diff --git a/AccessApproval/.OwlBot.yaml b/AccessApproval/.OwlBot.yaml index 6fd0b75c9e63..a7dc3172e300 100644 --- a/AccessApproval/.OwlBot.yaml +++ b/AccessApproval/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/accessapproval/v1/.*-php/(.*) - dest: /owl-bot-staging/AccessApproval/v1/$1 + - source: /google/cloud/accessapproval/(v1)/.*-php/(.*) + dest: /owl-bot-staging/AccessApproval/$1/$2 api-name: AccessApproval diff --git a/AccessApproval/owlbot.py b/AccessApproval/owlbot.py index 1c3242feba40..2033eeba731a 100644 --- a/AccessApproval/owlbot.py +++ b/AccessApproval/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ """This script is used to synthesize generated parts of this library.""" - import logging from pathlib import Path +import subprocess import synthtool as s from synthtool.languages import php @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,28 +41,16 @@ + "\n", '') -# [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -# [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/AccessApproval/src/V1/AccessApprovalClient.php b/AccessApproval/src/V1/AccessApprovalClient.php deleted file mode 100644 index 25a7af6d3752..000000000000 --- a/AccessApproval/src/V1/AccessApprovalClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Email address of the service account. * * Generated from protobuf field string account_email = 2; */ - private $account_email = ''; + protected $account_email = ''; /** * Constructor. diff --git a/AccessApproval/src/V1/AccessApprovalSettings.php b/AccessApproval/src/V1/AccessApprovalSettings.php index 9ec4a489a0a0..2175ebe2c3ca 100644 --- a/AccessApproval/src/V1/AccessApprovalSettings.php +++ b/AccessApproval/src/V1/AccessApprovalSettings.php @@ -23,7 +23,7 @@ class AccessApprovalSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * A list of email addresses to which notifications relating to approval * requests should be sent. Notifications relating to a resource will be sent @@ -57,7 +57,7 @@ class AccessApprovalSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enrolled_ancestor = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $enrolled_ancestor = false; + protected $enrolled_ancestor = false; /** * The asymmetric crypto key version to use for signing approval requests. * Empty active_key_version indicates that a Google-managed key should be used @@ -66,7 +66,7 @@ class AccessApprovalSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string active_key_version = 6; */ - private $active_key_version = ''; + protected $active_key_version = ''; /** * Output only. This field is read only (not settable via UpdateAccessApprovalSettings * method). If the field is true, that indicates that an ancestor of this @@ -75,7 +75,7 @@ class AccessApprovalSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool ancestor_has_active_key_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $ancestor_has_active_key_version = false; + protected $ancestor_has_active_key_version = false; /** * Output only. This field is read only (not settable via UpdateAccessApprovalSettings * method). If the field is true, that indicates that there is some @@ -87,7 +87,7 @@ class AccessApprovalSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool invalid_key_version = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $invalid_key_version = false; + protected $invalid_key_version = false; /** * Constructor. diff --git a/AccessApproval/src/V1/AccessLocations.php b/AccessApproval/src/V1/AccessLocations.php index 06f89579ec0c..3a5689084473 100644 --- a/AccessApproval/src/V1/AccessLocations.php +++ b/AccessApproval/src/V1/AccessLocations.php @@ -32,7 +32,7 @@ class AccessLocations extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string principal_office_country = 1; */ - private $principal_office_country = ''; + protected $principal_office_country = ''; /** * Physical location of the principal at the time of the access. A * two-letter country code (ISO 3166-1 alpha-2), such as "US", "DE" or "GB" or @@ -50,7 +50,7 @@ class AccessLocations extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string principal_physical_location_country = 2; */ - private $principal_physical_location_country = ''; + protected $principal_physical_location_country = ''; /** * Constructor. diff --git a/AccessApproval/src/V1/AccessReason.php b/AccessApproval/src/V1/AccessReason.php index 0cc7fd57ce79..9497b2f75c4b 100644 --- a/AccessApproval/src/V1/AccessReason.php +++ b/AccessApproval/src/V1/AccessReason.php @@ -18,13 +18,13 @@ class AccessReason extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.accessapproval.v1.AccessReason.Type type = 1; */ - private $type = 0; + protected $type = 0; /** * More detail about certain reason types. See comments for each type above. * * Generated from protobuf field string detail = 2; */ - private $detail = ''; + protected $detail = ''; /** * Constructor. diff --git a/AccessApproval/src/V1/ApprovalRequest.php b/AccessApproval/src/V1/ApprovalRequest.php index f2d782cecb4d..6efb0a4f7b9a 100644 --- a/AccessApproval/src/V1/ApprovalRequest.php +++ b/AccessApproval/src/V1/ApprovalRequest.php @@ -21,7 +21,7 @@ class ApprovalRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The resource for which approval is being requested. The format of the * resource name is defined at @@ -33,38 +33,38 @@ class ApprovalRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string requested_resource_name = 2; */ - private $requested_resource_name = ''; + protected $requested_resource_name = ''; /** * Properties related to the resource represented by requested_resource_name. * * Generated from protobuf field .google.cloud.accessapproval.v1.ResourceProperties requested_resource_properties = 9; */ - private $requested_resource_properties = null; + protected $requested_resource_properties = null; /** * The justification for which approval is being requested. * * Generated from protobuf field .google.cloud.accessapproval.v1.AccessReason requested_reason = 3; */ - private $requested_reason = null; + protected $requested_reason = null; /** * The locations for which approval is being requested. * * Generated from protobuf field .google.cloud.accessapproval.v1.AccessLocations requested_locations = 4; */ - private $requested_locations = null; + protected $requested_locations = null; /** * The time at which approval was requested. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 5; */ - private $request_time = null; + protected $request_time = null; /** * The requested expiration for the approval. If the request is approved, * access will be granted from the time of approval until the expiration time. * * Generated from protobuf field .google.protobuf.Timestamp requested_expiration = 6; */ - private $requested_expiration = null; + protected $requested_expiration = null; protected $decision; /** diff --git a/AccessApproval/src/V1/ApproveApprovalRequestMessage.php b/AccessApproval/src/V1/ApproveApprovalRequestMessage.php index 3a24e299d50b..cd0ed20e4d14 100644 --- a/AccessApproval/src/V1/ApproveApprovalRequestMessage.php +++ b/AccessApproval/src/V1/ApproveApprovalRequestMessage.php @@ -20,13 +20,13 @@ class ApproveApprovalRequestMessage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * The expiration time of this approval. * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 2; */ - private $expire_time = null; + protected $expire_time = null; /** * Constructor. diff --git a/AccessApproval/src/V1/ApproveDecision.php b/AccessApproval/src/V1/ApproveDecision.php index 82d73a8d7814..a9b020b1e3a0 100644 --- a/AccessApproval/src/V1/ApproveDecision.php +++ b/AccessApproval/src/V1/ApproveDecision.php @@ -20,31 +20,31 @@ class ApproveDecision extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp approve_time = 1; */ - private $approve_time = null; + protected $approve_time = null; /** * The time at which the approval expires. * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 2; */ - private $expire_time = null; + protected $expire_time = null; /** * If set, denotes the timestamp at which the approval is invalidated. * * Generated from protobuf field .google.protobuf.Timestamp invalidate_time = 3; */ - private $invalidate_time = null; + protected $invalidate_time = null; /** * The signature for the ApprovalRequest and details on how it was signed. * * Generated from protobuf field .google.cloud.accessapproval.v1.SignatureInfo signature_info = 4; */ - private $signature_info = null; + protected $signature_info = null; /** * True when the request has been auto-approved. * * Generated from protobuf field bool auto_approved = 5; */ - private $auto_approved = false; + protected $auto_approved = false; /** * Constructor. diff --git a/AccessApproval/src/V1/Client/AccessApprovalClient.php b/AccessApproval/src/V1/Client/AccessApprovalClient.php index 28353cec46e5..49b9332329d6 100644 --- a/AccessApproval/src/V1/Client/AccessApprovalClient.php +++ b/AccessApproval/src/V1/Client/AccessApprovalClient.php @@ -1,6 +1,6 @@ startApiCall('ApproveApprovalRequest', $request, $callOptions)->wait(); } @@ -481,8 +481,10 @@ public function approveApprovalRequest(ApproveApprovalRequestMessage $request, a * * @throws ApiException Thrown if the API call fails. */ - public function deleteAccessApprovalSettings(DeleteAccessApprovalSettingsMessage $request, array $callOptions = []): void - { + public function deleteAccessApprovalSettings( + DeleteAccessApprovalSettingsMessage $request, + array $callOptions = [] + ): void { $this->startApiCall('DeleteAccessApprovalSettings', $request, $callOptions)->wait(); } @@ -517,8 +519,10 @@ public function deleteAccessApprovalSettings(DeleteAccessApprovalSettingsMessage * * @throws ApiException Thrown if the API call fails. */ - public function dismissApprovalRequest(DismissApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest - { + public function dismissApprovalRequest( + DismissApprovalRequestMessage $request, + array $callOptions = [] + ): ApprovalRequest { return $this->startApiCall('DismissApprovalRequest', $request, $callOptions)->wait(); } @@ -545,8 +549,10 @@ public function dismissApprovalRequest(DismissApprovalRequestMessage $request, a * * @throws ApiException Thrown if the API call fails. */ - public function getAccessApprovalServiceAccount(GetAccessApprovalServiceAccountMessage $request, array $callOptions = []): AccessApprovalServiceAccount - { + public function getAccessApprovalServiceAccount( + GetAccessApprovalServiceAccountMessage $request, + array $callOptions = [] + ): AccessApprovalServiceAccount { return $this->startApiCall('GetAccessApprovalServiceAccount', $request, $callOptions)->wait(); } @@ -572,8 +578,10 @@ public function getAccessApprovalServiceAccount(GetAccessApprovalServiceAccountM * * @throws ApiException Thrown if the API call fails. */ - public function getAccessApprovalSettings(GetAccessApprovalSettingsMessage $request, array $callOptions = []): AccessApprovalSettings - { + public function getAccessApprovalSettings( + GetAccessApprovalSettingsMessage $request, + array $callOptions = [] + ): AccessApprovalSettings { return $this->startApiCall('GetAccessApprovalSettings', $request, $callOptions)->wait(); } @@ -632,8 +640,10 @@ public function getApprovalRequest(GetApprovalRequestMessage $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function invalidateApprovalRequest(InvalidateApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest - { + public function invalidateApprovalRequest( + InvalidateApprovalRequestMessage $request, + array $callOptions = [] + ): ApprovalRequest { return $this->startApiCall('InvalidateApprovalRequest', $request, $callOptions)->wait(); } @@ -660,8 +670,10 @@ public function invalidateApprovalRequest(InvalidateApprovalRequestMessage $requ * * @throws ApiException Thrown if the API call fails. */ - public function listApprovalRequests(ListApprovalRequestsMessage $request, array $callOptions = []): PagedListResponse - { + public function listApprovalRequests( + ListApprovalRequestsMessage $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListApprovalRequests', $request, $callOptions); } @@ -688,8 +700,10 @@ public function listApprovalRequests(ListApprovalRequestsMessage $request, array * * @throws ApiException Thrown if the API call fails. */ - public function updateAccessApprovalSettings(UpdateAccessApprovalSettingsMessage $request, array $callOptions = []): AccessApprovalSettings - { + public function updateAccessApprovalSettings( + UpdateAccessApprovalSettingsMessage $request, + array $callOptions = [] + ): AccessApprovalSettings { return $this->startApiCall('UpdateAccessApprovalSettings', $request, $callOptions)->wait(); } } diff --git a/AccessApproval/src/V1/DeleteAccessApprovalSettingsMessage.php b/AccessApproval/src/V1/DeleteAccessApprovalSettingsMessage.php index 03e9f9277726..e0ae5d40db9e 100644 --- a/AccessApproval/src/V1/DeleteAccessApprovalSettingsMessage.php +++ b/AccessApproval/src/V1/DeleteAccessApprovalSettingsMessage.php @@ -20,7 +20,7 @@ class DeleteAccessApprovalSettingsMessage extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Name of the AccessApprovalSettings to delete. diff --git a/AccessApproval/src/V1/DismissApprovalRequestMessage.php b/AccessApproval/src/V1/DismissApprovalRequestMessage.php index 330b07b2af87..174dfe04ef31 100644 --- a/AccessApproval/src/V1/DismissApprovalRequestMessage.php +++ b/AccessApproval/src/V1/DismissApprovalRequestMessage.php @@ -20,7 +20,7 @@ class DismissApprovalRequestMessage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/AccessApproval/src/V1/DismissDecision.php b/AccessApproval/src/V1/DismissDecision.php index 4e9a56538688..19d43a3a4de1 100644 --- a/AccessApproval/src/V1/DismissDecision.php +++ b/AccessApproval/src/V1/DismissDecision.php @@ -20,7 +20,7 @@ class DismissDecision extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp dismiss_time = 1; */ - private $dismiss_time = null; + protected $dismiss_time = null; /** * This field will be true if the ApprovalRequest was implicitly dismissed due * to inaction by the access approval approvers (the request is not acted @@ -28,7 +28,7 @@ class DismissDecision extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool implicit = 2; */ - private $implicit = false; + protected $implicit = false; /** * Constructor. diff --git a/AccessApproval/src/V1/EnrolledService.php b/AccessApproval/src/V1/EnrolledService.php index 91a9ea6cbf0d..c769d5624cef 100644 --- a/AccessApproval/src/V1/EnrolledService.php +++ b/AccessApproval/src/V1/EnrolledService.php @@ -75,13 +75,13 @@ class EnrolledService extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cloud_product = 1; */ - private $cloud_product = ''; + protected $cloud_product = ''; /** * The enrollment level of the service. * * Generated from protobuf field .google.cloud.accessapproval.v1.EnrollmentLevel enrollment_level = 2; */ - private $enrollment_level = 0; + protected $enrollment_level = 0; /** * Constructor. diff --git a/AccessApproval/src/V1/Gapic/AccessApprovalGapicClient.php b/AccessApproval/src/V1/Gapic/AccessApprovalGapicClient.php deleted file mode 100644 index 1cc7729e86e6..000000000000 --- a/AccessApproval/src/V1/Gapic/AccessApprovalGapicClient.php +++ /dev/null @@ -1,1055 +0,0 @@ -approveApprovalRequest(); - * } finally { - * $accessApprovalClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\AccessApproval\V1\Client\AccessApprovalClient}. - */ -class AccessApprovalGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.accessapproval.v1.AccessApproval'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'accessapproval.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'accessapproval.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $accessApprovalSettingsNameTemplate; - - private static $approvalRequestNameTemplate; - - private static $folderNameTemplate; - - private static $folderAccessApprovalSettingsNameTemplate; - - private static $folderApprovalRequestNameTemplate; - - private static $organizationNameTemplate; - - private static $organizationAccessApprovalSettingsNameTemplate; - - private static $organizationApprovalRequestNameTemplate; - - private static $projectNameTemplate; - - private static $projectAccessApprovalSettingsNameTemplate; - - private static $projectApprovalRequestNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getAccessApprovalSettingsNameTemplate() - { - if (self::$accessApprovalSettingsNameTemplate == null) { - self::$accessApprovalSettingsNameTemplate = new PathTemplate('projects/{project}/accessApprovalSettings'); - } - - return self::$accessApprovalSettingsNameTemplate; - } - - private static function getApprovalRequestNameTemplate() - { - if (self::$approvalRequestNameTemplate == null) { - self::$approvalRequestNameTemplate = new PathTemplate('projects/{project}/approvalRequests/{approval_request}'); - } - - return self::$approvalRequestNameTemplate; - } - - private static function getFolderNameTemplate() - { - if (self::$folderNameTemplate == null) { - self::$folderNameTemplate = new PathTemplate('folders/{folder}'); - } - - return self::$folderNameTemplate; - } - - private static function getFolderAccessApprovalSettingsNameTemplate() - { - if (self::$folderAccessApprovalSettingsNameTemplate == null) { - self::$folderAccessApprovalSettingsNameTemplate = new PathTemplate('folders/{folder}/accessApprovalSettings'); - } - - return self::$folderAccessApprovalSettingsNameTemplate; - } - - private static function getFolderApprovalRequestNameTemplate() - { - if (self::$folderApprovalRequestNameTemplate == null) { - self::$folderApprovalRequestNameTemplate = new PathTemplate('folders/{folder}/approvalRequests/{approval_request}'); - } - - return self::$folderApprovalRequestNameTemplate; - } - - private static function getOrganizationNameTemplate() - { - if (self::$organizationNameTemplate == null) { - self::$organizationNameTemplate = new PathTemplate('organizations/{organization}'); - } - - return self::$organizationNameTemplate; - } - - private static function getOrganizationAccessApprovalSettingsNameTemplate() - { - if (self::$organizationAccessApprovalSettingsNameTemplate == null) { - self::$organizationAccessApprovalSettingsNameTemplate = new PathTemplate('organizations/{organization}/accessApprovalSettings'); - } - - return self::$organizationAccessApprovalSettingsNameTemplate; - } - - private static function getOrganizationApprovalRequestNameTemplate() - { - if (self::$organizationApprovalRequestNameTemplate == null) { - self::$organizationApprovalRequestNameTemplate = new PathTemplate('organizations/{organization}/approvalRequests/{approval_request}'); - } - - return self::$organizationApprovalRequestNameTemplate; - } - - private static function getProjectNameTemplate() - { - if (self::$projectNameTemplate == null) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); - } - - return self::$projectNameTemplate; - } - - private static function getProjectAccessApprovalSettingsNameTemplate() - { - if (self::$projectAccessApprovalSettingsNameTemplate == null) { - self::$projectAccessApprovalSettingsNameTemplate = new PathTemplate('projects/{project}/accessApprovalSettings'); - } - - return self::$projectAccessApprovalSettingsNameTemplate; - } - - private static function getProjectApprovalRequestNameTemplate() - { - if (self::$projectApprovalRequestNameTemplate == null) { - self::$projectApprovalRequestNameTemplate = new PathTemplate('projects/{project}/approvalRequests/{approval_request}'); - } - - return self::$projectApprovalRequestNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'accessApprovalSettings' => self::getAccessApprovalSettingsNameTemplate(), - 'approvalRequest' => self::getApprovalRequestNameTemplate(), - 'folder' => self::getFolderNameTemplate(), - 'folderAccessApprovalSettings' => self::getFolderAccessApprovalSettingsNameTemplate(), - 'folderApprovalRequest' => self::getFolderApprovalRequestNameTemplate(), - 'organization' => self::getOrganizationNameTemplate(), - 'organizationAccessApprovalSettings' => self::getOrganizationAccessApprovalSettingsNameTemplate(), - 'organizationApprovalRequest' => self::getOrganizationApprovalRequestNameTemplate(), - 'project' => self::getProjectNameTemplate(), - 'projectAccessApprovalSettings' => self::getProjectAccessApprovalSettingsNameTemplate(), - 'projectApprovalRequest' => self::getProjectApprovalRequestNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project) - { - return self::getAccessApprovalSettingsNameTemplate()->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($project, $approvalRequest) - { - return self::getApprovalRequestNameTemplate()->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($folder) - { - return self::getFolderNameTemplate()->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($folder) - { - return self::getFolderAccessApprovalSettingsNameTemplate()->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($folder, $approvalRequest) - { - return self::getFolderApprovalRequestNameTemplate()->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($organization) - { - return self::getOrganizationNameTemplate()->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($organization) - { - return self::getOrganizationAccessApprovalSettingsNameTemplate()->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($organization, $approvalRequest) - { - return self::getOrganizationApprovalRequestNameTemplate()->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($project) - { - return self::getProjectNameTemplate()->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($project) - { - return self::getProjectAccessApprovalSettingsNameTemplate()->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($project, $approvalRequest) - { - return self::getProjectApprovalRequestNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * 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. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * $response = $accessApprovalClient->approveApprovalRequest(); - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the approval request to approve. - * @type Timestamp $expireTime - * The expiration time of this approval. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\AccessApproval\V1\ApprovalRequest - * - * @throws ApiException if the remote call fails - */ - public function approveApprovalRequest(array $optionalArgs = []) - { - $request = new ApproveApprovalRequestMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['expireTime'])) { - $request->setExpireTime($optionalArgs['expireTime']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ApproveApprovalRequest', ApprovalRequest::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * $accessApprovalClient->deleteAccessApprovalSettings(); - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the AccessApprovalSettings to delete. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 deleteAccessApprovalSettings(array $optionalArgs = []) - { - $request = new DeleteAccessApprovalSettingsMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteAccessApprovalSettings', GPBEmpty::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * $response = $accessApprovalClient->dismissApprovalRequest(); - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the ApprovalRequest to dismiss. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\AccessApproval\V1\ApprovalRequest - * - * @throws ApiException if the remote call fails - */ - public function dismissApprovalRequest(array $optionalArgs = []) - { - $request = new DismissApprovalRequestMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DismissApprovalRequest', ApprovalRequest::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the service account that is used by Access Approval to access KMS - * keys for signing approved approval requests. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * $response = $accessApprovalClient->getAccessApprovalServiceAccount(); - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the AccessApprovalServiceAccount to retrieve. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\AccessApproval\V1\AccessApprovalServiceAccount - * - * @throws ApiException if the remote call fails - */ - public function getAccessApprovalServiceAccount(array $optionalArgs = []) - { - $request = new GetAccessApprovalServiceAccountMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetAccessApprovalServiceAccount', AccessApprovalServiceAccount::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the settings associated with a project, folder, or organization. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * $response = $accessApprovalClient->getAccessApprovalSettings(); - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The name of the AccessApprovalSettings to retrieve. - * Format: "{projects|folders|organizations}/{id}/accessApprovalSettings" - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\AccessApproval\V1\AccessApprovalSettings - * - * @throws ApiException if the remote call fails - */ - public function getAccessApprovalSettings(array $optionalArgs = []) - { - $request = new GetAccessApprovalSettingsMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetAccessApprovalSettings', AccessApprovalSettings::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets an approval request. Returns NOT_FOUND if the request does not exist. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * $response = $accessApprovalClient->getApprovalRequest(); - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The name of the approval request to retrieve. - * Format: - * "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}" - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\AccessApproval\V1\ApprovalRequest - * - * @throws ApiException if the remote call fails - */ - public function getApprovalRequest(array $optionalArgs = []) - { - $request = new GetApprovalRequestMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetApprovalRequest', ApprovalRequest::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * $response = $accessApprovalClient->invalidateApprovalRequest(); - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the ApprovalRequest to invalidate. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\AccessApproval\V1\ApprovalRequest - * - * @throws ApiException if the remote call fails - */ - public function invalidateApprovalRequest(array $optionalArgs = []) - { - $request = new InvalidateApprovalRequestMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('InvalidateApprovalRequest', ApprovalRequest::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $accessApprovalClient->listApprovalRequests(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $accessApprovalClient->listApprovalRequests(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * The parent resource. This may be "projects/{project}", - * "folders/{folder}", or "organizations/{organization}". - * @type string $filter - * A filter on the type of approval requests to retrieve. Must be one of the - * following values: - * - * * [not set]: Requests that are pending or have active approvals. - * * ALL: All requests. - * * PENDING: Only pending requests. - * * ACTIVE: Only active (i.e. currently approved) requests. - * * DISMISSED: Only requests that have been dismissed, or requests that - * are not approved and past expiration. - * * EXPIRED: Only requests that have been approved, and the approval has - * expired. - * * HISTORY: Active, dismissed and expired requests. - * @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 listApprovalRequests(array $optionalArgs = []) - { - $request = new ListApprovalRequestsMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['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']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListApprovalRequests', $optionalArgs, ListApprovalRequestsResponse::class, $request); - } - - /** - * Updates the settings associated with a project, folder, or organization. - * Settings to update are determined by the value of field_mask. - * - * Sample code: - * ``` - * $accessApprovalClient = new AccessApprovalClient(); - * try { - * $response = $accessApprovalClient->updateAccessApprovalSettings(); - * } finally { - * $accessApprovalClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type AccessApprovalSettings $settings - * The new AccessApprovalSettings. - * @type FieldMask $updateMask - * The update mask applies to the settings. Only the top level fields of - * AccessApprovalSettings (notification_emails & enrolled_services) are - * supported. For each field, if it is included, the currently stored value - * will be entirely overwritten with the value of the field passed in this - * request. - * - * For the `FieldMask` definition, see - * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - * If this field is left unset, only the notification_emails field 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\AccessApproval\V1\AccessApprovalSettings - * - * @throws ApiException if the remote call fails - */ - public function updateAccessApprovalSettings(array $optionalArgs = []) - { - $request = new UpdateAccessApprovalSettingsMessage(); - $requestParamHeaders = []; - if (isset($optionalArgs['settings'])) { - $request->setSettings($optionalArgs['settings']); - } - - 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('UpdateAccessApprovalSettings', AccessApprovalSettings::class, $optionalArgs, $request)->wait(); - } -} diff --git a/AccessApproval/src/V1/GetAccessApprovalServiceAccountMessage.php b/AccessApproval/src/V1/GetAccessApprovalServiceAccountMessage.php index c24b1f04ed46..8c60086e1126 100644 --- a/AccessApproval/src/V1/GetAccessApprovalServiceAccountMessage.php +++ b/AccessApproval/src/V1/GetAccessApprovalServiceAccountMessage.php @@ -20,7 +20,7 @@ class GetAccessApprovalServiceAccountMessage extends \Google\Protobuf\Internal\M * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * @param string $name Name of the AccessApprovalServiceAccount to retrieve. diff --git a/AccessApproval/src/V1/GetAccessApprovalSettingsMessage.php b/AccessApproval/src/V1/GetAccessApprovalSettingsMessage.php index 3481d9b58123..4a7399d3cb5b 100644 --- a/AccessApproval/src/V1/GetAccessApprovalSettingsMessage.php +++ b/AccessApproval/src/V1/GetAccessApprovalSettingsMessage.php @@ -21,7 +21,7 @@ class GetAccessApprovalSettingsMessage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name The name of the AccessApprovalSettings to retrieve. diff --git a/AccessApproval/src/V1/GetApprovalRequestMessage.php b/AccessApproval/src/V1/GetApprovalRequestMessage.php index b47abdd8d2b8..62bf7cb4b8ce 100644 --- a/AccessApproval/src/V1/GetApprovalRequestMessage.php +++ b/AccessApproval/src/V1/GetApprovalRequestMessage.php @@ -22,7 +22,7 @@ class GetApprovalRequestMessage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name The name of the approval request to retrieve. diff --git a/AccessApproval/src/V1/InvalidateApprovalRequestMessage.php b/AccessApproval/src/V1/InvalidateApprovalRequestMessage.php index edc0d04e0191..53af32cef366 100644 --- a/AccessApproval/src/V1/InvalidateApprovalRequestMessage.php +++ b/AccessApproval/src/V1/InvalidateApprovalRequestMessage.php @@ -20,7 +20,7 @@ class InvalidateApprovalRequestMessage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/AccessApproval/src/V1/ListApprovalRequestsMessage.php b/AccessApproval/src/V1/ListApprovalRequestsMessage.php index 75f400f9d781..f0c5974aa1e2 100644 --- a/AccessApproval/src/V1/ListApprovalRequestsMessage.php +++ b/AccessApproval/src/V1/ListApprovalRequestsMessage.php @@ -21,7 +21,7 @@ class ListApprovalRequestsMessage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * A filter on the type of approval requests to retrieve. Must be one of the * following values: @@ -37,19 +37,19 @@ class ListApprovalRequestsMessage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 2; */ - private $filter = ''; + protected $filter = ''; /** * Requested page size. * * Generated from protobuf field int32 page_size = 3; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying the page of results to return. * * Generated from protobuf field string page_token = 4; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent The parent resource. This may be "projects/{project}", diff --git a/AccessApproval/src/V1/ListApprovalRequestsResponse.php b/AccessApproval/src/V1/ListApprovalRequestsResponse.php index c12903f866cc..1a7f36a9dc4f 100644 --- a/AccessApproval/src/V1/ListApprovalRequestsResponse.php +++ b/AccessApproval/src/V1/ListApprovalRequestsResponse.php @@ -26,7 +26,7 @@ class ListApprovalRequestsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/AccessApproval/src/V1/ResourceProperties.php b/AccessApproval/src/V1/ResourceProperties.php index 6991ce0ea59e..23a501d4e8f1 100644 --- a/AccessApproval/src/V1/ResourceProperties.php +++ b/AccessApproval/src/V1/ResourceProperties.php @@ -21,7 +21,7 @@ class ResourceProperties extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool excludes_descendants = 1; */ - private $excludes_descendants = false; + protected $excludes_descendants = false; /** * Constructor. diff --git a/AccessApproval/src/V1/SignatureInfo.php b/AccessApproval/src/V1/SignatureInfo.php index 19d3409f6b23..1755b4bb1723 100644 --- a/AccessApproval/src/V1/SignatureInfo.php +++ b/AccessApproval/src/V1/SignatureInfo.php @@ -20,7 +20,7 @@ class SignatureInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes signature = 1; */ - private $signature = ''; + protected $signature = ''; protected $verification_info; /** diff --git a/AccessApproval/src/V1/UpdateAccessApprovalSettingsMessage.php b/AccessApproval/src/V1/UpdateAccessApprovalSettingsMessage.php index a26305d737da..7a9c9849b269 100644 --- a/AccessApproval/src/V1/UpdateAccessApprovalSettingsMessage.php +++ b/AccessApproval/src/V1/UpdateAccessApprovalSettingsMessage.php @@ -20,7 +20,7 @@ class UpdateAccessApprovalSettingsMessage extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field .google.cloud.accessapproval.v1.AccessApprovalSettings settings = 1; */ - private $settings = null; + protected $settings = null; /** * The update mask applies to the settings. Only the top level fields of * AccessApprovalSettings (notification_emails & enrolled_services) are @@ -34,7 +34,7 @@ class UpdateAccessApprovalSettingsMessage extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\AccessApproval\V1\AccessApprovalSettings $settings The new AccessApprovalSettings. diff --git a/AccessApproval/tests/Unit/V1/AccessApprovalClientTest.php b/AccessApproval/tests/Unit/V1/AccessApprovalClientTest.php deleted file mode 100644 index 5e5c46ed94ad..000000000000 --- a/AccessApproval/tests/Unit/V1/AccessApprovalClientTest.php +++ /dev/null @@ -1,582 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return AccessApprovalClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new AccessApprovalClient($options); - } - - /** @test */ - public function approveApprovalRequestTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $requestedResourceName = 'requestedResourceName-1409378037'; - $expectedResponse = new ApprovalRequest(); - $expectedResponse->setName($name2); - $expectedResponse->setRequestedResourceName($requestedResourceName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->approveApprovalRequest(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/ApproveApprovalRequest', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function approveApprovalRequestExceptionTest() - { - $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); - try { - $gapicClient->approveApprovalRequest(); - // 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 deleteAccessApprovalSettingsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - $gapicClient->deleteAccessApprovalSettings(); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/DeleteAccessApprovalSettings', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteAccessApprovalSettingsExceptionTest() - { - $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); - try { - $gapicClient->deleteAccessApprovalSettings(); - // 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 dismissApprovalRequestTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $requestedResourceName = 'requestedResourceName-1409378037'; - $expectedResponse = new ApprovalRequest(); - $expectedResponse->setName($name2); - $expectedResponse->setRequestedResourceName($requestedResourceName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->dismissApprovalRequest(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/DismissApprovalRequest', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function dismissApprovalRequestExceptionTest() - { - $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); - try { - $gapicClient->dismissApprovalRequest(); - // 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 getAccessApprovalServiceAccountTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $accountEmail = 'accountEmail-539286774'; - $expectedResponse = new AccessApprovalServiceAccount(); - $expectedResponse->setName($name2); - $expectedResponse->setAccountEmail($accountEmail); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getAccessApprovalServiceAccount(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/GetAccessApprovalServiceAccount', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getAccessApprovalServiceAccountExceptionTest() - { - $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); - try { - $gapicClient->getAccessApprovalServiceAccount(); - // 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 getAccessApprovalSettingsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $enrolledAncestor = false; - $activeKeyVersion = 'activeKeyVersion559224639'; - $ancestorHasActiveKeyVersion = true; - $invalidKeyVersion = true; - $expectedResponse = new AccessApprovalSettings(); - $expectedResponse->setName($name2); - $expectedResponse->setEnrolledAncestor($enrolledAncestor); - $expectedResponse->setActiveKeyVersion($activeKeyVersion); - $expectedResponse->setAncestorHasActiveKeyVersion($ancestorHasActiveKeyVersion); - $expectedResponse->setInvalidKeyVersion($invalidKeyVersion); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getAccessApprovalSettings(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/GetAccessApprovalSettings', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getAccessApprovalSettingsExceptionTest() - { - $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); - try { - $gapicClient->getAccessApprovalSettings(); - // 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 getApprovalRequestTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $requestedResourceName = 'requestedResourceName-1409378037'; - $expectedResponse = new ApprovalRequest(); - $expectedResponse->setName($name2); - $expectedResponse->setRequestedResourceName($requestedResourceName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getApprovalRequest(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/GetApprovalRequest', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getApprovalRequestExceptionTest() - { - $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); - try { - $gapicClient->getApprovalRequest(); - // 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 invalidateApprovalRequestTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $requestedResourceName = 'requestedResourceName-1409378037'; - $expectedResponse = new ApprovalRequest(); - $expectedResponse->setName($name2); - $expectedResponse->setRequestedResourceName($requestedResourceName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->invalidateApprovalRequest(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/InvalidateApprovalRequest', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function invalidateApprovalRequestExceptionTest() - { - $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); - try { - $gapicClient->invalidateApprovalRequest(); - // 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 listApprovalRequestsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $approvalRequestsElement = new ApprovalRequest(); - $approvalRequests = [ - $approvalRequestsElement, - ]; - $expectedResponse = new ListApprovalRequestsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setApprovalRequests($approvalRequests); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listApprovalRequests(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getApprovalRequests()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/ListApprovalRequests', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listApprovalRequestsExceptionTest() - { - $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); - try { - $gapicClient->listApprovalRequests(); - // 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 updateAccessApprovalSettingsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $enrolledAncestor = false; - $activeKeyVersion = 'activeKeyVersion559224639'; - $ancestorHasActiveKeyVersion = true; - $invalidKeyVersion = true; - $expectedResponse = new AccessApprovalSettings(); - $expectedResponse->setName($name); - $expectedResponse->setEnrolledAncestor($enrolledAncestor); - $expectedResponse->setActiveKeyVersion($activeKeyVersion); - $expectedResponse->setAncestorHasActiveKeyVersion($ancestorHasActiveKeyVersion); - $expectedResponse->setInvalidKeyVersion($invalidKeyVersion); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateAccessApprovalSettings(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/UpdateAccessApprovalSettings', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateAccessApprovalSettingsExceptionTest() - { - $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); - try { - $gapicClient->updateAccessApprovalSettings(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/AccessApproval/tests/Unit/V1/Client/AccessApprovalClientTest.php b/AccessApproval/tests/Unit/V1/Client/AccessApprovalClientTest.php index eefc6dfc49ab..1c7e1ac64ed2 100644 --- a/AccessApproval/tests/Unit/V1/Client/AccessApprovalClientTest.php +++ b/AccessApproval/tests/Unit/V1/Client/AccessApprovalClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return AccessApprovalClient */ @@ -109,12 +111,15 @@ public function approveApprovalRequestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ApproveApprovalRequestMessage(); try { @@ -147,7 +152,10 @@ public function deleteAccessApprovalSettingsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/DeleteAccessApprovalSettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.accessapproval.v1.AccessApproval/DeleteAccessApprovalSettings', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -162,12 +170,15 @@ public function deleteAccessApprovalSettingsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new DeleteAccessApprovalSettingsMessage(); try { @@ -220,12 +231,15 @@ public function dismissApprovalRequestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new DismissApprovalRequestMessage(); try { @@ -263,7 +277,10 @@ public function getAccessApprovalServiceAccountTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/GetAccessApprovalServiceAccount', $actualFuncCall); + $this->assertSame( + '/google.cloud.accessapproval.v1.AccessApproval/GetAccessApprovalServiceAccount', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -278,12 +295,15 @@ public function getAccessApprovalServiceAccountExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetAccessApprovalServiceAccountMessage(); try { @@ -342,12 +362,15 @@ public function getAccessApprovalSettingsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetAccessApprovalSettingsMessage(); try { @@ -400,12 +423,15 @@ public function getApprovalRequestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetApprovalRequestMessage(); try { @@ -458,12 +484,15 @@ public function invalidateApprovalRequestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new InvalidateApprovalRequestMessage(); try { @@ -490,9 +519,7 @@ public function listApprovalRequestsTest() // Mock response $nextPageToken = ''; $approvalRequestsElement = new ApprovalRequest(); - $approvalRequests = [ - $approvalRequestsElement, - ]; + $approvalRequests = [$approvalRequestsElement]; $expectedResponse = new ListApprovalRequestsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setApprovalRequests($approvalRequests); @@ -522,12 +549,15 @@ public function listApprovalRequestsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListApprovalRequestsMessage(); try { @@ -571,7 +601,10 @@ public function updateAccessApprovalSettingsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.accessapproval.v1.AccessApproval/UpdateAccessApprovalSettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.accessapproval.v1.AccessApproval/UpdateAccessApprovalSettings', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -586,12 +619,15 @@ public function updateAccessApprovalSettingsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdateAccessApprovalSettingsMessage(); try { diff --git a/ApigeeConnect/.OwlBot.yaml b/ApigeeConnect/.OwlBot.yaml index aaef1898007a..509d524b02ca 100644 --- a/ApigeeConnect/.OwlBot.yaml +++ b/ApigeeConnect/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/apigeeconnect/v1/.*-php/(.*) - dest: /owl-bot-staging/ApigeeConnect/v1/$1 + - source: /google/cloud/apigeeconnect/(v1)/.*-php/(.*) + dest: /owl-bot-staging/ApigeeConnect/$1/$2 api-name: ApigeeConnect diff --git a/ApigeeConnect/owlbot.py b/ApigeeConnect/owlbot.py index 2f3e3c3b148d..7e1a5289181b 100644 --- a/ApigeeConnect/owlbot.py +++ b/ApigeeConnect/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,28 +41,16 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/ApigeeConnect/src/V1/Client/ConnectionServiceClient.php b/ApigeeConnect/src/V1/Client/ConnectionServiceClient.php index ef365d07038c..f32e0e799552 100644 --- a/ApigeeConnect/src/V1/Client/ConnectionServiceClient.php +++ b/ApigeeConnect/src/V1/Client/ConnectionServiceClient.php @@ -1,6 +1,6 @@ string name = 1; */ - private $name = ''; + protected $name = ''; /** * The region of the cluster. * * Generated from protobuf field string region = 2; */ - private $region = ''; + protected $region = ''; /** * Constructor. diff --git a/ApigeeConnect/src/V1/Connection.php b/ApigeeConnect/src/V1/Connection.php index f5486ed54a1a..605e1d267284 100644 --- a/ApigeeConnect/src/V1/Connection.php +++ b/ApigeeConnect/src/V1/Connection.php @@ -19,19 +19,19 @@ class Connection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string endpoint = 1; */ - private $endpoint = ''; + protected $endpoint = ''; /** * Cluster information. * * Generated from protobuf field .google.cloud.apigeeconnect.v1.Cluster cluster = 2; */ - private $cluster = null; + protected $cluster = null; /** * The count of streams. * * Generated from protobuf field int32 stream_count = 3; */ - private $stream_count = 0; + protected $stream_count = 0; /** * Constructor. diff --git a/ApigeeConnect/src/V1/ConnectionServiceClient.php b/ApigeeConnect/src/V1/ConnectionServiceClient.php deleted file mode 100644 index 2f8a4d1d9a26..000000000000 --- a/ApigeeConnect/src/V1/ConnectionServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string id = 1; */ - private $id = ''; + protected $id = ''; /** * Actual payload to send to agent. * * Generated from protobuf field .google.cloud.apigeeconnect.v1.Payload payload = 2; */ - private $payload = null; + protected $payload = null; /** * Tether Endpoint. * * Generated from protobuf field .google.cloud.apigeeconnect.v1.TetherEndpoint endpoint = 3; */ - private $endpoint = 0; + protected $endpoint = 0; /** * GCP Project. * Format: `projects/{project_number}`. * * Generated from protobuf field string project = 4; */ - private $project = ''; + protected $project = ''; /** * Unique identifier for clients to trace their request/response. * * Generated from protobuf field string trace_id = 5; */ - private $trace_id = ''; + protected $trace_id = ''; /** * Timeout for the HTTP request. * * Generated from protobuf field .google.protobuf.Duration timeout = 6; */ - private $timeout = null; + protected $timeout = null; /** * Constructor. diff --git a/ApigeeConnect/src/V1/EgressResponse.php b/ApigeeConnect/src/V1/EgressResponse.php index 74da2dd63ff1..0f3a9b16f827 100644 --- a/ApigeeConnect/src/V1/EgressResponse.php +++ b/ApigeeConnect/src/V1/EgressResponse.php @@ -20,46 +20,46 @@ class EgressResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * HttpResponse. * * Generated from protobuf field .google.cloud.apigeeconnect.v1.HttpResponse http_response = 2; */ - private $http_response = null; + protected $http_response = null; /** * Errors from application when handling the http request. * * Generated from protobuf field .google.rpc.Status status = 3; */ - private $status = null; + protected $status = null; /** * GCP Project. * Format: `projects/{project_number}`. * * Generated from protobuf field string project = 4; */ - private $project = ''; + protected $project = ''; /** * Unique identifier for clients to trace their request/response. Matches the * EgressRequest's trace id * * Generated from protobuf field string trace_id = 5; */ - private $trace_id = ''; + protected $trace_id = ''; /** * Tether Endpoint. * * Generated from protobuf field .google.cloud.apigeeconnect.v1.TetherEndpoint endpoint = 6; */ - private $endpoint = 0; + protected $endpoint = 0; /** * Name is the full resource path of endpoint. * Format: `projects/{project_number or project_id}/endpoints/{endpoint}` * * Generated from protobuf field string name = 7; */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/ApigeeConnect/src/V1/Gapic/ConnectionServiceGapicClient.php b/ApigeeConnect/src/V1/Gapic/ConnectionServiceGapicClient.php deleted file mode 100644 index 1d54fb6a86e3..000000000000 --- a/ApigeeConnect/src/V1/Gapic/ConnectionServiceGapicClient.php +++ /dev/null @@ -1,332 +0,0 @@ -endpointName('[PROJECT]', '[ENDPOINT]'); - * // Iterate over pages of elements - * $pagedResponse = $connectionServiceClient->listConnections($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $connectionServiceClient->listConnections($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $connectionServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\ApigeeConnect\V1\Client\ConnectionServiceClient}. - */ -class ConnectionServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.apigeeconnect.v1.ConnectionService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'apigeeconnect.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'apigeeconnect.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $endpointNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getEndpointNameTemplate() - { - if (self::$endpointNameTemplate == null) { - self::$endpointNameTemplate = new PathTemplate('projects/{project}/endpoints/{endpoint}'); - } - - return self::$endpointNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'endpoint' => self::getEndpointNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $endpoint) - { - return self::getEndpointNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * Lists connections that are currently active for the given Apigee Connect - * endpoint. - * - * Sample code: - * ``` - * $connectionServiceClient = new ConnectionServiceClient(); - * try { - * $formattedParent = $connectionServiceClient->endpointName('[PROJECT]', '[ENDPOINT]'); - * // Iterate over pages of elements - * $pagedResponse = $connectionServiceClient->listConnections($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $connectionServiceClient->listConnections($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $connectionServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent name of the form: - * `projects/{project_number or project_id}/endpoints/{endpoint}`. - * @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 listConnections($parent, array $optionalArgs = []) - { - $request = new ListConnectionsRequest(); - $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('ListConnections', $optionalArgs, ListConnectionsResponse::class, $request); - } -} diff --git a/ApigeeConnect/src/V1/Gapic/TetherGapicClient.php b/ApigeeConnect/src/V1/Gapic/TetherGapicClient.php deleted file mode 100644 index 72b079af2f19..000000000000 --- a/ApigeeConnect/src/V1/Gapic/TetherGapicClient.php +++ /dev/null @@ -1,257 +0,0 @@ -egress(); - * $stream->writeAll($requests); - * foreach ($stream->closeWriteAndReadAll() as $element) { - * // doSomethingWith($element); - * } - * // Alternatively: - * // Write requests individually, making read() calls if - * // required. Call closeWrite() once writes are complete, and read the - * // remaining responses from the server. - * $requests = [ - * $request, - * ]; - * $stream = $tetherClient->egress(); - * foreach ($requests as $request) { - * $stream->write($request); - * // if required, read a single response from the stream - * $element = $stream->read(); - * // doSomethingWith($element) - * } - * $stream->closeWrite(); - * $element = $stream->read(); - * while (!is_null($element)) { - * // doSomethingWith($element) - * $element = $stream->read(); - * } - * } finally { - * $tetherClient->close(); - * } - * ``` - * - * @deprecated Please use the new service client {@see \Google\Cloud\ApigeeConnect\V1\Client\TetherClient}. - */ -class TetherGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.apigeeconnect.v1.Tether'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'apigeeconnect.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'apigeeconnect.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static 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. - * - * Sample code: - * ``` - * $tetherClient = new TetherClient(); - * try { - * $request = new EgressResponse(); - * // Write all requests to the server, then read all responses until the - * // stream is complete - * $requests = [ - * $request, - * ]; - * $stream = $tetherClient->egress(); - * $stream->writeAll($requests); - * foreach ($stream->closeWriteAndReadAll() as $element) { - * // doSomethingWith($element); - * } - * // Alternatively: - * // Write requests individually, making read() calls if - * // required. Call closeWrite() once writes are complete, and read the - * // remaining responses from the server. - * $requests = [ - * $request, - * ]; - * $stream = $tetherClient->egress(); - * foreach ($requests as $request) { - * $stream->write($request); - * // if required, read a single response from the stream - * $element = $stream->read(); - * // doSomethingWith($element) - * } - * $stream->closeWrite(); - * $element = $stream->read(); - * while (!is_null($element)) { - * // doSomethingWith($element) - * $element = $stream->read(); - * } - * } finally { - * $tetherClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return \Google\ApiCore\BidiStream - * - * @throws ApiException if the remote call fails - */ - public function egress(array $optionalArgs = []) - { - return $this->startCall('Egress', EgressRequest::class, $optionalArgs, null, Call::BIDI_STREAMING_CALL); - } -} diff --git a/ApigeeConnect/src/V1/Header.php b/ApigeeConnect/src/V1/Header.php index 6ead2484eaa7..67bbddc21b71 100644 --- a/ApigeeConnect/src/V1/Header.php +++ b/ApigeeConnect/src/V1/Header.php @@ -18,7 +18,7 @@ class Header extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field string key = 1; */ - private $key = ''; + protected $key = ''; /** * Generated from protobuf field repeated string values = 2; */ diff --git a/ApigeeConnect/src/V1/HttpRequest.php b/ApigeeConnect/src/V1/HttpRequest.php index 117ebccd0b6a..aa38738186a9 100644 --- a/ApigeeConnect/src/V1/HttpRequest.php +++ b/ApigeeConnect/src/V1/HttpRequest.php @@ -20,20 +20,20 @@ class HttpRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * The HTTP request method. * Valid methods: "GET", "HEAD", "POST", "PUT", "PATCH","DELETE". * * Generated from protobuf field string method = 2; */ - private $method = ''; + protected $method = ''; /** * The HTTP request URL. * * Generated from protobuf field .google.cloud.apigeeconnect.v1.Url url = 3; */ - private $url = null; + protected $url = null; /** * The HTTP request headers. * @@ -45,7 +45,7 @@ class HttpRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes body = 5; */ - private $body = ''; + protected $body = ''; /** * Constructor. diff --git a/ApigeeConnect/src/V1/HttpResponse.php b/ApigeeConnect/src/V1/HttpResponse.php index 73335f3f586f..d79ba359efb9 100644 --- a/ApigeeConnect/src/V1/HttpResponse.php +++ b/ApigeeConnect/src/V1/HttpResponse.php @@ -20,25 +20,25 @@ class HttpResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * Status of http response, e.g. "200 OK". * * Generated from protobuf field string status = 2; */ - private $status = ''; + protected $status = ''; /** * Status code of http response, e.g. 200. * * Generated from protobuf field int32 status_code = 3; */ - private $status_code = 0; + protected $status_code = 0; /** * The HTTP 1.1 response body. * * Generated from protobuf field bytes body = 4; */ - private $body = ''; + protected $body = ''; /** * The HTTP response headers. * @@ -53,7 +53,7 @@ class HttpResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 content_length = 6; */ - private $content_length = 0; + protected $content_length = 0; /** * Constructor. diff --git a/ApigeeConnect/src/V1/ListConnectionsRequest.php b/ApigeeConnect/src/V1/ListConnectionsRequest.php index 7260ccfe33de..2ef0d60271f1 100644 --- a/ApigeeConnect/src/V1/ListConnectionsRequest.php +++ b/ApigeeConnect/src/V1/ListConnectionsRequest.php @@ -21,7 +21,7 @@ class ListConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of connections to return. The service may return fewer * than this value. If unspecified, at most 100 connections will be returned. @@ -29,7 +29,7 @@ class ListConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A page token, received from a previous `ListConnections` call. * Provide this to retrieve the subsequent page. @@ -38,7 +38,7 @@ class ListConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Parent name of the form: diff --git a/ApigeeConnect/src/V1/ListConnectionsResponse.php b/ApigeeConnect/src/V1/ListConnectionsResponse.php index b0668603d5e3..66033f7b56a1 100644 --- a/ApigeeConnect/src/V1/ListConnectionsResponse.php +++ b/ApigeeConnect/src/V1/ListConnectionsResponse.php @@ -28,7 +28,7 @@ class ListConnectionsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/ApigeeConnect/src/V1/StreamInfo.php b/ApigeeConnect/src/V1/StreamInfo.php index 63519e2442cd..c75fc3c7d379 100644 --- a/ApigeeConnect/src/V1/StreamInfo.php +++ b/ApigeeConnect/src/V1/StreamInfo.php @@ -20,7 +20,7 @@ class StreamInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * Constructor. diff --git a/ApigeeConnect/src/V1/TetherClient.php b/ApigeeConnect/src/V1/TetherClient.php deleted file mode 100644 index 83ac0cd4cb0c..000000000000 --- a/ApigeeConnect/src/V1/TetherClient.php +++ /dev/null @@ -1,34 +0,0 @@ -.google.cloud.apigeeconnect.v1.Scheme scheme = 1; */ - private $scheme = 0; + protected $scheme = 0; /** * Host or Host:Port. * * Generated from protobuf field string host = 2; */ - private $host = ''; + protected $host = ''; /** * Path starts with `/`. * * Generated from protobuf field string path = 3; */ - private $path = ''; + protected $path = ''; /** * Constructor. diff --git a/ApigeeConnect/tests/Unit/V1/Client/ConnectionServiceClientTest.php b/ApigeeConnect/tests/Unit/V1/Client/ConnectionServiceClientTest.php index 2f4c79227a8d..0d7a4ccbe963 100644 --- a/ApigeeConnect/tests/Unit/V1/Client/ConnectionServiceClientTest.php +++ b/ApigeeConnect/tests/Unit/V1/Client/ConnectionServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ConnectionServiceClient */ @@ -72,17 +74,14 @@ public function listConnectionsTest() // Mock response $nextPageToken = ''; $connectionsElement = new Connection(); - $connections = [ - $connectionsElement, - ]; + $connections = [$connectionsElement]; $expectedResponse = new ListConnectionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setConnections($connections); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->endpointName('[PROJECT]', '[ENDPOINT]'); - $request = (new ListConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListConnectionsRequest())->setParent($formattedParent); $response = $gapicClient->listConnections($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -109,17 +108,19 @@ public function listConnectionsExceptionTest() $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); + $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->endpointName('[PROJECT]', '[ENDPOINT]'); - $request = (new ListConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListConnectionsRequest())->setParent($formattedParent); try { $gapicClient->listConnections($request); // If the $gapicClient method call did not throw, fail the test @@ -144,17 +145,14 @@ public function listConnectionsAsyncTest() // Mock response $nextPageToken = ''; $connectionsElement = new Connection(); - $connections = [ - $connectionsElement, - ]; + $connections = [$connectionsElement]; $expectedResponse = new ListConnectionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setConnections($connections); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->endpointName('[PROJECT]', '[ENDPOINT]'); - $request = (new ListConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListConnectionsRequest())->setParent($formattedParent); $response = $gapicClient->listConnectionsAsync($request)->wait(); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); diff --git a/ApigeeConnect/tests/Unit/V1/Client/TetherClientTest.php b/ApigeeConnect/tests/Unit/V1/Client/TetherClientTest.php index ca67b3fa7b3d..382c426c68f4 100644 --- a/ApigeeConnect/tests/Unit/V1/Client/TetherClientTest.php +++ b/ApigeeConnect/tests/Unit/V1/Client/TetherClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return TetherClient */ @@ -103,10 +105,7 @@ public function egressTest() $bidi->write($request); $responses = []; $responses[] = $bidi->read(); - $bidi->writeAll([ - $request2, - $request3, - ]); + $bidi->writeAll([$request2, $request3]); foreach ($bidi->closeWriteAndReadAll() as $response) { $responses[] = $response; } @@ -144,12 +143,15 @@ public function egressExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->setStreamingStatus($status); $this->assertTrue($transport->isExhausted()); $bidi = $gapicClient->egress(); diff --git a/ApigeeConnect/tests/Unit/V1/ConnectionServiceClientTest.php b/ApigeeConnect/tests/Unit/V1/ConnectionServiceClientTest.php deleted file mode 100644 index b1ead38cc6df..000000000000 --- a/ApigeeConnect/tests/Unit/V1/ConnectionServiceClientTest.php +++ /dev/null @@ -1,130 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ConnectionServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ConnectionServiceClient($options); - } - - /** @test */ - public function listConnectionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $connectionsElement = new Connection(); - $connections = [ - $connectionsElement, - ]; - $expectedResponse = new ListConnectionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setConnections($connections); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->endpointName('[PROJECT]', '[ENDPOINT]'); - $response = $gapicClient->listConnections($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getConnections()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.apigeeconnect.v1.ConnectionService/ListConnections', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listConnectionsExceptionTest() - { - $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->endpointName('[PROJECT]', '[ENDPOINT]'); - try { - $gapicClient->listConnections($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()); - } -} diff --git a/ApigeeConnect/tests/Unit/V1/TetherClientTest.php b/ApigeeConnect/tests/Unit/V1/TetherClientTest.php deleted file mode 100644 index 7970157025d2..000000000000 --- a/ApigeeConnect/tests/Unit/V1/TetherClientTest.php +++ /dev/null @@ -1,169 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return TetherClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new TetherClient($options); - } - - /** @test */ - public function egressTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $id = 'id3355'; - $project = 'project-309310695'; - $traceId = 'traceId1270300245'; - $expectedResponse = new EgressRequest(); - $expectedResponse->setId($id); - $expectedResponse->setProject($project); - $expectedResponse->setTraceId($traceId); - $transport->addResponse($expectedResponse); - $id2 = 'id23227150'; - $project2 = 'project2-894831476'; - $traceId2 = 'traceId2987826376'; - $expectedResponse2 = new EgressRequest(); - $expectedResponse2->setId($id2); - $expectedResponse2->setProject($project2); - $expectedResponse2->setTraceId($traceId2); - $transport->addResponse($expectedResponse2); - $id3 = 'id33227151'; - $project3 = 'project3-894831475'; - $traceId3 = 'traceId3987826377'; - $expectedResponse3 = new EgressRequest(); - $expectedResponse3->setId($id3); - $expectedResponse3->setProject($project3); - $expectedResponse3->setTraceId($traceId3); - $transport->addResponse($expectedResponse3); - // Mock request - $request = new EgressResponse(); - $request2 = new EgressResponse(); - $request3 = new EgressResponse(); - $bidi = $gapicClient->egress(); - $this->assertInstanceOf(BidiStream::class, $bidi); - $bidi->write($request); - $responses = []; - $responses[] = $bidi->read(); - $bidi->writeAll([ - $request2, - $request3, - ]); - foreach ($bidi->closeWriteAndReadAll() as $response) { - $responses[] = $response; - } - - $expectedResponses = []; - $expectedResponses[] = $expectedResponse; - $expectedResponses[] = $expectedResponse2; - $expectedResponses[] = $expectedResponse3; - $this->assertEquals($expectedResponses, $responses); - $createStreamRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($createStreamRequests)); - $streamFuncCall = $createStreamRequests[0]->getFuncCall(); - $streamRequestObject = $createStreamRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.apigeeconnect.v1.Tether/Egress', $streamFuncCall); - $this->assertNull($streamRequestObject); - $callObjects = $transport->popCallObjects(); - $this->assertSame(1, count($callObjects)); - $bidiCall = $callObjects[0]; - $writeRequests = $bidiCall->popReceivedCalls(); - $expectedRequests = []; - $expectedRequests[] = $request; - $expectedRequests[] = $request2; - $expectedRequests[] = $request3; - $this->assertEquals($expectedRequests, $writeRequests); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function egressExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->setStreamingStatus($status); - $this->assertTrue($transport->isExhausted()); - $bidi = $gapicClient->egress(); - $results = $bidi->closeWriteAndReadAll(); - try { - iterator_to_array($results); - // If the close stream method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/BigQueryReservation/.OwlBot.yaml b/BigQueryReservation/.OwlBot.yaml index 09d5f5fac89e..bea98771ffdc 100644 --- a/BigQueryReservation/.OwlBot.yaml +++ b/BigQueryReservation/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/bigquery/reservation/v1/.*-php/(.*) - dest: /owl-bot-staging/BigQueryReservation/v1/$1 + - source: /google/cloud/bigquery/reservation/(v1)/.*-php/(.*) + dest: /owl-bot-staging/BigQueryReservation/$1/$2 api-name: BigQueryReservation diff --git a/BigQueryReservation/owlbot.py b/BigQueryReservation/owlbot.py index 0289cc2a59e4..ccc80f6830c5 100644 --- a/BigQueryReservation/owlbot.py +++ b/BigQueryReservation/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2020 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,51 +41,6 @@ + "\n", '') - -# prevent null reference error when descriptor uses optional field. -s.replace( - "**/Gapic/*GapicClient.php", - r"\$requestParams = new RequestParamsHeaderDescriptor\(\[\n\s{0,}'(\S{0,})\' => ((\$request->\S{0,}\(\))->\S{0,}\(\)),\n\s{0,}\]\)\;", - r"""$requestParams = new RequestParamsHeaderDescriptor([]); - if (!is_null(\3)) { - $requestParams = new RequestParamsHeaderDescriptor([ - '\1' => \2, - ]); - }""" -) - -# fix test group -s.replace( - 'tests/**/V1/*Test.php', - r'@group reservation', - '@group bigqueryreservation') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - # format generated clients subprocess.run([ 'npm', @@ -101,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/BigQueryReservation/src/V1/Assignment.php b/BigQueryReservation/src/V1/Assignment.php index 56cb1e885f41..041fc0363a57 100644 --- a/BigQueryReservation/src/V1/Assignment.php +++ b/BigQueryReservation/src/V1/Assignment.php @@ -24,26 +24,26 @@ class Assignment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * The resource which will use the reservation. E.g. * `projects/myproject`, `folders/123`, or `organizations/456`. * * Generated from protobuf field string assignee = 4; */ - private $assignee = ''; + protected $assignee = ''; /** * Which type of jobs will use the reservation. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Assignment.JobType job_type = 3; */ - private $job_type = 0; + protected $job_type = 0; /** * Output only. State of the assignment. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Assignment.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Constructor. diff --git a/BigQueryReservation/src/V1/BiReservation.php b/BigQueryReservation/src/V1/BiReservation.php index dfd77015db0d..65b19149239a 100644 --- a/BigQueryReservation/src/V1/BiReservation.php +++ b/BigQueryReservation/src/V1/BiReservation.php @@ -22,19 +22,19 @@ class BiReservation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. The last update timestamp of a reservation. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Size of a reservation, in bytes. * * Generated from protobuf field int64 size = 4; */ - private $size = 0; + protected $size = 0; /** * Preferred tables to use BI capacity for. * diff --git a/BigQueryReservation/src/V1/CapacityCommitment.php b/BigQueryReservation/src/V1/CapacityCommitment.php index 6190a9310266..7ff9f6aaaa0e 100644 --- a/BigQueryReservation/src/V1/CapacityCommitment.php +++ b/BigQueryReservation/src/V1/CapacityCommitment.php @@ -31,45 +31,45 @@ class CapacityCommitment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Number of slots in this commitment. * * Generated from protobuf field int64 slot_count = 2; */ - private $slot_count = 0; + protected $slot_count = 0; /** * Capacity commitment commitment plan. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.CapacityCommitment.CommitmentPlan plan = 3; */ - private $plan = 0; + protected $plan = 0; /** * Output only. State of the commitment. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.CapacityCommitment.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The start of the current commitment period. It is applicable * only for ACTIVE capacity commitments. * * Generated from protobuf field .google.protobuf.Timestamp commitment_start_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $commitment_start_time = null; + protected $commitment_start_time = null; /** * Output only. The end of the current commitment period. It is applicable * only for ACTIVE capacity commitments. * * Generated from protobuf field .google.protobuf.Timestamp commitment_end_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $commitment_end_time = null; + protected $commitment_end_time = null; /** * Output only. For FAILED commitment plan, provides the reason of failure. * * Generated from protobuf field .google.rpc.Status failure_status = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $failure_status = null; + protected $failure_status = null; /** * The plan this capacity commitment is converted to after commitment_end_time * passes. Once the plan is changed, committed period is extended according to @@ -77,7 +77,7 @@ class CapacityCommitment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.CapacityCommitment.CommitmentPlan renewal_plan = 8; */ - private $renewal_plan = 0; + protected $renewal_plan = 0; /** * Applicable only for commitments located within one of the BigQuery * multi-regions (US or EU). @@ -89,13 +89,13 @@ class CapacityCommitment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool multi_region_auxiliary = 10; */ - private $multi_region_auxiliary = false; + protected $multi_region_auxiliary = false; /** * Edition of the capacity commitment. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Edition edition = 12; */ - private $edition = 0; + protected $edition = 0; /** * Constructor. diff --git a/BigQueryReservation/src/V1/Client/ReservationServiceClient.php b/BigQueryReservation/src/V1/Client/ReservationServiceClient.php index b31f3e5869ab..253e18dcf340 100644 --- a/BigQueryReservation/src/V1/Client/ReservationServiceClient.php +++ b/BigQueryReservation/src/V1/Client/ReservationServiceClient.php @@ -1,6 +1,6 @@ render([ 'project' => $project, 'location' => $location, @@ -431,8 +435,10 @@ public function createAssignment(CreateAssignmentRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function createCapacityCommitment(CreateCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment - { + public function createCapacityCommitment( + CreateCapacityCommitmentRequest $request, + array $callOptions = [] + ): CapacityCommitment { return $this->startApiCall('CreateCapacityCommitment', $request, $callOptions)->wait(); } @@ -601,8 +607,10 @@ public function getBiReservation(GetBiReservationRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function getCapacityCommitment(GetCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment - { + public function getCapacityCommitment( + GetCapacityCommitmentRequest $request, + array $callOptions = [] + ): CapacityCommitment { return $this->startApiCall('GetCapacityCommitment', $request, $callOptions)->wait(); } @@ -700,8 +708,10 @@ public function listAssignments(ListAssignmentsRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function listCapacityCommitments(ListCapacityCommitmentsRequest $request, array $callOptions = []): PagedListResponse - { + public function listCapacityCommitments( + ListCapacityCommitmentsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListCapacityCommitments', $request, $callOptions); } @@ -759,8 +769,10 @@ public function listReservations(ListReservationsRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function mergeCapacityCommitments(MergeCapacityCommitmentsRequest $request, array $callOptions = []): CapacityCommitment - { + public function mergeCapacityCommitments( + MergeCapacityCommitmentsRequest $request, + array $callOptions = [] + ): CapacityCommitment { return $this->startApiCall('MergeCapacityCommitments', $request, $callOptions)->wait(); } @@ -835,8 +847,10 @@ public function moveAssignment(MoveAssignmentRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function searchAllAssignments(SearchAllAssignmentsRequest $request, array $callOptions = []): PagedListResponse - { + public function searchAllAssignments( + SearchAllAssignmentsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('SearchAllAssignments', $request, $callOptions); } @@ -919,8 +933,10 @@ public function searchAssignments(SearchAssignmentsRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function splitCapacityCommitment(SplitCapacityCommitmentRequest $request, array $callOptions = []): SplitCapacityCommitmentResponse - { + public function splitCapacityCommitment( + SplitCapacityCommitmentRequest $request, + array $callOptions = [] + ): SplitCapacityCommitmentResponse { return $this->startApiCall('SplitCapacityCommitment', $request, $callOptions)->wait(); } @@ -1014,8 +1030,10 @@ public function updateBiReservation(UpdateBiReservationRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function updateCapacityCommitment(UpdateCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment - { + public function updateCapacityCommitment( + UpdateCapacityCommitmentRequest $request, + array $callOptions = [] + ): CapacityCommitment { return $this->startApiCall('UpdateCapacityCommitment', $request, $callOptions)->wait(); } diff --git a/BigQueryReservation/src/V1/CreateAssignmentRequest.php b/BigQueryReservation/src/V1/CreateAssignmentRequest.php index 8ca0415af788..3dbab04fdca5 100644 --- a/BigQueryReservation/src/V1/CreateAssignmentRequest.php +++ b/BigQueryReservation/src/V1/CreateAssignmentRequest.php @@ -24,13 +24,13 @@ class CreateAssignmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Assignment resource to create. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Assignment assignment = 2; */ - private $assignment = null; + protected $assignment = null; /** * The optional assignment ID. Assignment name will be generated automatically * if this field is empty. @@ -39,7 +39,7 @@ class CreateAssignmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string assignment_id = 4; */ - private $assignment_id = ''; + protected $assignment_id = ''; /** * @param string $parent Required. The parent resource name of the assignment diff --git a/BigQueryReservation/src/V1/CreateCapacityCommitmentRequest.php b/BigQueryReservation/src/V1/CreateCapacityCommitmentRequest.php index b9fe4a6736c5..9329e35d14d5 100644 --- a/BigQueryReservation/src/V1/CreateCapacityCommitmentRequest.php +++ b/BigQueryReservation/src/V1/CreateCapacityCommitmentRequest.php @@ -22,20 +22,20 @@ class CreateCapacityCommitmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Content of the capacity commitment to create. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.CapacityCommitment capacity_commitment = 2; */ - private $capacity_commitment = null; + protected $capacity_commitment = null; /** * If true, fail the request if another project in the organization has a * capacity commitment. * * Generated from protobuf field bool enforce_single_admin_project_per_org = 4; */ - private $enforce_single_admin_project_per_org = false; + protected $enforce_single_admin_project_per_org = false; /** * The optional capacity commitment ID. Capacity commitment name will be * generated automatically if this field is empty. @@ -45,7 +45,7 @@ class CreateCapacityCommitmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string capacity_commitment_id = 5; */ - private $capacity_commitment_id = ''; + protected $capacity_commitment_id = ''; /** * @param string $parent Required. Resource name of the parent reservation. E.g., diff --git a/BigQueryReservation/src/V1/CreateReservationRequest.php b/BigQueryReservation/src/V1/CreateReservationRequest.php index 0de79790b5e9..ade4f1d52ee1 100644 --- a/BigQueryReservation/src/V1/CreateReservationRequest.php +++ b/BigQueryReservation/src/V1/CreateReservationRequest.php @@ -22,7 +22,7 @@ class CreateReservationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The reservation ID. It must only contain lower case alphanumeric * characters or dashes. It must start with a letter and must not end @@ -30,13 +30,13 @@ class CreateReservationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string reservation_id = 2; */ - private $reservation_id = ''; + protected $reservation_id = ''; /** * Definition of the new reservation to create. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Reservation reservation = 3; */ - private $reservation = null; + protected $reservation = null; /** * @param string $parent Required. Project, location. E.g., diff --git a/BigQueryReservation/src/V1/DeleteAssignmentRequest.php b/BigQueryReservation/src/V1/DeleteAssignmentRequest.php index a7a03fdfced8..3f39a0587e8e 100644 --- a/BigQueryReservation/src/V1/DeleteAssignmentRequest.php +++ b/BigQueryReservation/src/V1/DeleteAssignmentRequest.php @@ -24,7 +24,7 @@ class DeleteAssignmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the resource, e.g. diff --git a/BigQueryReservation/src/V1/DeleteCapacityCommitmentRequest.php b/BigQueryReservation/src/V1/DeleteCapacityCommitmentRequest.php index f0379ca216bd..dc012790ec91 100644 --- a/BigQueryReservation/src/V1/DeleteCapacityCommitmentRequest.php +++ b/BigQueryReservation/src/V1/DeleteCapacityCommitmentRequest.php @@ -22,7 +22,7 @@ class DeleteCapacityCommitmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Can be used to force delete commitments even if assignments exist. Deleting * commitments with assignments may cause queries to fail if they no longer @@ -30,7 +30,7 @@ class DeleteCapacityCommitmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool force = 3; */ - private $force = false; + protected $force = false; /** * @param string $name Required. Resource name of the capacity commitment to delete. E.g., diff --git a/BigQueryReservation/src/V1/DeleteReservationRequest.php b/BigQueryReservation/src/V1/DeleteReservationRequest.php index e980042b9d04..745b2051ee75 100644 --- a/BigQueryReservation/src/V1/DeleteReservationRequest.php +++ b/BigQueryReservation/src/V1/DeleteReservationRequest.php @@ -22,7 +22,7 @@ class DeleteReservationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Resource name of the reservation to retrieve. E.g., diff --git a/BigQueryReservation/src/V1/Gapic/ReservationServiceGapicClient.php b/BigQueryReservation/src/V1/Gapic/ReservationServiceGapicClient.php deleted file mode 100644 index 795ff69c2e3b..000000000000 --- a/BigQueryReservation/src/V1/Gapic/ReservationServiceGapicClient.php +++ /dev/null @@ -1,1934 +0,0 @@ -reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - * $response = $reservationServiceClient->createAssignment($formattedParent); - * } finally { - * $reservationServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\BigQuery\Reservation\V1\Client\ReservationServiceClient}. - */ -class ReservationServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.bigquery.reservation.v1.ReservationService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'bigqueryreservation.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'bigqueryreservation.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/bigquery', - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $assignmentNameTemplate; - - private static $biReservationNameTemplate; - - private static $capacityCommitmentNameTemplate; - - private static $locationNameTemplate; - - private static $reservationNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getAssignmentNameTemplate() - { - if (self::$assignmentNameTemplate == null) { - self::$assignmentNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/reservations/{reservation}/assignments/{assignment}' - ); - } - - return self::$assignmentNameTemplate; - } - - private static function getBiReservationNameTemplate() - { - if (self::$biReservationNameTemplate == null) { - self::$biReservationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/biReservation' - ); - } - - return self::$biReservationNameTemplate; - } - - private static function getCapacityCommitmentNameTemplate() - { - if (self::$capacityCommitmentNameTemplate == null) { - self::$capacityCommitmentNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment}' - ); - } - - return self::$capacityCommitmentNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getReservationNameTemplate() - { - if (self::$reservationNameTemplate == null) { - self::$reservationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/reservations/{reservation}' - ); - } - - return self::$reservationNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'assignment' => self::getAssignmentNameTemplate(), - 'biReservation' => self::getBiReservationNameTemplate(), - 'capacityCommitment' => self::getCapacityCommitmentNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'reservation' => self::getReservationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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( - $project, - $location, - $reservation, - $assignment - ) { - return self::getAssignmentNameTemplate()->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($project, $location) - { - return self::getBiReservationNameTemplate()->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( - $project, - $location, - $capacityCommitment - ) { - return self::getCapacityCommitmentNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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($project, $location, $reservation) - { - return self::getReservationNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * 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. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedParent = $reservationServiceClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - * $response = $reservationServiceClient->createAssignment($formattedParent); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource name of the assignment - * E.g. `projects/myproject/locations/US/reservations/team1-prod` - * @param array $optionalArgs { - * Optional. - * - * @type Assignment $assignment - * Assignment resource to create. - * @type string $assignmentId - * The optional assignment ID. Assignment name will be generated automatically - * if this field is empty. - * This field must only contain lower case alphanumeric characters or dashes. - * Max length is 64 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\BigQuery\Reservation\V1\Assignment - * - * @throws ApiException if the remote call fails - */ - public function createAssignment($parent, array $optionalArgs = []) - { - $request = new CreateAssignmentRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['assignment'])) { - $request->setAssignment($optionalArgs['assignment']); - } - - if (isset($optionalArgs['assignmentId'])) { - $request->setAssignmentId($optionalArgs['assignmentId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateAssignment', - Assignment::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Creates a new capacity commitment resource. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedParent = $reservationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $response = $reservationServiceClient->createCapacityCommitment($formattedParent); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Resource name of the parent reservation. E.g., - * `projects/myproject/locations/US` - * @param array $optionalArgs { - * Optional. - * - * @type CapacityCommitment $capacityCommitment - * Content of the capacity commitment to create. - * @type bool $enforceSingleAdminProjectPerOrg - * If true, fail the request if another project in the organization has a - * capacity commitment. - * @type string $capacityCommitmentId - * The optional capacity commitment ID. Capacity commitment name will be - * generated automatically if this field is empty. - * This field must only contain lower case alphanumeric characters or dashes. - * The first and last character cannot be a dash. Max length is 64 characters. - * NOTE: this ID won't be kept if the capacity commitment is split or merged. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\BigQuery\Reservation\V1\CapacityCommitment - * - * @throws ApiException if the remote call fails - */ - public function createCapacityCommitment($parent, array $optionalArgs = []) - { - $request = new CreateCapacityCommitmentRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['capacityCommitment'])) { - $request->setCapacityCommitment( - $optionalArgs['capacityCommitment'] - ); - } - - if (isset($optionalArgs['enforceSingleAdminProjectPerOrg'])) { - $request->setEnforceSingleAdminProjectPerOrg( - $optionalArgs['enforceSingleAdminProjectPerOrg'] - ); - } - - if (isset($optionalArgs['capacityCommitmentId'])) { - $request->setCapacityCommitmentId( - $optionalArgs['capacityCommitmentId'] - ); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateCapacityCommitment', - CapacityCommitment::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Creates a new reservation resource. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedParent = $reservationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $response = $reservationServiceClient->createReservation($formattedParent); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Project, location. E.g., - * `projects/myproject/locations/US` - * @param array $optionalArgs { - * Optional. - * - * @type string $reservationId - * The reservation ID. It must only contain lower case alphanumeric - * characters or dashes. It must start with a letter and must not end - * with a dash. Its maximum length is 64 characters. - * @type Reservation $reservation - * Definition of the new reservation to create. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\BigQuery\Reservation\V1\Reservation - * - * @throws ApiException if the remote call fails - */ - public function createReservation($parent, array $optionalArgs = []) - { - $request = new CreateReservationRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['reservationId'])) { - $request->setReservationId($optionalArgs['reservationId']); - } - - if (isset($optionalArgs['reservation'])) { - $request->setReservation($optionalArgs['reservation']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateReservation', - Reservation::class, - $optionalArgs, - $request - )->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. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedName = $reservationServiceClient->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - * $reservationServiceClient->deleteAssignment($formattedName); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the resource, e.g. - * `projects/myproject/locations/US/reservations/team1-prod/assignments/123` - * @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 deleteAssignment($name, array $optionalArgs = []) - { - $request = new DeleteAssignmentRequest(); - $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( - 'DeleteAssignment', - GPBEmpty::class, - $optionalArgs, - $request - )->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`. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedName = $reservationServiceClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - * $reservationServiceClient->deleteCapacityCommitment($formattedName); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the capacity commitment to delete. E.g., - * `projects/myproject/locations/US/capacityCommitments/123` - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * Can be used to force delete commitments even if assignments exist. Deleting - * commitments with assignments may cause queries to fail if they no longer - * have access to slots. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 deleteCapacityCommitment($name, array $optionalArgs = []) - { - $request = new DeleteCapacityCommitmentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'DeleteCapacityCommitment', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a reservation. - * Returns `google.rpc.Code.FAILED_PRECONDITION` when reservation has - * assignments. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedName = $reservationServiceClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - * $reservationServiceClient->deleteReservation($formattedName); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the reservation to retrieve. E.g., - * `projects/myproject/locations/US/reservations/team1-prod` - * @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 deleteReservation($name, array $optionalArgs = []) - { - $request = new DeleteReservationRequest(); - $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( - 'DeleteReservation', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Retrieves a BI reservation. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedName = $reservationServiceClient->biReservationName('[PROJECT]', '[LOCATION]'); - * $response = $reservationServiceClient->getBiReservation($formattedName); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the requested reservation, for example: - * `projects/{project_id}/locations/{location_id}/biReservation` - * @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\BigQuery\Reservation\V1\BiReservation - * - * @throws ApiException if the remote call fails - */ - public function getBiReservation($name, array $optionalArgs = []) - { - $request = new GetBiReservationRequest(); - $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( - 'GetBiReservation', - BiReservation::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Returns information about the capacity commitment. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedName = $reservationServiceClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - * $response = $reservationServiceClient->getCapacityCommitment($formattedName); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the capacity commitment to retrieve. E.g., - * `projects/myproject/locations/US/capacityCommitments/123` - * @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\BigQuery\Reservation\V1\CapacityCommitment - * - * @throws ApiException if the remote call fails - */ - public function getCapacityCommitment($name, array $optionalArgs = []) - { - $request = new GetCapacityCommitmentRequest(); - $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( - 'GetCapacityCommitment', - CapacityCommitment::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Returns information about the reservation. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedName = $reservationServiceClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - * $response = $reservationServiceClient->getReservation($formattedName); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the reservation to retrieve. E.g., - * `projects/myproject/locations/US/reservations/team1-prod` - * @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\BigQuery\Reservation\V1\Reservation - * - * @throws ApiException if the remote call fails - */ - public function getReservation($name, array $optionalArgs = []) - { - $request = new GetReservationRequest(); - $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( - 'GetReservation', - Reservation::class, - $optionalArgs, - $request - )->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. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedParent = $reservationServiceClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - * // Iterate over pages of elements - * $pagedResponse = $reservationServiceClient->listAssignments($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $reservationServiceClient->listAssignments($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource name e.g.: - * - * `projects/myproject/locations/US/reservations/team1-prod` - * - * Or: - * - * `projects/myproject/locations/US/reservations/-` - * @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 listAssignments($parent, array $optionalArgs = []) - { - $request = new ListAssignmentsRequest(); - $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( - 'ListAssignments', - $optionalArgs, - ListAssignmentsResponse::class, - $request - ); - } - - /** - * Lists all the capacity commitments for the admin project. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedParent = $reservationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $reservationServiceClient->listCapacityCommitments($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $reservationServiceClient->listCapacityCommitments($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Resource name of the parent reservation. E.g., - * `projects/myproject/locations/US` - * @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 listCapacityCommitments($parent, array $optionalArgs = []) - { - $request = new ListCapacityCommitmentsRequest(); - $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( - 'ListCapacityCommitments', - $optionalArgs, - ListCapacityCommitmentsResponse::class, - $request - ); - } - - /** - * Lists all the reservations for the project in the specified location. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedParent = $reservationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $reservationServiceClient->listReservations($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $reservationServiceClient->listReservations($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource name containing project and location, e.g.: - * `projects/myproject/locations/US` - * @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 listReservations($parent, array $optionalArgs = []) - { - $request = new ListReservationsRequest(); - $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( - 'ListReservations', - $optionalArgs, - ListReservationsResponse::class, - $request - ); - } - - /** - * 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`. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $response = $reservationServiceClient->mergeCapacityCommitments(); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * Parent resource that identifies admin project and location e.g., - * `projects/myproject/locations/us` - * @type string[] $capacityCommitmentIds - * Ids of capacity commitments to merge. - * These capacity commitments must exist under admin project and location - * specified in the parent. - * ID is the last portion of capacity commitment name e.g., 'abc' for - * projects/myproject/locations/US/capacityCommitments/abc - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\BigQuery\Reservation\V1\CapacityCommitment - * - * @throws ApiException if the remote call fails - */ - public function mergeCapacityCommitments(array $optionalArgs = []) - { - $request = new MergeCapacityCommitmentsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['parent']; - } - - if (isset($optionalArgs['capacityCommitmentIds'])) { - $request->setCapacityCommitmentIds( - $optionalArgs['capacityCommitmentIds'] - ); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'MergeCapacityCommitments', - CapacityCommitment::class, - $optionalArgs, - $request - )->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. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedName = $reservationServiceClient->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - * $response = $reservationServiceClient->moveAssignment($formattedName); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the assignment, - * e.g. - * `projects/myproject/locations/US/reservations/team1-prod/assignments/123` - * @param array $optionalArgs { - * Optional. - * - * @type string $destinationId - * The new reservation ID, e.g.: - * `projects/myotherproject/locations/US/reservations/team2-prod` - * @type string $assignmentId - * The optional assignment ID. A new assignment name is generated if this - * field is empty. - * - * This field can contain only lowercase alphanumeric characters or dashes. - * Max length is 64 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\BigQuery\Reservation\V1\Assignment - * - * @throws ApiException if the remote call fails - */ - public function moveAssignment($name, array $optionalArgs = []) - { - $request = new MoveAssignmentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['destinationId'])) { - $request->setDestinationId($optionalArgs['destinationId']); - } - - if (isset($optionalArgs['assignmentId'])) { - $request->setAssignmentId($optionalArgs['assignmentId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'MoveAssignment', - Assignment::class, - $optionalArgs, - $request - )->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/*`. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedParent = $reservationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $reservationServiceClient->searchAllAssignments($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $reservationServiceClient->searchAllAssignments($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource name with location (project name could be the - * wildcard '-'), e.g.: - * `projects/-/locations/US`. - * @param array $optionalArgs { - * Optional. - * - * @type string $query - * Please specify resource name as assignee in the query. - * - * Examples: - * - * * `assignee=projects/myproject` - * * `assignee=folders/123` - * * `assignee=organizations/456` - * @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 searchAllAssignments($parent, array $optionalArgs = []) - { - $request = new SearchAllAssignmentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['query'])) { - $request->setQuery($optionalArgs['query']); - } - - 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( - 'SearchAllAssignments', - $optionalArgs, - SearchAllAssignmentsResponse::class, - $request - ); - } - - /** - * 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. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedParent = $reservationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $reservationServiceClient->searchAssignments($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $reservationServiceClient->searchAssignments($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource name of the admin project(containing project and - * location), e.g.: - * `projects/myproject/locations/US`. - * @param array $optionalArgs { - * Optional. - * - * @type string $query - * Please specify resource name as assignee in the query. - * - * Examples: - * - * * `assignee=projects/myproject` - * * `assignee=folders/123` - * * `assignee=organizations/456` - * @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 - * - * @deprecated This method will be removed in the next major version update. - */ - public function searchAssignments($parent, array $optionalArgs = []) - { - $request = new SearchAssignmentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['query'])) { - $request->setQuery($optionalArgs['query']); - } - - 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( - 'SearchAssignments', - $optionalArgs, - SearchAssignmentsResponse::class, - $request - ); - } - - /** - * 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. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $formattedName = $reservationServiceClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - * $response = $reservationServiceClient->splitCapacityCommitment($formattedName); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name e.g.,: - * `projects/myproject/locations/US/capacityCommitments/123` - * @param array $optionalArgs { - * Optional. - * - * @type int $slotCount - * Number of slots in the capacity commitment after the split. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\BigQuery\Reservation\V1\SplitCapacityCommitmentResponse - * - * @throws ApiException if the remote call fails - */ - public function splitCapacityCommitment($name, array $optionalArgs = []) - { - $request = new SplitCapacityCommitmentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['slotCount'])) { - $request->setSlotCount($optionalArgs['slotCount']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'SplitCapacityCommitment', - SplitCapacityCommitmentResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates an existing assignment. - * - * Only the `priority` field can be updated. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $response = $reservationServiceClient->updateAssignment(); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type Assignment $assignment - * Content of the assignment to update. - * @type FieldMask $updateMask - * Standard field mask for the set of fields to 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\BigQuery\Reservation\V1\Assignment - * - * @throws ApiException if the remote call fails - */ - public function updateAssignment(array $optionalArgs = []) - { - $request = new UpdateAssignmentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['assignment'])) { - $request->setAssignment($optionalArgs['assignment']); - } - - 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( - 'UpdateAssignment', - Assignment::class, - $optionalArgs, - $request - )->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. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $response = $reservationServiceClient->updateBiReservation(); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type BiReservation $biReservation - * A reservation to update. - * @type FieldMask $updateMask - * A list of fields to be updated in this request. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\BigQuery\Reservation\V1\BiReservation - * - * @throws ApiException if the remote call fails - */ - public function updateBiReservation(array $optionalArgs = []) - { - $request = new UpdateBiReservationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['biReservation'])) { - $request->setBiReservation($optionalArgs['biReservation']); - } - - 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( - 'UpdateBiReservation', - BiReservation::class, - $optionalArgs, - $request - )->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`. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $response = $reservationServiceClient->updateCapacityCommitment(); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type CapacityCommitment $capacityCommitment - * Content of the capacity commitment to update. - * @type FieldMask $updateMask - * Standard field mask for the set of fields to 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\BigQuery\Reservation\V1\CapacityCommitment - * - * @throws ApiException if the remote call fails - */ - public function updateCapacityCommitment(array $optionalArgs = []) - { - $request = new UpdateCapacityCommitmentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['capacityCommitment'])) { - $request->setCapacityCommitment( - $optionalArgs['capacityCommitment'] - ); - } - - 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( - 'UpdateCapacityCommitment', - CapacityCommitment::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates an existing reservation resource. - * - * Sample code: - * ``` - * $reservationServiceClient = new ReservationServiceClient(); - * try { - * $response = $reservationServiceClient->updateReservation(); - * } finally { - * $reservationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type Reservation $reservation - * Content of the reservation to update. - * @type FieldMask $updateMask - * Standard field mask for the set of fields to 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\BigQuery\Reservation\V1\Reservation - * - * @throws ApiException if the remote call fails - */ - public function updateReservation(array $optionalArgs = []) - { - $request = new UpdateReservationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['reservation'])) { - $request->setReservation($optionalArgs['reservation']); - } - - 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( - 'UpdateReservation', - Reservation::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/BigQueryReservation/src/V1/GetBiReservationRequest.php b/BigQueryReservation/src/V1/GetBiReservationRequest.php index 897e3c86e905..2c7408d233fc 100644 --- a/BigQueryReservation/src/V1/GetBiReservationRequest.php +++ b/BigQueryReservation/src/V1/GetBiReservationRequest.php @@ -21,7 +21,7 @@ class GetBiReservationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the requested reservation, for example: diff --git a/BigQueryReservation/src/V1/GetCapacityCommitmentRequest.php b/BigQueryReservation/src/V1/GetCapacityCommitmentRequest.php index 83f86857efdf..785336d7ba0b 100644 --- a/BigQueryReservation/src/V1/GetCapacityCommitmentRequest.php +++ b/BigQueryReservation/src/V1/GetCapacityCommitmentRequest.php @@ -22,7 +22,7 @@ class GetCapacityCommitmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Resource name of the capacity commitment to retrieve. E.g., diff --git a/BigQueryReservation/src/V1/GetReservationRequest.php b/BigQueryReservation/src/V1/GetReservationRequest.php index 6fe64ac4b572..0b048b21d39d 100644 --- a/BigQueryReservation/src/V1/GetReservationRequest.php +++ b/BigQueryReservation/src/V1/GetReservationRequest.php @@ -22,7 +22,7 @@ class GetReservationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Resource name of the reservation to retrieve. E.g., diff --git a/BigQueryReservation/src/V1/ListAssignmentsRequest.php b/BigQueryReservation/src/V1/ListAssignmentsRequest.php index b9851bc7c364..821a46e9140e 100644 --- a/BigQueryReservation/src/V1/ListAssignmentsRequest.php +++ b/BigQueryReservation/src/V1/ListAssignmentsRequest.php @@ -24,19 +24,19 @@ class ListAssignmentsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return per page. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value returned from a previous List request, if any. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The parent resource name e.g.: diff --git a/BigQueryReservation/src/V1/ListAssignmentsResponse.php b/BigQueryReservation/src/V1/ListAssignmentsResponse.php index e6bf21c96a3c..86846c01f893 100644 --- a/BigQueryReservation/src/V1/ListAssignmentsResponse.php +++ b/BigQueryReservation/src/V1/ListAssignmentsResponse.php @@ -28,7 +28,7 @@ class ListAssignmentsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/BigQueryReservation/src/V1/ListCapacityCommitmentsRequest.php b/BigQueryReservation/src/V1/ListCapacityCommitmentsRequest.php index 916380614b40..74d24a845b98 100644 --- a/BigQueryReservation/src/V1/ListCapacityCommitmentsRequest.php +++ b/BigQueryReservation/src/V1/ListCapacityCommitmentsRequest.php @@ -22,19 +22,19 @@ class ListCapacityCommitmentsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value returned from a previous List request, if any. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Resource name of the parent reservation. E.g., diff --git a/BigQueryReservation/src/V1/ListCapacityCommitmentsResponse.php b/BigQueryReservation/src/V1/ListCapacityCommitmentsResponse.php index bf710e12d8d9..3775a9f7af41 100644 --- a/BigQueryReservation/src/V1/ListCapacityCommitmentsResponse.php +++ b/BigQueryReservation/src/V1/ListCapacityCommitmentsResponse.php @@ -28,7 +28,7 @@ class ListCapacityCommitmentsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/BigQueryReservation/src/V1/ListReservationsRequest.php b/BigQueryReservation/src/V1/ListReservationsRequest.php index c927a3345c20..a7badf9061a2 100644 --- a/BigQueryReservation/src/V1/ListReservationsRequest.php +++ b/BigQueryReservation/src/V1/ListReservationsRequest.php @@ -22,19 +22,19 @@ class ListReservationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return per page. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value returned from a previous List request, if any. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The parent resource name containing project and location, e.g.: diff --git a/BigQueryReservation/src/V1/ListReservationsResponse.php b/BigQueryReservation/src/V1/ListReservationsResponse.php index 33a9e76cf14e..01a522f87675 100644 --- a/BigQueryReservation/src/V1/ListReservationsResponse.php +++ b/BigQueryReservation/src/V1/ListReservationsResponse.php @@ -28,7 +28,7 @@ class ListReservationsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/BigQueryReservation/src/V1/MergeCapacityCommitmentsRequest.php b/BigQueryReservation/src/V1/MergeCapacityCommitmentsRequest.php index 548c2396bffe..4cba4685918d 100644 --- a/BigQueryReservation/src/V1/MergeCapacityCommitmentsRequest.php +++ b/BigQueryReservation/src/V1/MergeCapacityCommitmentsRequest.php @@ -22,7 +22,7 @@ class MergeCapacityCommitmentsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Ids of capacity commitments to merge. * These capacity commitments must exist under admin project and location diff --git a/BigQueryReservation/src/V1/MoveAssignmentRequest.php b/BigQueryReservation/src/V1/MoveAssignmentRequest.php index 658e26c0ac36..9c82141891e1 100644 --- a/BigQueryReservation/src/V1/MoveAssignmentRequest.php +++ b/BigQueryReservation/src/V1/MoveAssignmentRequest.php @@ -28,14 +28,14 @@ class MoveAssignmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * The new reservation ID, e.g.: * `projects/myotherproject/locations/US/reservations/team2-prod` * * Generated from protobuf field string destination_id = 3 [(.google.api.resource_reference) = { */ - private $destination_id = ''; + protected $destination_id = ''; /** * The optional assignment ID. A new assignment name is generated if this * field is empty. @@ -44,7 +44,7 @@ class MoveAssignmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string assignment_id = 5; */ - private $assignment_id = ''; + protected $assignment_id = ''; /** * @param string $name Required. The resource name of the assignment, diff --git a/BigQueryReservation/src/V1/Reservation.php b/BigQueryReservation/src/V1/Reservation.php index 718139a8603a..9c806e7cf943 100644 --- a/BigQueryReservation/src/V1/Reservation.php +++ b/BigQueryReservation/src/V1/Reservation.php @@ -24,7 +24,7 @@ class Reservation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Minimum slots available to this reservation. A slot is a unit of * computational power in BigQuery, and serves as the unit of parallelism. @@ -39,7 +39,7 @@ class Reservation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 slot_capacity = 2; */ - private $slot_capacity = 0; + protected $slot_capacity = 0; /** * If false, any query or pipeline job using this reservation will use idle * slots from other reservations within the same admin project. If true, a @@ -48,14 +48,14 @@ class Reservation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool ignore_idle_slots = 4; */ - private $ignore_idle_slots = false; + protected $ignore_idle_slots = false; /** * The configuration parameters for the auto scaling feature. Note this is an * alpha feature. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Reservation.Autoscale autoscale = 7; */ - private $autoscale = null; + protected $autoscale = null; /** * Job concurrency target which sets a soft upper bound on the number of jobs * that can run concurrently in this reservation. This is a soft target due to @@ -68,19 +68,19 @@ class Reservation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 concurrency = 16; */ - private $concurrency = 0; + protected $concurrency = 0; /** * Output only. Creation time of the reservation. * * Generated from protobuf field .google.protobuf.Timestamp creation_time = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $creation_time = null; + protected $creation_time = null; /** * Output only. Last update time of the reservation. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Applicable only for reservations located within one of the BigQuery * multi-regions (US or EU). @@ -92,13 +92,13 @@ class Reservation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool multi_region_auxiliary = 14; */ - private $multi_region_auxiliary = false; + protected $multi_region_auxiliary = false; /** * Edition of the reservation. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Edition edition = 17; */ - private $edition = 0; + protected $edition = 0; /** * Constructor. diff --git a/BigQueryReservation/src/V1/Reservation/Autoscale.php b/BigQueryReservation/src/V1/Reservation/Autoscale.php index 38e93fc4152f..00575569a9fc 100644 --- a/BigQueryReservation/src/V1/Reservation/Autoscale.php +++ b/BigQueryReservation/src/V1/Reservation/Autoscale.php @@ -21,13 +21,13 @@ class Autoscale extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 current_slots = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $current_slots = 0; + protected $current_slots = 0; /** * Number of slots to be scaled when needed. * * Generated from protobuf field int64 max_slots = 2; */ - private $max_slots = 0; + protected $max_slots = 0; /** * Constructor. diff --git a/BigQueryReservation/src/V1/ReservationServiceClient.php b/BigQueryReservation/src/V1/ReservationServiceClient.php deleted file mode 100644 index 48b6b28133d1..000000000000 --- a/BigQueryReservation/src/V1/ReservationServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Please specify resource name as assignee in the query. * Examples: @@ -35,19 +35,19 @@ class SearchAllAssignmentsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string query = 2; */ - private $query = ''; + protected $query = ''; /** * The maximum number of items to return per page. * * Generated from protobuf field int32 page_size = 3; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value returned from a previous List request, if any. * * Generated from protobuf field string page_token = 4; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The resource name with location (project name could be the diff --git a/BigQueryReservation/src/V1/SearchAllAssignmentsResponse.php b/BigQueryReservation/src/V1/SearchAllAssignmentsResponse.php index 402000b45fab..1864b05872c0 100644 --- a/BigQueryReservation/src/V1/SearchAllAssignmentsResponse.php +++ b/BigQueryReservation/src/V1/SearchAllAssignmentsResponse.php @@ -28,7 +28,7 @@ class SearchAllAssignmentsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/BigQueryReservation/src/V1/SearchAssignmentsRequest.php b/BigQueryReservation/src/V1/SearchAssignmentsRequest.php index faf6a4797ff4..2965aef34365 100644 --- a/BigQueryReservation/src/V1/SearchAssignmentsRequest.php +++ b/BigQueryReservation/src/V1/SearchAssignmentsRequest.php @@ -25,7 +25,7 @@ class SearchAssignmentsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Please specify resource name as assignee in the query. * Examples: @@ -35,19 +35,19 @@ class SearchAssignmentsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string query = 2; */ - private $query = ''; + protected $query = ''; /** * The maximum number of items to return per page. * * Generated from protobuf field int32 page_size = 3; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value returned from a previous List request, if any. * * Generated from protobuf field string page_token = 4; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The resource name of the admin project(containing project and diff --git a/BigQueryReservation/src/V1/SearchAssignmentsResponse.php b/BigQueryReservation/src/V1/SearchAssignmentsResponse.php index 90f618a49e64..f7f802f7c0c8 100644 --- a/BigQueryReservation/src/V1/SearchAssignmentsResponse.php +++ b/BigQueryReservation/src/V1/SearchAssignmentsResponse.php @@ -28,7 +28,7 @@ class SearchAssignmentsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/BigQueryReservation/src/V1/SplitCapacityCommitmentRequest.php b/BigQueryReservation/src/V1/SplitCapacityCommitmentRequest.php index b205b3fb6948..ef7d9a88c90e 100644 --- a/BigQueryReservation/src/V1/SplitCapacityCommitmentRequest.php +++ b/BigQueryReservation/src/V1/SplitCapacityCommitmentRequest.php @@ -22,13 +22,13 @@ class SplitCapacityCommitmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Number of slots in the capacity commitment after the split. * * Generated from protobuf field int64 slot_count = 2; */ - private $slot_count = 0; + protected $slot_count = 0; /** * @param string $name Required. The resource name e.g.,: diff --git a/BigQueryReservation/src/V1/SplitCapacityCommitmentResponse.php b/BigQueryReservation/src/V1/SplitCapacityCommitmentResponse.php index 9327ce6f91b5..dfe6cb372ee1 100644 --- a/BigQueryReservation/src/V1/SplitCapacityCommitmentResponse.php +++ b/BigQueryReservation/src/V1/SplitCapacityCommitmentResponse.php @@ -21,13 +21,13 @@ class SplitCapacityCommitmentResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.CapacityCommitment first = 1; */ - private $first = null; + protected $first = null; /** * Second capacity commitment, result of a split. * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.CapacityCommitment second = 2; */ - private $second = null; + protected $second = null; /** * Constructor. diff --git a/BigQueryReservation/src/V1/TableReference.php b/BigQueryReservation/src/V1/TableReference.php index bab29eddef6d..a90214c8e1bb 100644 --- a/BigQueryReservation/src/V1/TableReference.php +++ b/BigQueryReservation/src/V1/TableReference.php @@ -21,19 +21,19 @@ class TableReference extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string project_id = 1; */ - private $project_id = ''; + protected $project_id = ''; /** * The ID of the dataset in the above project. * * Generated from protobuf field string dataset_id = 2; */ - private $dataset_id = ''; + protected $dataset_id = ''; /** * The ID of the table in the above dataset. * * Generated from protobuf field string table_id = 3; */ - private $table_id = ''; + protected $table_id = ''; /** * Constructor. diff --git a/BigQueryReservation/src/V1/UpdateAssignmentRequest.php b/BigQueryReservation/src/V1/UpdateAssignmentRequest.php index 6e4ca72aea41..9cf9c1ac0556 100644 --- a/BigQueryReservation/src/V1/UpdateAssignmentRequest.php +++ b/BigQueryReservation/src/V1/UpdateAssignmentRequest.php @@ -21,13 +21,13 @@ class UpdateAssignmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Assignment assignment = 1; */ - private $assignment = null; + protected $assignment = null; /** * Standard field mask for the set of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\BigQuery\Reservation\V1\Assignment $assignment Content of the assignment to update. diff --git a/BigQueryReservation/src/V1/UpdateBiReservationRequest.php b/BigQueryReservation/src/V1/UpdateBiReservationRequest.php index f5f1fe550549..f38c800ad548 100644 --- a/BigQueryReservation/src/V1/UpdateBiReservationRequest.php +++ b/BigQueryReservation/src/V1/UpdateBiReservationRequest.php @@ -20,13 +20,13 @@ class UpdateBiReservationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.BiReservation bi_reservation = 1; */ - private $bi_reservation = null; + protected $bi_reservation = null; /** * A list of fields to be updated in this request. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\BigQuery\Reservation\V1\BiReservation $biReservation A reservation to update. diff --git a/BigQueryReservation/src/V1/UpdateCapacityCommitmentRequest.php b/BigQueryReservation/src/V1/UpdateCapacityCommitmentRequest.php index 0b7fbe993bcf..b60c38af791f 100644 --- a/BigQueryReservation/src/V1/UpdateCapacityCommitmentRequest.php +++ b/BigQueryReservation/src/V1/UpdateCapacityCommitmentRequest.php @@ -21,13 +21,13 @@ class UpdateCapacityCommitmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.CapacityCommitment capacity_commitment = 1; */ - private $capacity_commitment = null; + protected $capacity_commitment = null; /** * Standard field mask for the set of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\BigQuery\Reservation\V1\CapacityCommitment $capacityCommitment Content of the capacity commitment to update. diff --git a/BigQueryReservation/src/V1/UpdateReservationRequest.php b/BigQueryReservation/src/V1/UpdateReservationRequest.php index 887fbc031646..001b97e55e2a 100644 --- a/BigQueryReservation/src/V1/UpdateReservationRequest.php +++ b/BigQueryReservation/src/V1/UpdateReservationRequest.php @@ -21,13 +21,13 @@ class UpdateReservationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.reservation.v1.Reservation reservation = 1; */ - private $reservation = null; + protected $reservation = null; /** * Standard field mask for the set of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\BigQuery\Reservation\V1\Reservation $reservation Content of the reservation to update. diff --git a/BigQueryReservation/tests/Unit/V1/Client/ReservationServiceClientTest.php b/BigQueryReservation/tests/Unit/V1/Client/ReservationServiceClientTest.php index c9218db4fb33..0e068c934895 100644 --- a/BigQueryReservation/tests/Unit/V1/Client/ReservationServiceClientTest.php +++ b/BigQueryReservation/tests/Unit/V1/Client/ReservationServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ReservationServiceClient */ @@ -107,8 +109,7 @@ public function createAssignmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new CreateAssignmentRequest()) - ->setParent($formattedParent); + $request = (new CreateAssignmentRequest())->setParent($formattedParent); $response = $gapicClient->createAssignment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -132,17 +133,19 @@ public function createAssignmentExceptionTest() $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); + $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->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new CreateAssignmentRequest()) - ->setParent($formattedParent); + $request = (new CreateAssignmentRequest())->setParent($formattedParent); try { $gapicClient->createAssignment($request); // If the $gapicClient method call did not throw, fail the test @@ -175,15 +178,17 @@ public function createCapacityCommitmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new CreateCapacityCommitmentRequest()) - ->setParent($formattedParent); + $request = (new CreateCapacityCommitmentRequest())->setParent($formattedParent); $response = $gapicClient->createCapacityCommitment($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.bigquery.reservation.v1.ReservationService/CreateCapacityCommitment', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/CreateCapacityCommitment', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -200,17 +205,19 @@ public function createCapacityCommitmentExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new CreateCapacityCommitmentRequest()) - ->setParent($formattedParent); + $request = (new CreateCapacityCommitmentRequest())->setParent($formattedParent); try { $gapicClient->createCapacityCommitment($request); // If the $gapicClient method call did not throw, fail the test @@ -247,15 +254,17 @@ public function createReservationTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new CreateReservationRequest()) - ->setParent($formattedParent); + $request = (new CreateReservationRequest())->setParent($formattedParent); $response = $gapicClient->createReservation($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.bigquery.reservation.v1.ReservationService/CreateReservation', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/CreateReservation', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -272,17 +281,19 @@ public function createReservationExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new CreateReservationRequest()) - ->setParent($formattedParent); + $request = (new CreateReservationRequest())->setParent($formattedParent); try { $gapicClient->createReservation($request); // If the $gapicClient method call did not throw, fail the test @@ -309,8 +320,7 @@ public function deleteAssignmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - $request = (new DeleteAssignmentRequest()) - ->setName($formattedName); + $request = (new DeleteAssignmentRequest())->setName($formattedName); $gapicClient->deleteAssignment($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -333,17 +343,19 @@ public function deleteAssignmentExceptionTest() $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); + $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->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - $request = (new DeleteAssignmentRequest()) - ->setName($formattedName); + $request = (new DeleteAssignmentRequest())->setName($formattedName); try { $gapicClient->deleteAssignment($request); // If the $gapicClient method call did not throw, fail the test @@ -370,14 +382,16 @@ public function deleteCapacityCommitmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $request = (new DeleteCapacityCommitmentRequest()) - ->setName($formattedName); + $request = (new DeleteCapacityCommitmentRequest())->setName($formattedName); $gapicClient->deleteCapacityCommitment($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/DeleteCapacityCommitment', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/DeleteCapacityCommitment', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -394,17 +408,19 @@ public function deleteCapacityCommitmentExceptionTest() $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); + $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->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $request = (new DeleteCapacityCommitmentRequest()) - ->setName($formattedName); + $request = (new DeleteCapacityCommitmentRequest())->setName($formattedName); try { $gapicClient->deleteCapacityCommitment($request); // If the $gapicClient method call did not throw, fail the test @@ -431,14 +447,16 @@ public function deleteReservationTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new DeleteReservationRequest()) - ->setName($formattedName); + $request = (new DeleteReservationRequest())->setName($formattedName); $gapicClient->deleteReservation($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/DeleteReservation', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/DeleteReservation', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -455,17 +473,19 @@ public function deleteReservationExceptionTest() $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); + $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->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new DeleteReservationRequest()) - ->setName($formattedName); + $request = (new DeleteReservationRequest())->setName($formattedName); try { $gapicClient->deleteReservation($request); // If the $gapicClient method call did not throw, fail the test @@ -496,8 +516,7 @@ public function getBiReservationTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->biReservationName('[PROJECT]', '[LOCATION]'); - $request = (new GetBiReservationRequest()) - ->setName($formattedName); + $request = (new GetBiReservationRequest())->setName($formattedName); $response = $gapicClient->getBiReservation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -521,17 +540,19 @@ public function getBiReservationExceptionTest() $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); + $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->biReservationName('[PROJECT]', '[LOCATION]'); - $request = (new GetBiReservationRequest()) - ->setName($formattedName); + $request = (new GetBiReservationRequest())->setName($formattedName); try { $gapicClient->getBiReservation($request); // If the $gapicClient method call did not throw, fail the test @@ -564,15 +585,17 @@ public function getCapacityCommitmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $request = (new GetCapacityCommitmentRequest()) - ->setName($formattedName); + $request = (new GetCapacityCommitmentRequest())->setName($formattedName); $response = $gapicClient->getCapacityCommitment($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.bigquery.reservation.v1.ReservationService/GetCapacityCommitment', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/GetCapacityCommitment', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -589,17 +612,19 @@ public function getCapacityCommitmentExceptionTest() $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); + $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->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $request = (new GetCapacityCommitmentRequest()) - ->setName($formattedName); + $request = (new GetCapacityCommitmentRequest())->setName($formattedName); try { $gapicClient->getCapacityCommitment($request); // If the $gapicClient method call did not throw, fail the test @@ -636,8 +661,7 @@ public function getReservationTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new GetReservationRequest()) - ->setName($formattedName); + $request = (new GetReservationRequest())->setName($formattedName); $response = $gapicClient->getReservation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -661,17 +685,19 @@ public function getReservationExceptionTest() $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); + $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->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new GetReservationRequest()) - ->setName($formattedName); + $request = (new GetReservationRequest())->setName($formattedName); try { $gapicClient->getReservation($request); // If the $gapicClient method call did not throw, fail the test @@ -696,17 +722,14 @@ public function listAssignmentsTest() // Mock response $nextPageToken = ''; $assignmentsElement = new Assignment(); - $assignments = [ - $assignmentsElement, - ]; + $assignments = [$assignmentsElement]; $expectedResponse = new ListAssignmentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAssignments($assignments); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new ListAssignmentsRequest()) - ->setParent($formattedParent); + $request = (new ListAssignmentsRequest())->setParent($formattedParent); $response = $gapicClient->listAssignments($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -733,17 +756,19 @@ public function listAssignmentsExceptionTest() $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); + $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->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new ListAssignmentsRequest()) - ->setParent($formattedParent); + $request = (new ListAssignmentsRequest())->setParent($formattedParent); try { $gapicClient->listAssignments($request); // If the $gapicClient method call did not throw, fail the test @@ -768,17 +793,14 @@ public function listCapacityCommitmentsTest() // Mock response $nextPageToken = ''; $capacityCommitmentsElement = new CapacityCommitment(); - $capacityCommitments = [ - $capacityCommitmentsElement, - ]; + $capacityCommitments = [$capacityCommitmentsElement]; $expectedResponse = new ListCapacityCommitmentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setCapacityCommitments($capacityCommitments); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListCapacityCommitmentsRequest()) - ->setParent($formattedParent); + $request = (new ListCapacityCommitmentsRequest())->setParent($formattedParent); $response = $gapicClient->listCapacityCommitments($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -788,7 +810,10 @@ public function listCapacityCommitmentsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/ListCapacityCommitments', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/ListCapacityCommitments', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -805,17 +830,19 @@ public function listCapacityCommitmentsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListCapacityCommitmentsRequest()) - ->setParent($formattedParent); + $request = (new ListCapacityCommitmentsRequest())->setParent($formattedParent); try { $gapicClient->listCapacityCommitments($request); // If the $gapicClient method call did not throw, fail the test @@ -840,17 +867,14 @@ public function listReservationsTest() // Mock response $nextPageToken = ''; $reservationsElement = new Reservation(); - $reservations = [ - $reservationsElement, - ]; + $reservations = [$reservationsElement]; $expectedResponse = new ListReservationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setReservations($reservations); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListReservationsRequest()) - ->setParent($formattedParent); + $request = (new ListReservationsRequest())->setParent($formattedParent); $response = $gapicClient->listReservations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -877,17 +901,19 @@ public function listReservationsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListReservationsRequest()) - ->setParent($formattedParent); + $request = (new ListReservationsRequest())->setParent($formattedParent); try { $gapicClient->listReservations($request); // If the $gapicClient method call did not throw, fail the test @@ -925,7 +951,10 @@ public function mergeCapacityCommitmentsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/MergeCapacityCommitments', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/MergeCapacityCommitments', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -940,12 +969,15 @@ public function mergeCapacityCommitmentsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new MergeCapacityCommitmentsRequest(); try { @@ -978,8 +1010,7 @@ public function moveAssignmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - $request = (new MoveAssignmentRequest()) - ->setName($formattedName); + $request = (new MoveAssignmentRequest())->setName($formattedName); $response = $gapicClient->moveAssignment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1003,17 +1034,19 @@ public function moveAssignmentExceptionTest() $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); + $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->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - $request = (new MoveAssignmentRequest()) - ->setName($formattedName); + $request = (new MoveAssignmentRequest())->setName($formattedName); try { $gapicClient->moveAssignment($request); // If the $gapicClient method call did not throw, fail the test @@ -1038,17 +1071,14 @@ public function searchAllAssignmentsTest() // Mock response $nextPageToken = ''; $assignmentsElement = new Assignment(); - $assignments = [ - $assignmentsElement, - ]; + $assignments = [$assignmentsElement]; $expectedResponse = new SearchAllAssignmentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAssignments($assignments); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new SearchAllAssignmentsRequest()) - ->setParent($formattedParent); + $request = (new SearchAllAssignmentsRequest())->setParent($formattedParent); $response = $gapicClient->searchAllAssignments($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1058,7 +1088,10 @@ public function searchAllAssignmentsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/SearchAllAssignments', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/SearchAllAssignments', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1075,17 +1108,19 @@ public function searchAllAssignmentsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new SearchAllAssignmentsRequest()) - ->setParent($formattedParent); + $request = (new SearchAllAssignmentsRequest())->setParent($formattedParent); try { $gapicClient->searchAllAssignments($request); // If the $gapicClient method call did not throw, fail the test @@ -1110,17 +1145,14 @@ public function searchAssignmentsTest() // Mock response $nextPageToken = ''; $assignmentsElement = new Assignment(); - $assignments = [ - $assignmentsElement, - ]; + $assignments = [$assignmentsElement]; $expectedResponse = new SearchAssignmentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAssignments($assignments); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new SearchAssignmentsRequest()) - ->setParent($formattedParent); + $request = (new SearchAssignmentsRequest())->setParent($formattedParent); $response = $gapicClient->searchAssignments($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1130,7 +1162,10 @@ public function searchAssignmentsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/SearchAssignments', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/SearchAssignments', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1147,17 +1182,19 @@ public function searchAssignmentsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new SearchAssignmentsRequest()) - ->setParent($formattedParent); + $request = (new SearchAssignmentsRequest())->setParent($formattedParent); try { $gapicClient->searchAssignments($request); // If the $gapicClient method call did not throw, fail the test @@ -1184,15 +1221,17 @@ public function splitCapacityCommitmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $request = (new SplitCapacityCommitmentRequest()) - ->setName($formattedName); + $request = (new SplitCapacityCommitmentRequest())->setName($formattedName); $response = $gapicClient->splitCapacityCommitment($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.bigquery.reservation.v1.ReservationService/SplitCapacityCommitment', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/SplitCapacityCommitment', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1209,17 +1248,19 @@ public function splitCapacityCommitmentExceptionTest() $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); + $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->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $request = (new SplitCapacityCommitmentRequest()) - ->setName($formattedName); + $request = (new SplitCapacityCommitmentRequest())->setName($formattedName); try { $gapicClient->splitCapacityCommitment($request); // If the $gapicClient method call did not throw, fail the test @@ -1270,12 +1311,15 @@ public function updateAssignmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdateAssignmentRequest(); try { @@ -1313,7 +1357,10 @@ public function updateBiReservationTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/UpdateBiReservation', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/UpdateBiReservation', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -1328,12 +1375,15 @@ public function updateBiReservationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdateBiReservationRequest(); try { @@ -1373,7 +1423,10 @@ public function updateCapacityCommitmentTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/UpdateCapacityCommitment', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/UpdateCapacityCommitment', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -1388,12 +1441,15 @@ public function updateCapacityCommitmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdateCapacityCommitmentRequest(); try { @@ -1437,7 +1493,10 @@ public function updateReservationTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/UpdateReservation', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.reservation.v1.ReservationService/UpdateReservation', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -1452,12 +1511,15 @@ public function updateReservationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdateReservationRequest(); try { @@ -1490,8 +1552,7 @@ public function createAssignmentAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $request = (new CreateAssignmentRequest()) - ->setParent($formattedParent); + $request = (new CreateAssignmentRequest())->setParent($formattedParent); $response = $gapicClient->createAssignmentAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); diff --git a/BigQueryReservation/tests/Unit/V1/ReservationServiceClientTest.php b/BigQueryReservation/tests/Unit/V1/ReservationServiceClientTest.php deleted file mode 100644 index 2c04e90a6fa3..000000000000 --- a/BigQueryReservation/tests/Unit/V1/ReservationServiceClientTest.php +++ /dev/null @@ -1,1380 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ReservationServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ReservationServiceClient($options); - } - - /** @test */ - public function createAssignmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $assignee = 'assignee-369881649'; - $expectedResponse = new Assignment(); - $expectedResponse->setName($name); - $expectedResponse->setAssignee($assignee); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $response = $gapicClient->createAssignment($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/CreateAssignment', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createAssignmentExceptionTest() - { - $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->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - try { - $gapicClient->createAssignment($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 createCapacityCommitmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $slotCount = 191518834; - $multiRegionAuxiliary = false; - $expectedResponse = new CapacityCommitment(); - $expectedResponse->setName($name); - $expectedResponse->setSlotCount($slotCount); - $expectedResponse->setMultiRegionAuxiliary($multiRegionAuxiliary); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->createCapacityCommitment($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/CreateCapacityCommitment', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createCapacityCommitmentExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->createCapacityCommitment($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 createReservationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $slotCapacity = 1516717605; - $ignoreIdleSlots = false; - $concurrency = 1476186003; - $multiRegionAuxiliary = false; - $expectedResponse = new Reservation(); - $expectedResponse->setName($name); - $expectedResponse->setSlotCapacity($slotCapacity); - $expectedResponse->setIgnoreIdleSlots($ignoreIdleSlots); - $expectedResponse->setConcurrency($concurrency); - $expectedResponse->setMultiRegionAuxiliary($multiRegionAuxiliary); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->createReservation($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/CreateReservation', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createReservationExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->createReservation($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 deleteAssignmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - $gapicClient->deleteAssignment($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/DeleteAssignment', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteAssignmentExceptionTest() - { - $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->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - try { - $gapicClient->deleteAssignment($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 deleteCapacityCommitmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $gapicClient->deleteCapacityCommitment($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/DeleteCapacityCommitment', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteCapacityCommitmentExceptionTest() - { - $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->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - try { - $gapicClient->deleteCapacityCommitment($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 deleteReservationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $gapicClient->deleteReservation($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/DeleteReservation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteReservationExceptionTest() - { - $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->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - try { - $gapicClient->deleteReservation($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 getBiReservationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $size = 3530753; - $expectedResponse = new BiReservation(); - $expectedResponse->setName($name2); - $expectedResponse->setSize($size); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->biReservationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->getBiReservation($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.bigquery.reservation.v1.ReservationService/GetBiReservation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getBiReservationExceptionTest() - { - $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->biReservationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->getBiReservation($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 getCapacityCommitmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $slotCount = 191518834; - $multiRegionAuxiliary = false; - $expectedResponse = new CapacityCommitment(); - $expectedResponse->setName($name2); - $expectedResponse->setSlotCount($slotCount); - $expectedResponse->setMultiRegionAuxiliary($multiRegionAuxiliary); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $response = $gapicClient->getCapacityCommitment($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.bigquery.reservation.v1.ReservationService/GetCapacityCommitment', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getCapacityCommitmentExceptionTest() - { - $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->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - try { - $gapicClient->getCapacityCommitment($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 getReservationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $slotCapacity = 1516717605; - $ignoreIdleSlots = false; - $concurrency = 1476186003; - $multiRegionAuxiliary = false; - $expectedResponse = new Reservation(); - $expectedResponse->setName($name2); - $expectedResponse->setSlotCapacity($slotCapacity); - $expectedResponse->setIgnoreIdleSlots($ignoreIdleSlots); - $expectedResponse->setConcurrency($concurrency); - $expectedResponse->setMultiRegionAuxiliary($multiRegionAuxiliary); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $response = $gapicClient->getReservation($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.bigquery.reservation.v1.ReservationService/GetReservation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getReservationExceptionTest() - { - $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->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - try { - $gapicClient->getReservation($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 listAssignmentsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $assignmentsElement = new Assignment(); - $assignments = [ - $assignmentsElement, - ]; - $expectedResponse = new ListAssignmentsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAssignments($assignments); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - $response = $gapicClient->listAssignments($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAssignments()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/ListAssignments', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listAssignmentsExceptionTest() - { - $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->reservationName('[PROJECT]', '[LOCATION]', '[RESERVATION]'); - try { - $gapicClient->listAssignments($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 listCapacityCommitmentsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $capacityCommitmentsElement = new CapacityCommitment(); - $capacityCommitments = [ - $capacityCommitmentsElement, - ]; - $expectedResponse = new ListCapacityCommitmentsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setCapacityCommitments($capacityCommitments); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listCapacityCommitments($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getCapacityCommitments()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/ListCapacityCommitments', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listCapacityCommitmentsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listCapacityCommitments($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 listReservationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $reservationsElement = new Reservation(); - $reservations = [ - $reservationsElement, - ]; - $expectedResponse = new ListReservationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setReservations($reservations); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listReservations($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getReservations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/ListReservations', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listReservationsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listReservations($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 mergeCapacityCommitmentsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $slotCount = 191518834; - $multiRegionAuxiliary = false; - $expectedResponse = new CapacityCommitment(); - $expectedResponse->setName($name); - $expectedResponse->setSlotCount($slotCount); - $expectedResponse->setMultiRegionAuxiliary($multiRegionAuxiliary); - $transport->addResponse($expectedResponse); - $response = $gapicClient->mergeCapacityCommitments(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/MergeCapacityCommitments', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function mergeCapacityCommitmentsExceptionTest() - { - $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); - try { - $gapicClient->mergeCapacityCommitments(); - // 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 moveAssignmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $assignee = 'assignee-369881649'; - $expectedResponse = new Assignment(); - $expectedResponse->setName($name2); - $expectedResponse->setAssignee($assignee); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - $response = $gapicClient->moveAssignment($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.bigquery.reservation.v1.ReservationService/MoveAssignment', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function moveAssignmentExceptionTest() - { - $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->assignmentName('[PROJECT]', '[LOCATION]', '[RESERVATION]', '[ASSIGNMENT]'); - try { - $gapicClient->moveAssignment($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 searchAllAssignmentsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $assignmentsElement = new Assignment(); - $assignments = [ - $assignmentsElement, - ]; - $expectedResponse = new SearchAllAssignmentsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAssignments($assignments); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->searchAllAssignments($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAssignments()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/SearchAllAssignments', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function searchAllAssignmentsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->searchAllAssignments($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 searchAssignmentsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $assignmentsElement = new Assignment(); - $assignments = [ - $assignmentsElement, - ]; - $expectedResponse = new SearchAssignmentsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAssignments($assignments); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->searchAssignments($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAssignments()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/SearchAssignments', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function searchAssignmentsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->searchAssignments($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 splitCapacityCommitmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new SplitCapacityCommitmentResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - $response = $gapicClient->splitCapacityCommitment($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.bigquery.reservation.v1.ReservationService/SplitCapacityCommitment', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function splitCapacityCommitmentExceptionTest() - { - $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->capacityCommitmentName('[PROJECT]', '[LOCATION]', '[CAPACITY_COMMITMENT]'); - try { - $gapicClient->splitCapacityCommitment($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 updateAssignmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $assignee = 'assignee-369881649'; - $expectedResponse = new Assignment(); - $expectedResponse->setName($name); - $expectedResponse->setAssignee($assignee); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateAssignment(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/UpdateAssignment', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateAssignmentExceptionTest() - { - $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); - try { - $gapicClient->updateAssignment(); - // 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 updateBiReservationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $size = 3530753; - $expectedResponse = new BiReservation(); - $expectedResponse->setName($name); - $expectedResponse->setSize($size); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateBiReservation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/UpdateBiReservation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateBiReservationExceptionTest() - { - $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); - try { - $gapicClient->updateBiReservation(); - // 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 updateCapacityCommitmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $slotCount = 191518834; - $multiRegionAuxiliary = false; - $expectedResponse = new CapacityCommitment(); - $expectedResponse->setName($name); - $expectedResponse->setSlotCount($slotCount); - $expectedResponse->setMultiRegionAuxiliary($multiRegionAuxiliary); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateCapacityCommitment(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/UpdateCapacityCommitment', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateCapacityCommitmentExceptionTest() - { - $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); - try { - $gapicClient->updateCapacityCommitment(); - // 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 updateReservationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $slotCapacity = 1516717605; - $ignoreIdleSlots = false; - $concurrency = 1476186003; - $multiRegionAuxiliary = false; - $expectedResponse = new Reservation(); - $expectedResponse->setName($name); - $expectedResponse->setSlotCapacity($slotCapacity); - $expectedResponse->setIgnoreIdleSlots($ignoreIdleSlots); - $expectedResponse->setConcurrency($concurrency); - $expectedResponse->setMultiRegionAuxiliary($multiRegionAuxiliary); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateReservation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.reservation.v1.ReservationService/UpdateReservation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateReservationExceptionTest() - { - $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); - try { - $gapicClient->updateReservation(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/BillingBudgets/.OwlBot.yaml b/BillingBudgets/.OwlBot.yaml index c9e6eb1a5dd2..875e8ccbdd64 100644 --- a/BillingBudgets/.OwlBot.yaml +++ b/BillingBudgets/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/billing/budgets/(.*)/.*-php/(.*) + - source: /google/cloud/billing/budgets/(v1)/.*-php/(.*) dest: /owl-bot-staging/BillingBudgets/$1/$2 api-name: BillingBudgets diff --git a/BillingBudgets/metadata/V1Beta1/BudgetModel.php b/BillingBudgets/metadata/V1Beta1/BudgetModel.php deleted file mode 100644 index 9538ddfc7e52..000000000000 Binary files a/BillingBudgets/metadata/V1Beta1/BudgetModel.php and /dev/null differ diff --git a/BillingBudgets/metadata/V1Beta1/BudgetService.php b/BillingBudgets/metadata/V1Beta1/BudgetService.php deleted file mode 100644 index 151b458d053f..000000000000 --- a/BillingBudgets/metadata/V1Beta1/BudgetService.php +++ /dev/null @@ -1,61 +0,0 @@ -internalAddGeneratedFile( - ' -ø -9google/cloud/billing/budgets/v1beta1/budget_service.proto$google.cloud.billing.budgets.v1beta1google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto7google/cloud/billing/budgets/v1beta1/budget_model.protogoogle/protobuf/empty.proto google/protobuf/field_mask.proto"– -CreateBudgetRequest< -parent ( B,àAúA&$billingbudgets.googleapis.com/BudgetA -budget ( 2,.google.cloud.billing.budgets.v1beta1.BudgetBàA"Ž -UpdateBudgetRequestA -budget ( 2,.google.cloud.billing.budgets.v1beta1.BudgetBàA4 - update_mask ( 2.google.protobuf.FieldMaskBàA"N -GetBudgetRequest: -name ( B,àAúA& -$billingbudgets.googleapis.com/Budget"— -ListBudgetsRequest< -parent ( B,àAúA&$billingbudgets.googleapis.com/Budget -scope ( BàA - page_size (BàA - -page_token ( BàA"m -ListBudgetsResponse= -budgets ( 2,.google.cloud.billing.budgets.v1beta1.Budget -next_page_token ( "Q -DeleteBudgetRequest: -name ( B,àAúA& -$billingbudgets.googleapis.com/Budget2÷ - BudgetService¯ - CreateBudget9.google.cloud.billing.budgets.v1beta1.CreateBudgetRequest,.google.cloud.billing.budgets.v1beta1.Budget"6‚Óä“0"+/v1beta1/{parent=billingAccounts/*}/budgets:*¶ - UpdateBudget9.google.cloud.billing.budgets.v1beta1.UpdateBudgetRequest,.google.cloud.billing.budgets.v1beta1.Budget"=‚Óä“722/v1beta1/{budget.name=billingAccounts/*/budgets/*}:*¦ - GetBudget6.google.cloud.billing.budgets.v1beta1.GetBudgetRequest,.google.cloud.billing.budgets.v1beta1.Budget"3‚Óä“-+/v1beta1/{name=billingAccounts/*/budgets/*}· - ListBudgets8.google.cloud.billing.budgets.v1beta1.ListBudgetsRequest9.google.cloud.billing.budgets.v1beta1.ListBudgetsResponse"3‚Óä“-+/v1beta1/{parent=billingAccounts/*}/budgets– - DeleteBudget9.google.cloud.billing.budgets.v1beta1.DeleteBudgetRequest.google.protobuf.Empty"3‚Óä“-*+/v1beta1/{name=billingAccounts/*/budgets/*}ÊAbillingbudgets.googleapis.comÒA\\https://www.googleapis.com/auth/cloud-billing,https://www.googleapis.com/auth/cloud-platformBp -(com.google.cloud.billing.budgets.v1beta1PZBcloud.google.com/go/billing/budgets/apiv1beta1/budgetspb;budgetspbbproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/BillingBudgets/owlbot.py b/BillingBudgets/owlbot.py index 2eb18fbe47cd..9a35bc05285b 100644 --- a/BillingBudgets/owlbot.py +++ b/BillingBudgets/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,28 +41,16 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/BillingBudgets/src/V1/Budget.php b/BillingBudgets/src/V1/Budget.php index b86fc5e91c1f..0da2acd85199 100644 --- a/BillingBudgets/src/V1/Budget.php +++ b/BillingBudgets/src/V1/Budget.php @@ -26,14 +26,14 @@ class Budget extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * User data for display name in UI. The name must be less than or equal to 60 * characters. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Optional. Filters that define which resources are used to compute the * actual spend against the budget amount, such as projects, services, and the @@ -41,13 +41,13 @@ class Budget extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.billing.budgets.v1.Filter budget_filter = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $budget_filter = null; + protected $budget_filter = null; /** * Required. Budgeted amount. * * Generated from protobuf field .google.cloud.billing.budgets.v1.BudgetAmount amount = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $amount = null; + protected $amount = null; /** * Optional. Rules that trigger alerts (notifications of thresholds * being crossed) when spend exceeds the specified percentages of the budget. @@ -63,7 +63,7 @@ class Budget extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.billing.budgets.v1.NotificationsRule notifications_rule = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $notifications_rule = null; + protected $notifications_rule = null; /** * Optional. Etag to validate that the object is unchanged for a * read-modify-write operation. @@ -71,7 +71,7 @@ class Budget extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 7 [(.google.api.field_behavior) = OPTIONAL]; */ - private $etag = ''; + protected $etag = ''; /** * Constructor. diff --git a/BillingBudgets/src/V1/BudgetServiceClient.php b/BillingBudgets/src/V1/BudgetServiceClient.php deleted file mode 100644 index 9a1d4786876b..000000000000 --- a/BillingBudgets/src/V1/BudgetServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. Budget to create. * * Generated from protobuf field .google.cloud.billing.budgets.v1.Budget budget = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $budget = null; + protected $budget = null; /** * @param string $parent Required. The name of the billing account to create the budget in. Values diff --git a/BillingBudgets/src/V1/CustomPeriod.php b/BillingBudgets/src/V1/CustomPeriod.php index 4a2450c9b591..e7b18a2688b0 100644 --- a/BillingBudgets/src/V1/CustomPeriod.php +++ b/BillingBudgets/src/V1/CustomPeriod.php @@ -20,7 +20,7 @@ class CustomPeriod extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.type.Date start_date = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $start_date = null; + protected $start_date = null; /** * Optional. The end date of the time period. Budgets with elapsed end date * won't be processed. If unset, specifies to track all usage incurred since @@ -28,7 +28,7 @@ class CustomPeriod extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.type.Date end_date = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $end_date = null; + protected $end_date = null; /** * Constructor. diff --git a/BillingBudgets/src/V1/DeleteBudgetRequest.php b/BillingBudgets/src/V1/DeleteBudgetRequest.php index c8e01fd95bce..4bdbd4788aa0 100644 --- a/BillingBudgets/src/V1/DeleteBudgetRequest.php +++ b/BillingBudgets/src/V1/DeleteBudgetRequest.php @@ -21,7 +21,7 @@ class DeleteBudgetRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the budget to delete. Values are of the form diff --git a/BillingBudgets/src/V1/Filter.php b/BillingBudgets/src/V1/Filter.php index 600ed907bbc4..a9a8df097c50 100644 --- a/BillingBudgets/src/V1/Filter.php +++ b/BillingBudgets/src/V1/Filter.php @@ -55,7 +55,7 @@ class Filter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.billing.budgets.v1.Filter.CreditTypesTreatment credit_types_treatment = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $credit_types_treatment = 0; + protected $credit_types_treatment = 0; /** * Optional. A set of services of the form `services/{service_id}`, * specifying that usage from only this set of services should be diff --git a/BillingBudgets/src/V1/Gapic/BudgetServiceGapicClient.php b/BillingBudgets/src/V1/Gapic/BudgetServiceGapicClient.php deleted file mode 100644 index 8a5b174fbbdd..000000000000 --- a/BillingBudgets/src/V1/Gapic/BudgetServiceGapicClient.php +++ /dev/null @@ -1,556 +0,0 @@ -billingAccountName('[BILLING_ACCOUNT]'); - * $budget = new Budget(); - * $response = $budgetServiceClient->createBudget($formattedParent, $budget); - * } finally { - * $budgetServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Billing\Budgets\V1\Client\BudgetServiceClient}. - */ -class BudgetServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.billing.budgets.v1.BudgetService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'billingbudgets.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'billingbudgets.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-billing', - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $billingAccountNameTemplate; - - private static $budgetNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getBillingAccountNameTemplate() - { - if (self::$billingAccountNameTemplate == null) { - self::$billingAccountNameTemplate = new PathTemplate('billingAccounts/{billing_account}'); - } - - return self::$billingAccountNameTemplate; - } - - private static function getBudgetNameTemplate() - { - if (self::$budgetNameTemplate == null) { - self::$budgetNameTemplate = new PathTemplate('billingAccounts/{billing_account}/budgets/{budget}'); - } - - return self::$budgetNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'billingAccount' => self::getBillingAccountNameTemplate(), - 'budget' => self::getBudgetNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account resource. - * - * @param string $billingAccount - * - * @return string The formatted billing_account resource. - */ - public static function billingAccountName($billingAccount) - { - return self::getBillingAccountNameTemplate()->render([ - 'billing_account' => $billingAccount, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a budget - * resource. - * - * @param string $billingAccount - * @param string $budget - * - * @return string The formatted budget resource. - */ - public static function budgetName($billingAccount, $budget) - { - return self::getBudgetNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * 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. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $formattedParent = $budgetServiceClient->billingAccountName('[BILLING_ACCOUNT]'); - * $budget = new Budget(); - * $response = $budgetServiceClient->createBudget($formattedParent, $budget); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the billing account to create the budget in. Values - * are of the form `billingAccounts/{billingAccountId}`. - * @param Budget $budget Required. Budget to create. - * @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\Billing\Budgets\V1\Budget - * - * @throws ApiException if the remote call fails - */ - public function createBudget($parent, $budget, array $optionalArgs = []) - { - $request = new CreateBudgetRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setBudget($budget); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateBudget', Budget::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes a budget. Returns successfully if already deleted. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $formattedName = $budgetServiceClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - * $budgetServiceClient->deleteBudget($formattedName); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the budget to delete. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * @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 deleteBudget($name, array $optionalArgs = []) - { - $request = new DeleteBudgetRequest(); - $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('DeleteBudget', GPBEmpty::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $formattedName = $budgetServiceClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - * $response = $budgetServiceClient->getBudget($formattedName); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of budget to get. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * @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\Billing\Budgets\V1\Budget - * - * @throws ApiException if the remote call fails - */ - public function getBudget($name, array $optionalArgs = []) - { - $request = new GetBudgetRequest(); - $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('GetBudget', Budget::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $formattedParent = $budgetServiceClient->billingAccountName('[BILLING_ACCOUNT]'); - * // Iterate over pages of elements - * $pagedResponse = $budgetServiceClient->listBudgets($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $budgetServiceClient->listBudgets($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Name of billing account to list budgets under. Values - * are of the form `billingAccounts/{billingAccountId}`. - * @param array $optionalArgs { - * Optional. - * - * @type string $scope - * Optional. Set the scope of the budgets to be returned, in the format of the - * resource name. The scope of a budget is the cost that it tracks, such as - * costs for a single project, or the costs for all projects in a folder. Only - * project scope (in the format of "projects/project-id" or "projects/123") is - * supported in this field. When this field is set to a project's resource - * name, the budgets returned are tracking the costs for that project. - * @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 listBudgets($parent, array $optionalArgs = []) - { - $request = new ListBudgetsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['scope'])) { - $request->setScope($optionalArgs['scope']); - } - - 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('ListBudgets', $optionalArgs, ListBudgetsResponse::class, $request); - } - - /** - * 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. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $budget = new Budget(); - * $response = $budgetServiceClient->updateBudget($budget); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param Budget $budget Required. The updated budget object. - * The budget to update is specified by the budget name in the budget. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Optional. Indicates which fields in the provided budget to update. - * Read-only fields (such as `name`) cannot be changed. If this is not - * provided, then only fields with non-default values from the request are - * updated. See - * https://developers.google.com/protocol-buffers/docs/proto3#default for more - * details about default values. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Billing\Budgets\V1\Budget - * - * @throws ApiException if the remote call fails - */ - public function updateBudget($budget, array $optionalArgs = []) - { - $request = new UpdateBudgetRequest(); - $requestParamHeaders = []; - $request->setBudget($budget); - $requestParamHeaders['budget.name'] = $budget->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('UpdateBudget', Budget::class, $optionalArgs, $request)->wait(); - } -} diff --git a/BillingBudgets/src/V1/GetBudgetRequest.php b/BillingBudgets/src/V1/GetBudgetRequest.php index d3a2b7e8a09d..1c12b459606a 100644 --- a/BillingBudgets/src/V1/GetBudgetRequest.php +++ b/BillingBudgets/src/V1/GetBudgetRequest.php @@ -21,7 +21,7 @@ class GetBudgetRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of budget to get. Values are of the form diff --git a/BillingBudgets/src/V1/ListBudgetsRequest.php b/BillingBudgets/src/V1/ListBudgetsRequest.php index 5d7ded538521..cc94ff1ad6ac 100644 --- a/BillingBudgets/src/V1/ListBudgetsRequest.php +++ b/BillingBudgets/src/V1/ListBudgetsRequest.php @@ -21,7 +21,7 @@ class ListBudgetsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. Set the scope of the budgets to be returned, in the format of the * resource name. The scope of a budget is the cost that it tracks, such as @@ -32,14 +32,14 @@ class ListBudgetsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string scope = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $scope = ''; + protected $scope = ''; /** * Optional. The maximum number of budgets to return per page. * The default and maximum value are 100. * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The value returned by the last `ListBudgetsResponse` which * indicates that this is a continuation of a prior `ListBudgets` call, @@ -47,7 +47,7 @@ class ListBudgetsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Name of billing account to list budgets under. Values diff --git a/BillingBudgets/src/V1/ListBudgetsResponse.php b/BillingBudgets/src/V1/ListBudgetsResponse.php index 8b185517edeb..c00fba71972a 100644 --- a/BillingBudgets/src/V1/ListBudgetsResponse.php +++ b/BillingBudgets/src/V1/ListBudgetsResponse.php @@ -27,7 +27,7 @@ class ListBudgetsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/BillingBudgets/src/V1/NotificationsRule.php b/BillingBudgets/src/V1/NotificationsRule.php index e281f06c95d5..cb57f006391a 100644 --- a/BillingBudgets/src/V1/NotificationsRule.php +++ b/BillingBudgets/src/V1/NotificationsRule.php @@ -42,7 +42,7 @@ class NotificationsRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string pubsub_topic = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $pubsub_topic = ''; + protected $pubsub_topic = ''; /** * Optional. Required when * [NotificationsRule.pubsub_topic][google.cloud.billing.budgets.v1.NotificationsRule.pubsub_topic] @@ -53,7 +53,7 @@ class NotificationsRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string schema_version = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $schema_version = ''; + protected $schema_version = ''; /** * Optional. Email targets to send notifications to when a threshold is * exceeded. This is in addition to the `DefaultIamRecipients` who receive @@ -87,7 +87,7 @@ class NotificationsRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool disable_default_iam_recipients = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $disable_default_iam_recipients = false; + protected $disable_default_iam_recipients = false; /** * Optional. When set to true, and when the budget has a single project * configured, notifications will be sent to project level recipients of that @@ -98,7 +98,7 @@ class NotificationsRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_project_level_recipients = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enable_project_level_recipients = false; + protected $enable_project_level_recipients = false; /** * Constructor. diff --git a/BillingBudgets/src/V1/ThresholdRule.php b/BillingBudgets/src/V1/ThresholdRule.php index c8558256376f..fdb59867e7a2 100644 --- a/BillingBudgets/src/V1/ThresholdRule.php +++ b/BillingBudgets/src/V1/ThresholdRule.php @@ -39,14 +39,14 @@ class ThresholdRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double threshold_percent = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $threshold_percent = 0.0; + protected $threshold_percent = 0.0; /** * Optional. The type of basis used to determine if spend has passed the * threshold. Behavior defaults to CURRENT_SPEND if not set. * * Generated from protobuf field .google.cloud.billing.budgets.v1.ThresholdRule.Basis spend_basis = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $spend_basis = 0; + protected $spend_basis = 0; /** * Constructor. diff --git a/BillingBudgets/src/V1/UpdateBudgetRequest.php b/BillingBudgets/src/V1/UpdateBudgetRequest.php index 5fd9f2a0ae04..7f5ed69c5deb 100644 --- a/BillingBudgets/src/V1/UpdateBudgetRequest.php +++ b/BillingBudgets/src/V1/UpdateBudgetRequest.php @@ -21,7 +21,7 @@ class UpdateBudgetRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.billing.budgets.v1.Budget budget = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $budget = null; + protected $budget = null; /** * Optional. Indicates which fields in the provided budget to update. * Read-only fields (such as `name`) cannot be changed. If this is not @@ -32,7 +32,7 @@ class UpdateBudgetRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\Billing\Budgets\V1\Budget $budget Required. The updated budget object. diff --git a/BillingBudgets/src/V1beta1/AllUpdatesRule.php b/BillingBudgets/src/V1beta1/AllUpdatesRule.php deleted file mode 100644 index 379bf7e81811..000000000000 --- a/BillingBudgets/src/V1beta1/AllUpdatesRule.php +++ /dev/null @@ -1,324 +0,0 @@ -google.cloud.billing.budgets.v1beta1.AllUpdatesRule - */ -class AllUpdatesRule extends \Google\Protobuf\Internal\Message -{ - /** - * Optional. The name of the Pub/Sub topic where budget related messages will - * be published, in the form `projects/{project_id}/topics/{topic_id}`. - * Updates are sent at regular intervals to the topic. The topic needs to be - * created before the budget is created; see - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications - * for more details. - * Caller is expected to have - * `pubsub.topics.setIamPolicy` permission on the topic when it's set for a - * budget, otherwise, the API call will fail with PERMISSION_DENIED. See - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#permissions_required_for_this_task - * for more details on Pub/Sub roles and permissions. - * - * Generated from protobuf field string pubsub_topic = 1 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $pubsub_topic = ''; - /** - * Optional. Required when - * [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic] - * is set. The schema version of the notification sent to - * [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic]. - * Only "1.0" is accepted. It represents the JSON schema as defined in - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format. - * - * Generated from protobuf field string schema_version = 2 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $schema_version = ''; - /** - * Optional. Targets to send notifications to when a threshold is exceeded. - * This is in addition to default recipients who have billing account IAM - * roles. The value is the full REST resource name of a monitoring - * notification channel with the form - * `projects/{project_id}/notificationChannels/{channel_id}`. A maximum of 5 - * channels are allowed. See - * https://cloud.google.com/billing/docs/how-to/budgets-notification-recipients - * for more details. - * - * Generated from protobuf field repeated string monitoring_notification_channels = 3 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $monitoring_notification_channels; - /** - * Optional. When set to true, disables default notifications sent when a - * threshold is exceeded. Default notifications are sent to those with Billing - * Account Administrator and Billing Account User IAM roles for the target - * account. - * - * Generated from protobuf field bool disable_default_iam_recipients = 4 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $disable_default_iam_recipients = false; - /** - * Optional. When set to true, and when the budget has a single project - * configured, notifications will be sent to project level recipients of that - * project. This field will be ignored if the budget has multiple or no - * project configured. - * Currently, project level recipients are the users with `Owner` role on a - * cloud project. - * - * Generated from protobuf field bool enable_project_level_recipients = 5 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $enable_project_level_recipients = false; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $pubsub_topic - * Optional. The name of the Pub/Sub topic where budget related messages will - * be published, in the form `projects/{project_id}/topics/{topic_id}`. - * Updates are sent at regular intervals to the topic. The topic needs to be - * created before the budget is created; see - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications - * for more details. - * Caller is expected to have - * `pubsub.topics.setIamPolicy` permission on the topic when it's set for a - * budget, otherwise, the API call will fail with PERMISSION_DENIED. See - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#permissions_required_for_this_task - * for more details on Pub/Sub roles and permissions. - * @type string $schema_version - * Optional. Required when - * [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic] - * is set. The schema version of the notification sent to - * [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic]. - * Only "1.0" is accepted. It represents the JSON schema as defined in - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format. - * @type array|\Google\Protobuf\Internal\RepeatedField $monitoring_notification_channels - * Optional. Targets to send notifications to when a threshold is exceeded. - * This is in addition to default recipients who have billing account IAM - * roles. The value is the full REST resource name of a monitoring - * notification channel with the form - * `projects/{project_id}/notificationChannels/{channel_id}`. A maximum of 5 - * channels are allowed. See - * https://cloud.google.com/billing/docs/how-to/budgets-notification-recipients - * for more details. - * @type bool $disable_default_iam_recipients - * Optional. When set to true, disables default notifications sent when a - * threshold is exceeded. Default notifications are sent to those with Billing - * Account Administrator and Billing Account User IAM roles for the target - * account. - * @type bool $enable_project_level_recipients - * Optional. When set to true, and when the budget has a single project - * configured, notifications will be sent to project level recipients of that - * project. This field will be ignored if the budget has multiple or no - * project configured. - * Currently, project level recipients are the users with `Owner` role on a - * cloud project. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetModel::initOnce(); - parent::__construct($data); - } - - /** - * Optional. The name of the Pub/Sub topic where budget related messages will - * be published, in the form `projects/{project_id}/topics/{topic_id}`. - * Updates are sent at regular intervals to the topic. The topic needs to be - * created before the budget is created; see - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications - * for more details. - * Caller is expected to have - * `pubsub.topics.setIamPolicy` permission on the topic when it's set for a - * budget, otherwise, the API call will fail with PERMISSION_DENIED. See - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#permissions_required_for_this_task - * for more details on Pub/Sub roles and permissions. - * - * Generated from protobuf field string pubsub_topic = 1 [(.google.api.field_behavior) = OPTIONAL]; - * @return string - */ - public function getPubsubTopic() - { - return $this->pubsub_topic; - } - - /** - * Optional. The name of the Pub/Sub topic where budget related messages will - * be published, in the form `projects/{project_id}/topics/{topic_id}`. - * Updates are sent at regular intervals to the topic. The topic needs to be - * created before the budget is created; see - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications - * for more details. - * Caller is expected to have - * `pubsub.topics.setIamPolicy` permission on the topic when it's set for a - * budget, otherwise, the API call will fail with PERMISSION_DENIED. See - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#permissions_required_for_this_task - * for more details on Pub/Sub roles and permissions. - * - * Generated from protobuf field string pubsub_topic = 1 [(.google.api.field_behavior) = OPTIONAL]; - * @param string $var - * @return $this - */ - public function setPubsubTopic($var) - { - GPBUtil::checkString($var, True); - $this->pubsub_topic = $var; - - return $this; - } - - /** - * Optional. Required when - * [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic] - * is set. The schema version of the notification sent to - * [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic]. - * Only "1.0" is accepted. It represents the JSON schema as defined in - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format. - * - * Generated from protobuf field string schema_version = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @return string - */ - public function getSchemaVersion() - { - return $this->schema_version; - } - - /** - * Optional. Required when - * [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic] - * is set. The schema version of the notification sent to - * [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic]. - * Only "1.0" is accepted. It represents the JSON schema as defined in - * https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format. - * - * Generated from protobuf field string schema_version = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @param string $var - * @return $this - */ - public function setSchemaVersion($var) - { - GPBUtil::checkString($var, True); - $this->schema_version = $var; - - return $this; - } - - /** - * Optional. Targets to send notifications to when a threshold is exceeded. - * This is in addition to default recipients who have billing account IAM - * roles. The value is the full REST resource name of a monitoring - * notification channel with the form - * `projects/{project_id}/notificationChannels/{channel_id}`. A maximum of 5 - * channels are allowed. See - * https://cloud.google.com/billing/docs/how-to/budgets-notification-recipients - * for more details. - * - * Generated from protobuf field repeated string monitoring_notification_channels = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getMonitoringNotificationChannels() - { - return $this->monitoring_notification_channels; - } - - /** - * Optional. Targets to send notifications to when a threshold is exceeded. - * This is in addition to default recipients who have billing account IAM - * roles. The value is the full REST resource name of a monitoring - * notification channel with the form - * `projects/{project_id}/notificationChannels/{channel_id}`. A maximum of 5 - * channels are allowed. See - * https://cloud.google.com/billing/docs/how-to/budgets-notification-recipients - * for more details. - * - * Generated from protobuf field repeated string monitoring_notification_channels = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setMonitoringNotificationChannels($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->monitoring_notification_channels = $arr; - - return $this; - } - - /** - * Optional. When set to true, disables default notifications sent when a - * threshold is exceeded. Default notifications are sent to those with Billing - * Account Administrator and Billing Account User IAM roles for the target - * account. - * - * Generated from protobuf field bool disable_default_iam_recipients = 4 [(.google.api.field_behavior) = OPTIONAL]; - * @return bool - */ - public function getDisableDefaultIamRecipients() - { - return $this->disable_default_iam_recipients; - } - - /** - * Optional. When set to true, disables default notifications sent when a - * threshold is exceeded. Default notifications are sent to those with Billing - * Account Administrator and Billing Account User IAM roles for the target - * account. - * - * Generated from protobuf field bool disable_default_iam_recipients = 4 [(.google.api.field_behavior) = OPTIONAL]; - * @param bool $var - * @return $this - */ - public function setDisableDefaultIamRecipients($var) - { - GPBUtil::checkBool($var); - $this->disable_default_iam_recipients = $var; - - return $this; - } - - /** - * Optional. When set to true, and when the budget has a single project - * configured, notifications will be sent to project level recipients of that - * project. This field will be ignored if the budget has multiple or no - * project configured. - * Currently, project level recipients are the users with `Owner` role on a - * cloud project. - * - * Generated from protobuf field bool enable_project_level_recipients = 5 [(.google.api.field_behavior) = OPTIONAL]; - * @return bool - */ - public function getEnableProjectLevelRecipients() - { - return $this->enable_project_level_recipients; - } - - /** - * Optional. When set to true, and when the budget has a single project - * configured, notifications will be sent to project level recipients of that - * project. This field will be ignored if the budget has multiple or no - * project configured. - * Currently, project level recipients are the users with `Owner` role on a - * cloud project. - * - * Generated from protobuf field bool enable_project_level_recipients = 5 [(.google.api.field_behavior) = OPTIONAL]; - * @param bool $var - * @return $this - */ - public function setEnableProjectLevelRecipients($var) - { - GPBUtil::checkBool($var); - $this->enable_project_level_recipients = $var; - - return $this; - } - -} - diff --git a/BillingBudgets/src/V1beta1/Budget.php b/BillingBudgets/src/V1beta1/Budget.php deleted file mode 100644 index ca3ba1df52a2..000000000000 --- a/BillingBudgets/src/V1beta1/Budget.php +++ /dev/null @@ -1,349 +0,0 @@ -google.cloud.billing.budgets.v1beta1.Budget - */ -class Budget extends \Google\Protobuf\Internal\Message -{ - /** - * Output only. Resource name of the budget. - * The resource name implies the scope of a budget. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $name = ''; - /** - * User data for display name in UI. - * Validation: <= 60 chars. - * - * Generated from protobuf field string display_name = 2; - */ - private $display_name = ''; - /** - * Optional. Filters that define which resources are used to compute the - * actual spend against the budget amount, such as projects, services, and the - * budget's time period, as well as other filters. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Filter budget_filter = 3 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $budget_filter = null; - /** - * Required. Budgeted amount. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.BudgetAmount amount = 4 [(.google.api.field_behavior) = REQUIRED]; - */ - private $amount = null; - /** - * Optional. Rules that trigger alerts (notifications of thresholds - * being crossed) when spend exceeds the specified percentages of the budget. - * Optional for `pubsubTopic` notifications. - * Required if using email notifications. - * - * Generated from protobuf field repeated .google.cloud.billing.budgets.v1beta1.ThresholdRule threshold_rules = 5 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $threshold_rules; - /** - * Optional. Rules to apply to notifications sent based on budget spend and - * thresholds. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.AllUpdatesRule all_updates_rule = 6 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $all_updates_rule = null; - /** - * Optional. Etag to validate that the object is unchanged for a - * read-modify-write operation. - * An empty etag will cause an update to overwrite other changes. - * - * Generated from protobuf field string etag = 7 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $etag = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Output only. Resource name of the budget. - * The resource name implies the scope of a budget. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * @type string $display_name - * User data for display name in UI. - * Validation: <= 60 chars. - * @type \Google\Cloud\Billing\Budgets\V1beta1\Filter $budget_filter - * Optional. Filters that define which resources are used to compute the - * actual spend against the budget amount, such as projects, services, and the - * budget's time period, as well as other filters. - * @type \Google\Cloud\Billing\Budgets\V1beta1\BudgetAmount $amount - * Required. Budgeted amount. - * @type array<\Google\Cloud\Billing\Budgets\V1beta1\ThresholdRule>|\Google\Protobuf\Internal\RepeatedField $threshold_rules - * Optional. Rules that trigger alerts (notifications of thresholds - * being crossed) when spend exceeds the specified percentages of the budget. - * Optional for `pubsubTopic` notifications. - * Required if using email notifications. - * @type \Google\Cloud\Billing\Budgets\V1beta1\AllUpdatesRule $all_updates_rule - * Optional. Rules to apply to notifications sent based on budget spend and - * thresholds. - * @type string $etag - * Optional. Etag to validate that the object is unchanged for a - * read-modify-write operation. - * An empty etag will cause an update to overwrite other changes. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetModel::initOnce(); - parent::__construct($data); - } - - /** - * Output only. Resource name of the budget. - * The resource name implies the scope of a budget. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Output only. Resource name of the budget. - * The resource name implies the scope of a budget. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * 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; - } - - /** - * User data for display name in UI. - * Validation: <= 60 chars. - * - * Generated from protobuf field string display_name = 2; - * @return string - */ - public function getDisplayName() - { - return $this->display_name; - } - - /** - * User data for display name in UI. - * Validation: <= 60 chars. - * - * Generated from protobuf field string display_name = 2; - * @param string $var - * @return $this - */ - public function setDisplayName($var) - { - GPBUtil::checkString($var, True); - $this->display_name = $var; - - return $this; - } - - /** - * Optional. Filters that define which resources are used to compute the - * actual spend against the budget amount, such as projects, services, and the - * budget's time period, as well as other filters. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Filter budget_filter = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Cloud\Billing\Budgets\V1beta1\Filter|null - */ - public function getBudgetFilter() - { - return $this->budget_filter; - } - - public function hasBudgetFilter() - { - return isset($this->budget_filter); - } - - public function clearBudgetFilter() - { - unset($this->budget_filter); - } - - /** - * Optional. Filters that define which resources are used to compute the - * actual spend against the budget amount, such as projects, services, and the - * budget's time period, as well as other filters. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Filter budget_filter = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @param \Google\Cloud\Billing\Budgets\V1beta1\Filter $var - * @return $this - */ - public function setBudgetFilter($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Billing\Budgets\V1beta1\Filter::class); - $this->budget_filter = $var; - - return $this; - } - - /** - * Required. Budgeted amount. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.BudgetAmount amount = 4 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Billing\Budgets\V1beta1\BudgetAmount|null - */ - public function getAmount() - { - return $this->amount; - } - - public function hasAmount() - { - return isset($this->amount); - } - - public function clearAmount() - { - unset($this->amount); - } - - /** - * Required. Budgeted amount. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.BudgetAmount amount = 4 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Billing\Budgets\V1beta1\BudgetAmount $var - * @return $this - */ - public function setAmount($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Billing\Budgets\V1beta1\BudgetAmount::class); - $this->amount = $var; - - return $this; - } - - /** - * Optional. Rules that trigger alerts (notifications of thresholds - * being crossed) when spend exceeds the specified percentages of the budget. - * Optional for `pubsubTopic` notifications. - * Required if using email notifications. - * - * Generated from protobuf field repeated .google.cloud.billing.budgets.v1beta1.ThresholdRule threshold_rules = 5 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getThresholdRules() - { - return $this->threshold_rules; - } - - /** - * Optional. Rules that trigger alerts (notifications of thresholds - * being crossed) when spend exceeds the specified percentages of the budget. - * Optional for `pubsubTopic` notifications. - * Required if using email notifications. - * - * Generated from protobuf field repeated .google.cloud.billing.budgets.v1beta1.ThresholdRule threshold_rules = 5 [(.google.api.field_behavior) = OPTIONAL]; - * @param array<\Google\Cloud\Billing\Budgets\V1beta1\ThresholdRule>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setThresholdRules($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Billing\Budgets\V1beta1\ThresholdRule::class); - $this->threshold_rules = $arr; - - return $this; - } - - /** - * Optional. Rules to apply to notifications sent based on budget spend and - * thresholds. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.AllUpdatesRule all_updates_rule = 6 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Cloud\Billing\Budgets\V1beta1\AllUpdatesRule|null - */ - public function getAllUpdatesRule() - { - return $this->all_updates_rule; - } - - public function hasAllUpdatesRule() - { - return isset($this->all_updates_rule); - } - - public function clearAllUpdatesRule() - { - unset($this->all_updates_rule); - } - - /** - * Optional. Rules to apply to notifications sent based on budget spend and - * thresholds. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.AllUpdatesRule all_updates_rule = 6 [(.google.api.field_behavior) = OPTIONAL]; - * @param \Google\Cloud\Billing\Budgets\V1beta1\AllUpdatesRule $var - * @return $this - */ - public function setAllUpdatesRule($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Billing\Budgets\V1beta1\AllUpdatesRule::class); - $this->all_updates_rule = $var; - - return $this; - } - - /** - * Optional. Etag to validate that the object is unchanged for a - * read-modify-write operation. - * An empty etag will cause an update to overwrite other changes. - * - * Generated from protobuf field string etag = 7 [(.google.api.field_behavior) = OPTIONAL]; - * @return string - */ - public function getEtag() - { - return $this->etag; - } - - /** - * Optional. Etag to validate that the object is unchanged for a - * read-modify-write operation. - * An empty etag will cause an update to overwrite other changes. - * - * Generated from protobuf field string etag = 7 [(.google.api.field_behavior) = OPTIONAL]; - * @param string $var - * @return $this - */ - public function setEtag($var) - { - GPBUtil::checkString($var, True); - $this->etag = $var; - - return $this; - } - -} - diff --git a/BillingBudgets/src/V1beta1/BudgetAmount.php b/BillingBudgets/src/V1beta1/BudgetAmount.php deleted file mode 100644 index 98c628ad8d81..000000000000 --- a/BillingBudgets/src/V1beta1/BudgetAmount.php +++ /dev/null @@ -1,132 +0,0 @@ -google.cloud.billing.budgets.v1beta1.BudgetAmount - */ -class BudgetAmount extends \Google\Protobuf\Internal\Message -{ - protected $budget_amount; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Type\Money $specified_amount - * A specified amount to use as the budget. - * `currency_code` is optional. If specified when creating a budget, it must - * match the currency of the billing account. If specified when updating a - * budget, it must match the currency_code of the existing budget. - * The `currency_code` is provided on output. - * @type \Google\Cloud\Billing\Budgets\V1beta1\LastPeriodAmount $last_period_amount - * Use the last period's actual spend as the budget for the present period. - * LastPeriodAmount can only be set when the budget's time period is a - * [Filter.calendar_period][google.cloud.billing.budgets.v1beta1.Filter.calendar_period]. - * It cannot be set in combination with - * [Filter.custom_period][google.cloud.billing.budgets.v1beta1.Filter.custom_period]. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetModel::initOnce(); - parent::__construct($data); - } - - /** - * A specified amount to use as the budget. - * `currency_code` is optional. If specified when creating a budget, it must - * match the currency of the billing account. If specified when updating a - * budget, it must match the currency_code of the existing budget. - * The `currency_code` is provided on output. - * - * Generated from protobuf field .google.type.Money specified_amount = 1; - * @return \Google\Type\Money|null - */ - public function getSpecifiedAmount() - { - return $this->readOneof(1); - } - - public function hasSpecifiedAmount() - { - return $this->hasOneof(1); - } - - /** - * A specified amount to use as the budget. - * `currency_code` is optional. If specified when creating a budget, it must - * match the currency of the billing account. If specified when updating a - * budget, it must match the currency_code of the existing budget. - * The `currency_code` is provided on output. - * - * Generated from protobuf field .google.type.Money specified_amount = 1; - * @param \Google\Type\Money $var - * @return $this - */ - public function setSpecifiedAmount($var) - { - GPBUtil::checkMessage($var, \Google\Type\Money::class); - $this->writeOneof(1, $var); - - return $this; - } - - /** - * Use the last period's actual spend as the budget for the present period. - * LastPeriodAmount can only be set when the budget's time period is a - * [Filter.calendar_period][google.cloud.billing.budgets.v1beta1.Filter.calendar_period]. - * It cannot be set in combination with - * [Filter.custom_period][google.cloud.billing.budgets.v1beta1.Filter.custom_period]. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.LastPeriodAmount last_period_amount = 2; - * @return \Google\Cloud\Billing\Budgets\V1beta1\LastPeriodAmount|null - */ - public function getLastPeriodAmount() - { - return $this->readOneof(2); - } - - public function hasLastPeriodAmount() - { - return $this->hasOneof(2); - } - - /** - * Use the last period's actual spend as the budget for the present period. - * LastPeriodAmount can only be set when the budget's time period is a - * [Filter.calendar_period][google.cloud.billing.budgets.v1beta1.Filter.calendar_period]. - * It cannot be set in combination with - * [Filter.custom_period][google.cloud.billing.budgets.v1beta1.Filter.custom_period]. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.LastPeriodAmount last_period_amount = 2; - * @param \Google\Cloud\Billing\Budgets\V1beta1\LastPeriodAmount $var - * @return $this - */ - public function setLastPeriodAmount($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Billing\Budgets\V1beta1\LastPeriodAmount::class); - $this->writeOneof(2, $var); - - return $this; - } - - /** - * @return string - */ - public function getBudgetAmount() - { - return $this->whichOneof("budget_amount"); - } - -} - diff --git a/BillingBudgets/src/V1beta1/BudgetServiceClient.php b/BillingBudgets/src/V1beta1/BudgetServiceClient.php deleted file mode 100644 index 706696b49d30..000000000000 --- a/BillingBudgets/src/V1beta1/BudgetServiceClient.php +++ /dev/null @@ -1,36 +0,0 @@ -google.cloud.billing.budgets.v1beta1.CalendarPeriod - */ -class CalendarPeriod -{ - /** - * Calendar period is unset. This is the default if the budget is for a - * custom time period (CustomPeriod). - * - * Generated from protobuf enum CALENDAR_PERIOD_UNSPECIFIED = 0; - */ - const CALENDAR_PERIOD_UNSPECIFIED = 0; - /** - * A month. Month starts on the first day of each month, such as January 1, - * February 1, March 1, and so on. - * - * Generated from protobuf enum MONTH = 1; - */ - const MONTH = 1; - /** - * A quarter. Quarters start on dates January 1, April 1, July 1, and October - * 1 of each year. - * - * Generated from protobuf enum QUARTER = 2; - */ - const QUARTER = 2; - /** - * A year. Year starts on January 1. - * - * Generated from protobuf enum YEAR = 3; - */ - const YEAR = 3; - - private static $valueToName = [ - self::CALENDAR_PERIOD_UNSPECIFIED => 'CALENDAR_PERIOD_UNSPECIFIED', - self::MONTH => 'MONTH', - self::QUARTER => 'QUARTER', - self::YEAR => 'YEAR', - ]; - - 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/BillingBudgets/src/V1beta1/CreateBudgetRequest.php b/BillingBudgets/src/V1beta1/CreateBudgetRequest.php deleted file mode 100644 index e41ff00ec7ad..000000000000 --- a/BillingBudgets/src/V1beta1/CreateBudgetRequest.php +++ /dev/null @@ -1,115 +0,0 @@ -google.cloud.billing.budgets.v1beta1.CreateBudgetRequest - */ -class CreateBudgetRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The name of the billing account to create the budget in. Values - * are of the form `billingAccounts/{billingAccountId}`. - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $parent = ''; - /** - * Required. Budget to create. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Budget budget = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $budget = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * Required. The name of the billing account to create the budget in. Values - * are of the form `billingAccounts/{billingAccountId}`. - * @type \Google\Cloud\Billing\Budgets\V1beta1\Budget $budget - * Required. Budget to create. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The name of the billing account to create the budget in. Values - * are of the form `billingAccounts/{billingAccountId}`. - * - * 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 billing account to create the budget in. Values - * are of the form `billingAccounts/{billingAccountId}`. - * - * 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. Budget to create. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Budget budget = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Billing\Budgets\V1beta1\Budget|null - */ - public function getBudget() - { - return $this->budget; - } - - public function hasBudget() - { - return isset($this->budget); - } - - public function clearBudget() - { - unset($this->budget); - } - - /** - * Required. Budget to create. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Budget budget = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Billing\Budgets\V1beta1\Budget $var - * @return $this - */ - public function setBudget($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Billing\Budgets\V1beta1\Budget::class); - $this->budget = $var; - - return $this; - } - -} - diff --git a/BillingBudgets/src/V1beta1/CustomPeriod.php b/BillingBudgets/src/V1beta1/CustomPeriod.php deleted file mode 100644 index 9e4fda2b85e3..000000000000 --- a/BillingBudgets/src/V1beta1/CustomPeriod.php +++ /dev/null @@ -1,129 +0,0 @@ -google.cloud.billing.budgets.v1beta1.CustomPeriod - */ -class CustomPeriod extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The start date must be after January 1, 2017. - * - * Generated from protobuf field .google.type.Date start_date = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $start_date = null; - /** - * Optional. The end date of the time period. Budgets with elapsed end date - * won't be processed. If unset, specifies to track all usage incurred since - * the start_date. - * - * Generated from protobuf field .google.type.Date end_date = 2 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $end_date = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Type\Date $start_date - * Required. The start date must be after January 1, 2017. - * @type \Google\Type\Date $end_date - * Optional. The end date of the time period. Budgets with elapsed end date - * won't be processed. If unset, specifies to track all usage incurred since - * the start_date. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetModel::initOnce(); - parent::__construct($data); - } - - /** - * Required. The start date must be after January 1, 2017. - * - * Generated from protobuf field .google.type.Date start_date = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Type\Date|null - */ - public function getStartDate() - { - return $this->start_date; - } - - public function hasStartDate() - { - return isset($this->start_date); - } - - public function clearStartDate() - { - unset($this->start_date); - } - - /** - * Required. The start date must be after January 1, 2017. - * - * Generated from protobuf field .google.type.Date start_date = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Type\Date $var - * @return $this - */ - public function setStartDate($var) - { - GPBUtil::checkMessage($var, \Google\Type\Date::class); - $this->start_date = $var; - - return $this; - } - - /** - * Optional. The end date of the time period. Budgets with elapsed end date - * won't be processed. If unset, specifies to track all usage incurred since - * the start_date. - * - * Generated from protobuf field .google.type.Date end_date = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Type\Date|null - */ - public function getEndDate() - { - return $this->end_date; - } - - public function hasEndDate() - { - return isset($this->end_date); - } - - public function clearEndDate() - { - unset($this->end_date); - } - - /** - * Optional. The end date of the time period. Budgets with elapsed end date - * won't be processed. If unset, specifies to track all usage incurred since - * the start_date. - * - * Generated from protobuf field .google.type.Date end_date = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @param \Google\Type\Date $var - * @return $this - */ - public function setEndDate($var) - { - GPBUtil::checkMessage($var, \Google\Type\Date::class); - $this->end_date = $var; - - return $this; - } - -} - diff --git a/BillingBudgets/src/V1beta1/DeleteBudgetRequest.php b/BillingBudgets/src/V1beta1/DeleteBudgetRequest.php deleted file mode 100644 index b257539f46fb..000000000000 --- a/BillingBudgets/src/V1beta1/DeleteBudgetRequest.php +++ /dev/null @@ -1,71 +0,0 @@ -google.cloud.billing.budgets.v1beta1.DeleteBudgetRequest - */ -class DeleteBudgetRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Name of the budget to delete. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. Name of the budget to delete. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Name of the budget to delete. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * 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. Name of the budget to delete. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * 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/BillingBudgets/src/V1beta1/Filter.php b/BillingBudgets/src/V1beta1/Filter.php deleted file mode 100644 index 331d174f9501..000000000000 --- a/BillingBudgets/src/V1beta1/Filter.php +++ /dev/null @@ -1,496 +0,0 @@ -google.cloud.billing.budgets.v1beta1.Filter - */ -class Filter extends \Google\Protobuf\Internal\Message -{ - /** - * Optional. A set of projects of the form `projects/{project}`, - * specifying that usage from only this set of projects should be - * included in the budget. If omitted, the report will include all usage for - * the billing account, regardless of which project the usage occurred on. - * - * Generated from protobuf field repeated string projects = 1 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $projects; - /** - * Optional. A set of folder and organization names of the form - * `folders/{folderId}` or `organizations/{organizationId}`, specifying that - * usage from only this set of folders and organizations should be included in - * the budget. If omitted, the budget includes all usage that the billing - * account pays for. If the folder or organization contains projects that are - * paid for by a different Cloud Billing account, the budget *doesn't* apply - * to those projects. - * - * Generated from protobuf field repeated string resource_ancestors = 2 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $resource_ancestors; - /** - * Optional. If - * [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] - * is INCLUDE_SPECIFIED_CREDITS, this is a list of credit types to be - * subtracted from gross cost to determine the spend for threshold - * calculations. See [a list of acceptable credit type - * values](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type). - * If - * [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] - * is **not** INCLUDE_SPECIFIED_CREDITS, this field must be empty. - * - * Generated from protobuf field repeated string credit_types = 7 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $credit_types; - /** - * Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatment credit_types_treatment = 4 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $credit_types_treatment = 0; - /** - * Optional. A set of services of the form `services/{service_id}`, - * specifying that usage from only this set of services should be - * included in the budget. If omitted, the report will include usage for - * all the services. - * The service names are available through the Catalog API: - * https://cloud.google.com/billing/v1/how-tos/catalog-api. - * - * Generated from protobuf field repeated string services = 3 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $services; - /** - * Optional. A set of subaccounts of the form `billingAccounts/{account_id}`, - * specifying that usage from only this set of subaccounts should be included - * in the budget. If a subaccount is set to the name of the parent account, - * usage from the parent account will be included. If omitted, the - * report will include usage from the parent account and all - * subaccounts, if they exist. - * - * Generated from protobuf field repeated string subaccounts = 5 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $subaccounts; - /** - * Optional. A single label and value pair specifying that usage from only - * this set of labeled resources should be included in the budget. If omitted, - * the report will include all labeled and unlabeled usage. - * An object containing a single `"key": value` pair. Example: `{ "name": - * "wrench" }`. - * _Currently, multiple entries or multiple values per entry are not - * allowed._ - * - * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $labels; - protected $usage_period; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array|\Google\Protobuf\Internal\RepeatedField $projects - * Optional. A set of projects of the form `projects/{project}`, - * specifying that usage from only this set of projects should be - * included in the budget. If omitted, the report will include all usage for - * the billing account, regardless of which project the usage occurred on. - * @type array|\Google\Protobuf\Internal\RepeatedField $resource_ancestors - * Optional. A set of folder and organization names of the form - * `folders/{folderId}` or `organizations/{organizationId}`, specifying that - * usage from only this set of folders and organizations should be included in - * the budget. If omitted, the budget includes all usage that the billing - * account pays for. If the folder or organization contains projects that are - * paid for by a different Cloud Billing account, the budget *doesn't* apply - * to those projects. - * @type array|\Google\Protobuf\Internal\RepeatedField $credit_types - * Optional. If - * [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] - * is INCLUDE_SPECIFIED_CREDITS, this is a list of credit types to be - * subtracted from gross cost to determine the spend for threshold - * calculations. See [a list of acceptable credit type - * values](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type). - * If - * [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] - * is **not** INCLUDE_SPECIFIED_CREDITS, this field must be empty. - * @type int $credit_types_treatment - * Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`. - * @type array|\Google\Protobuf\Internal\RepeatedField $services - * Optional. A set of services of the form `services/{service_id}`, - * specifying that usage from only this set of services should be - * included in the budget. If omitted, the report will include usage for - * all the services. - * The service names are available through the Catalog API: - * https://cloud.google.com/billing/v1/how-tos/catalog-api. - * @type array|\Google\Protobuf\Internal\RepeatedField $subaccounts - * Optional. A set of subaccounts of the form `billingAccounts/{account_id}`, - * specifying that usage from only this set of subaccounts should be included - * in the budget. If a subaccount is set to the name of the parent account, - * usage from the parent account will be included. If omitted, the - * report will include usage from the parent account and all - * subaccounts, if they exist. - * @type array|\Google\Protobuf\Internal\MapField $labels - * Optional. A single label and value pair specifying that usage from only - * this set of labeled resources should be included in the budget. If omitted, - * the report will include all labeled and unlabeled usage. - * An object containing a single `"key": value` pair. Example: `{ "name": - * "wrench" }`. - * _Currently, multiple entries or multiple values per entry are not - * allowed._ - * @type int $calendar_period - * Optional. Specifies to track usage for recurring calendar period. - * For example, assume that CalendarPeriod.QUARTER is set. The budget will - * track usage from April 1 to June 30, when the current calendar month is - * April, May, June. After that, it will track usage from July 1 to - * September 30 when the current calendar month is July, August, September, - * so on. - * @type \Google\Cloud\Billing\Budgets\V1beta1\CustomPeriod $custom_period - * Optional. Specifies to track usage from any start date (required) to any - * end date (optional). This time period is static, it does not recur. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetModel::initOnce(); - parent::__construct($data); - } - - /** - * Optional. A set of projects of the form `projects/{project}`, - * specifying that usage from only this set of projects should be - * included in the budget. If omitted, the report will include all usage for - * the billing account, regardless of which project the usage occurred on. - * - * Generated from protobuf field repeated string projects = 1 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getProjects() - { - return $this->projects; - } - - /** - * Optional. A set of projects of the form `projects/{project}`, - * specifying that usage from only this set of projects should be - * included in the budget. If omitted, the report will include all usage for - * the billing account, regardless of which project the usage occurred on. - * - * Generated from protobuf field repeated string projects = 1 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setProjects($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->projects = $arr; - - return $this; - } - - /** - * Optional. A set of folder and organization names of the form - * `folders/{folderId}` or `organizations/{organizationId}`, specifying that - * usage from only this set of folders and organizations should be included in - * the budget. If omitted, the budget includes all usage that the billing - * account pays for. If the folder or organization contains projects that are - * paid for by a different Cloud Billing account, the budget *doesn't* apply - * to those projects. - * - * Generated from protobuf field repeated string resource_ancestors = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getResourceAncestors() - { - return $this->resource_ancestors; - } - - /** - * Optional. A set of folder and organization names of the form - * `folders/{folderId}` or `organizations/{organizationId}`, specifying that - * usage from only this set of folders and organizations should be included in - * the budget. If omitted, the budget includes all usage that the billing - * account pays for. If the folder or organization contains projects that are - * paid for by a different Cloud Billing account, the budget *doesn't* apply - * to those projects. - * - * Generated from protobuf field repeated string resource_ancestors = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setResourceAncestors($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->resource_ancestors = $arr; - - return $this; - } - - /** - * Optional. If - * [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] - * is INCLUDE_SPECIFIED_CREDITS, this is a list of credit types to be - * subtracted from gross cost to determine the spend for threshold - * calculations. See [a list of acceptable credit type - * values](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type). - * If - * [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] - * is **not** INCLUDE_SPECIFIED_CREDITS, this field must be empty. - * - * Generated from protobuf field repeated string credit_types = 7 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getCreditTypes() - { - return $this->credit_types; - } - - /** - * Optional. If - * [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] - * is INCLUDE_SPECIFIED_CREDITS, this is a list of credit types to be - * subtracted from gross cost to determine the spend for threshold - * calculations. See [a list of acceptable credit type - * values](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type). - * If - * [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] - * is **not** INCLUDE_SPECIFIED_CREDITS, this field must be empty. - * - * Generated from protobuf field repeated string credit_types = 7 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setCreditTypes($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->credit_types = $arr; - - return $this; - } - - /** - * Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatment credit_types_treatment = 4 [(.google.api.field_behavior) = OPTIONAL]; - * @return int - */ - public function getCreditTypesTreatment() - { - return $this->credit_types_treatment; - } - - /** - * Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatment credit_types_treatment = 4 [(.google.api.field_behavior) = OPTIONAL]; - * @param int $var - * @return $this - */ - public function setCreditTypesTreatment($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Billing\Budgets\V1beta1\Filter\CreditTypesTreatment::class); - $this->credit_types_treatment = $var; - - return $this; - } - - /** - * Optional. A set of services of the form `services/{service_id}`, - * specifying that usage from only this set of services should be - * included in the budget. If omitted, the report will include usage for - * all the services. - * The service names are available through the Catalog API: - * https://cloud.google.com/billing/v1/how-tos/catalog-api. - * - * Generated from protobuf field repeated string services = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getServices() - { - return $this->services; - } - - /** - * Optional. A set of services of the form `services/{service_id}`, - * specifying that usage from only this set of services should be - * included in the budget. If omitted, the report will include usage for - * all the services. - * The service names are available through the Catalog API: - * https://cloud.google.com/billing/v1/how-tos/catalog-api. - * - * Generated from protobuf field repeated string services = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setServices($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->services = $arr; - - return $this; - } - - /** - * Optional. A set of subaccounts of the form `billingAccounts/{account_id}`, - * specifying that usage from only this set of subaccounts should be included - * in the budget. If a subaccount is set to the name of the parent account, - * usage from the parent account will be included. If omitted, the - * report will include usage from the parent account and all - * subaccounts, if they exist. - * - * Generated from protobuf field repeated string subaccounts = 5 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getSubaccounts() - { - return $this->subaccounts; - } - - /** - * Optional. A set of subaccounts of the form `billingAccounts/{account_id}`, - * specifying that usage from only this set of subaccounts should be included - * in the budget. If a subaccount is set to the name of the parent account, - * usage from the parent account will be included. If omitted, the - * report will include usage from the parent account and all - * subaccounts, if they exist. - * - * Generated from protobuf field repeated string subaccounts = 5 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setSubaccounts($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->subaccounts = $arr; - - return $this; - } - - /** - * Optional. A single label and value pair specifying that usage from only - * this set of labeled resources should be included in the budget. If omitted, - * the report will include all labeled and unlabeled usage. - * An object containing a single `"key": value` pair. Example: `{ "name": - * "wrench" }`. - * _Currently, multiple entries or multiple values per entry are not - * allowed._ - * - * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\MapField - */ - public function getLabels() - { - return $this->labels; - } - - /** - * Optional. A single label and value pair specifying that usage from only - * this set of labeled resources should be included in the budget. If omitted, - * the report will include all labeled and unlabeled usage. - * An object containing a single `"key": value` pair. Example: `{ "name": - * "wrench" }`. - * _Currently, multiple entries or multiple values per entry are not - * allowed._ - * - * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\MapField $var - * @return $this - */ - public function setLabels($var) - { - $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\ListValue::class); - $this->labels = $arr; - - return $this; - } - - /** - * Optional. Specifies to track usage for recurring calendar period. - * For example, assume that CalendarPeriod.QUARTER is set. The budget will - * track usage from April 1 to June 30, when the current calendar month is - * April, May, June. After that, it will track usage from July 1 to - * September 30 when the current calendar month is July, August, September, - * so on. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.CalendarPeriod calendar_period = 8 [(.google.api.field_behavior) = OPTIONAL]; - * @return int - */ - public function getCalendarPeriod() - { - return $this->readOneof(8); - } - - public function hasCalendarPeriod() - { - return $this->hasOneof(8); - } - - /** - * Optional. Specifies to track usage for recurring calendar period. - * For example, assume that CalendarPeriod.QUARTER is set. The budget will - * track usage from April 1 to June 30, when the current calendar month is - * April, May, June. After that, it will track usage from July 1 to - * September 30 when the current calendar month is July, August, September, - * so on. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.CalendarPeriod calendar_period = 8 [(.google.api.field_behavior) = OPTIONAL]; - * @param int $var - * @return $this - */ - public function setCalendarPeriod($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Billing\Budgets\V1beta1\CalendarPeriod::class); - $this->writeOneof(8, $var); - - return $this; - } - - /** - * Optional. Specifies to track usage from any start date (required) to any - * end date (optional). This time period is static, it does not recur. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.CustomPeriod custom_period = 9 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Cloud\Billing\Budgets\V1beta1\CustomPeriod|null - */ - public function getCustomPeriod() - { - return $this->readOneof(9); - } - - public function hasCustomPeriod() - { - return $this->hasOneof(9); - } - - /** - * Optional. Specifies to track usage from any start date (required) to any - * end date (optional). This time period is static, it does not recur. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.CustomPeriod custom_period = 9 [(.google.api.field_behavior) = OPTIONAL]; - * @param \Google\Cloud\Billing\Budgets\V1beta1\CustomPeriod $var - * @return $this - */ - public function setCustomPeriod($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Billing\Budgets\V1beta1\CustomPeriod::class); - $this->writeOneof(9, $var); - - return $this; - } - - /** - * @return string - */ - public function getUsagePeriod() - { - return $this->whichOneof("usage_period"); - } - -} - diff --git a/BillingBudgets/src/V1beta1/Filter/CreditTypesTreatment.php b/BillingBudgets/src/V1beta1/Filter/CreditTypesTreatment.php deleted file mode 100644 index b13efe61e5b5..000000000000 --- a/BillingBudgets/src/V1beta1/Filter/CreditTypesTreatment.php +++ /dev/null @@ -1,76 +0,0 @@ -google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatment - */ -class CreditTypesTreatment -{ - /** - * Generated from protobuf enum CREDIT_TYPES_TREATMENT_UNSPECIFIED = 0; - */ - const CREDIT_TYPES_TREATMENT_UNSPECIFIED = 0; - /** - * All types of credit are subtracted from the gross cost to determine the - * spend for threshold calculations. - * - * Generated from protobuf enum INCLUDE_ALL_CREDITS = 1; - */ - const INCLUDE_ALL_CREDITS = 1; - /** - * All types of credit are added to the net cost to determine the spend for - * threshold calculations. - * - * Generated from protobuf enum EXCLUDE_ALL_CREDITS = 2; - */ - const EXCLUDE_ALL_CREDITS = 2; - /** - * [Credit - * types](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type) - * specified in the credit_types field are subtracted from the - * gross cost to determine the spend for threshold calculations. - * - * Generated from protobuf enum INCLUDE_SPECIFIED_CREDITS = 3; - */ - const INCLUDE_SPECIFIED_CREDITS = 3; - - private static $valueToName = [ - self::CREDIT_TYPES_TREATMENT_UNSPECIFIED => 'CREDIT_TYPES_TREATMENT_UNSPECIFIED', - self::INCLUDE_ALL_CREDITS => 'INCLUDE_ALL_CREDITS', - self::EXCLUDE_ALL_CREDITS => 'EXCLUDE_ALL_CREDITS', - self::INCLUDE_SPECIFIED_CREDITS => 'INCLUDE_SPECIFIED_CREDITS', - ]; - - 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/BillingBudgets/src/V1beta1/Gapic/BudgetServiceGapicClient.php b/BillingBudgets/src/V1beta1/Gapic/BudgetServiceGapicClient.php deleted file mode 100644 index 0014e25b356a..000000000000 --- a/BillingBudgets/src/V1beta1/Gapic/BudgetServiceGapicClient.php +++ /dev/null @@ -1,578 +0,0 @@ -billingAccountName('[BILLING_ACCOUNT]'); - * $budget = new Budget(); - * $response = $budgetServiceClient->createBudget($formattedParent, $budget); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * Many parameters require resource names to be formatted in a particular way. To - * assist with these names, this class includes a format method for each type of - * name, and additionally a parseName method to extract the individual identifiers - * contained within formatted names that are returned by the API. - * - * @experimental - * - * @deprecated This class will be removed in the next major version update. - */ -class BudgetServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.billing.budgets.v1beta1.BudgetService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'billingbudgets.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'billingbudgets.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-billing', - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $billingAccountNameTemplate; - - private static $budgetNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getBillingAccountNameTemplate() - { - if (self::$billingAccountNameTemplate == null) { - self::$billingAccountNameTemplate = new PathTemplate('billingAccounts/{billing_account}'); - } - - return self::$billingAccountNameTemplate; - } - - private static function getBudgetNameTemplate() - { - if (self::$budgetNameTemplate == null) { - self::$budgetNameTemplate = new PathTemplate('billingAccounts/{billing_account}/budgets/{budget}'); - } - - return self::$budgetNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'billingAccount' => self::getBillingAccountNameTemplate(), - 'budget' => self::getBudgetNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account resource. - * - * @param string $billingAccount - * - * @return string The formatted billing_account resource. - * - * @experimental - */ - public static function billingAccountName($billingAccount) - { - return self::getBillingAccountNameTemplate()->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. - * - * @experimental - */ - public static function budgetName($billingAccount, $budget) - { - return self::getBudgetNameTemplate()->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. - * - * @experimental - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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 - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * 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. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $formattedParent = $budgetServiceClient->billingAccountName('[BILLING_ACCOUNT]'); - * $budget = new Budget(); - * $response = $budgetServiceClient->createBudget($formattedParent, $budget); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the billing account to create the budget in. Values - * are of the form `billingAccounts/{billingAccountId}`. - * @param Budget $budget Required. Budget to create. - * @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\Billing\Budgets\V1beta1\Budget - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function createBudget($parent, $budget, array $optionalArgs = []) - { - $request = new CreateBudgetRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setBudget($budget); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateBudget', Budget::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes a budget. Returns successfully if already deleted. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $formattedName = $budgetServiceClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - * $budgetServiceClient->deleteBudget($formattedName); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the budget to delete. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * @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 - * - * @experimental - */ - public function deleteBudget($name, array $optionalArgs = []) - { - $request = new DeleteBudgetRequest(); - $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('DeleteBudget', GPBEmpty::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $formattedName = $budgetServiceClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - * $response = $budgetServiceClient->getBudget($formattedName); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of budget to get. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * @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\Billing\Budgets\V1beta1\Budget - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function getBudget($name, array $optionalArgs = []) - { - $request = new GetBudgetRequest(); - $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('GetBudget', Budget::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $formattedParent = $budgetServiceClient->billingAccountName('[BILLING_ACCOUNT]'); - * // Iterate over pages of elements - * $pagedResponse = $budgetServiceClient->listBudgets($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $budgetServiceClient->listBudgets($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Name of billing account to list budgets under. Values - * are of the form `billingAccounts/{billingAccountId}`. - * @param array $optionalArgs { - * Optional. - * - * @type string $scope - * Optional. Set the scope of the budgets to be returned, in the format of the - * resource name. The scope of a budget is the cost that it tracks, such as - * costs for a single project, or the costs for all projects in a folder. Only - * project scope (in the format of "projects/project-id" or "projects/123") is - * supported in this field. When this field is set to a project's resource - * name, the budgets returned are tracking the costs for that project. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function listBudgets($parent, array $optionalArgs = []) - { - $request = new ListBudgetsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['scope'])) { - $request->setScope($optionalArgs['scope']); - } - - 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('ListBudgets', $optionalArgs, ListBudgetsResponse::class, $request); - } - - /** - * 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. - * - * Sample code: - * ``` - * $budgetServiceClient = new BudgetServiceClient(); - * try { - * $budget = new Budget(); - * $response = $budgetServiceClient->updateBudget($budget); - * } finally { - * $budgetServiceClient->close(); - * } - * ``` - * - * @param Budget $budget Required. The updated budget object. - * The budget to update is specified by the budget name in the budget. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Optional. Indicates which fields in the provided budget to update. - * Read-only fields (such as `name`) cannot be changed. If this is not - * provided, then only fields with non-default values from the request are - * updated. See - * https://developers.google.com/protocol-buffers/docs/proto3#default for more - * details about default values. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Billing\Budgets\V1beta1\Budget - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function updateBudget($budget, array $optionalArgs = []) - { - $request = new UpdateBudgetRequest(); - $requestParamHeaders = []; - $request->setBudget($budget); - $requestParamHeaders['budget.name'] = $budget->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('UpdateBudget', Budget::class, $optionalArgs, $request)->wait(); - } -} diff --git a/BillingBudgets/src/V1beta1/GetBudgetRequest.php b/BillingBudgets/src/V1beta1/GetBudgetRequest.php deleted file mode 100644 index 9db9f36121a4..000000000000 --- a/BillingBudgets/src/V1beta1/GetBudgetRequest.php +++ /dev/null @@ -1,71 +0,0 @@ -google.cloud.billing.budgets.v1beta1.GetBudgetRequest - */ -class GetBudgetRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Name of budget to get. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. Name of budget to get. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Name of budget to get. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * 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. Name of budget to get. Values are of the form - * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. - * - * 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/BillingBudgets/src/V1beta1/LastPeriodAmount.php b/BillingBudgets/src/V1beta1/LastPeriodAmount.php deleted file mode 100644 index 112417e877f8..000000000000 --- a/BillingBudgets/src/V1beta1/LastPeriodAmount.php +++ /dev/null @@ -1,41 +0,0 @@ -google.cloud.billing.budgets.v1beta1.LastPeriodAmount - */ -class LastPeriodAmount extends \Google\Protobuf\Internal\Message -{ - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetModel::initOnce(); - parent::__construct($data); - } - -} - diff --git a/BillingBudgets/src/V1beta1/ListBudgetsRequest.php b/BillingBudgets/src/V1beta1/ListBudgetsRequest.php deleted file mode 100644 index 5e2ab1d93645..000000000000 --- a/BillingBudgets/src/V1beta1/ListBudgetsRequest.php +++ /dev/null @@ -1,205 +0,0 @@ -google.cloud.billing.budgets.v1beta1.ListBudgetsRequest - */ -class ListBudgetsRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Name of billing account to list budgets under. Values - * are of the form `billingAccounts/{billingAccountId}`. - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $parent = ''; - /** - * Optional. Set the scope of the budgets to be returned, in the format of the - * resource name. The scope of a budget is the cost that it tracks, such as - * costs for a single project, or the costs for all projects in a folder. Only - * project scope (in the format of "projects/project-id" or "projects/123") is - * supported in this field. When this field is set to a project's resource - * name, the budgets returned are tracking the costs for that project. - * - * Generated from protobuf field string scope = 4 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $scope = ''; - /** - * Optional. The maximum number of budgets to return per page. - * The default and maximum value are 100. - * - * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $page_size = 0; - /** - * Optional. The value returned by the last `ListBudgetsResponse` which - * indicates that this is a continuation of a prior `ListBudgets` call, - * and that the system should return the next page of data. - * - * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $page_token = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * Required. Name of billing account to list budgets under. Values - * are of the form `billingAccounts/{billingAccountId}`. - * @type string $scope - * Optional. Set the scope of the budgets to be returned, in the format of the - * resource name. The scope of a budget is the cost that it tracks, such as - * costs for a single project, or the costs for all projects in a folder. Only - * project scope (in the format of "projects/project-id" or "projects/123") is - * supported in this field. When this field is set to a project's resource - * name, the budgets returned are tracking the costs for that project. - * @type int $page_size - * Optional. The maximum number of budgets to return per page. - * The default and maximum value are 100. - * @type string $page_token - * Optional. The value returned by the last `ListBudgetsResponse` which - * indicates that this is a continuation of a prior `ListBudgets` call, - * and that the system should return the next page of data. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Name of billing account to list budgets under. Values - * are of the form `billingAccounts/{billingAccountId}`. - * - * 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. Name of billing account to list budgets under. Values - * are of the form `billingAccounts/{billingAccountId}`. - * - * 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. Set the scope of the budgets to be returned, in the format of the - * resource name. The scope of a budget is the cost that it tracks, such as - * costs for a single project, or the costs for all projects in a folder. Only - * project scope (in the format of "projects/project-id" or "projects/123") is - * supported in this field. When this field is set to a project's resource - * name, the budgets returned are tracking the costs for that project. - * - * Generated from protobuf field string scope = 4 [(.google.api.field_behavior) = OPTIONAL]; - * @return string - */ - public function getScope() - { - return $this->scope; - } - - /** - * Optional. Set the scope of the budgets to be returned, in the format of the - * resource name. The scope of a budget is the cost that it tracks, such as - * costs for a single project, or the costs for all projects in a folder. Only - * project scope (in the format of "projects/project-id" or "projects/123") is - * supported in this field. When this field is set to a project's resource - * name, the budgets returned are tracking the costs for that project. - * - * Generated from protobuf field string scope = 4 [(.google.api.field_behavior) = OPTIONAL]; - * @param string $var - * @return $this - */ - public function setScope($var) - { - GPBUtil::checkString($var, True); - $this->scope = $var; - - return $this; - } - - /** - * Optional. The maximum number of budgets to return per page. - * The default and maximum value are 100. - * - * 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 budgets to return per page. - * The default and maximum value are 100. - * - * 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 value returned by the last `ListBudgetsResponse` which - * indicates that this is a continuation of a prior `ListBudgets` call, - * and that the system should return the next page of data. - * - * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @return string - */ - public function getPageToken() - { - return $this->page_token; - } - - /** - * Optional. The value returned by the last `ListBudgetsResponse` which - * indicates that this is a continuation of a prior `ListBudgets` call, - * and that the system should return the next page of data. - * - * 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/BillingBudgets/src/V1beta1/ListBudgetsResponse.php b/BillingBudgets/src/V1beta1/ListBudgetsResponse.php deleted file mode 100644 index d4f1493f2c92..000000000000 --- a/BillingBudgets/src/V1beta1/ListBudgetsResponse.php +++ /dev/null @@ -1,105 +0,0 @@ -google.cloud.billing.budgets.v1beta1.ListBudgetsResponse - */ -class ListBudgetsResponse extends \Google\Protobuf\Internal\Message -{ - /** - * List of the budgets owned by the requested billing account. - * - * Generated from protobuf field repeated .google.cloud.billing.budgets.v1beta1.Budget budgets = 1; - */ - private $budgets; - /** - * If not empty, indicates that there may be more budgets that match the - * request; this value should be passed in a new `ListBudgetsRequest`. - * - * 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\Billing\Budgets\V1beta1\Budget>|\Google\Protobuf\Internal\RepeatedField $budgets - * List of the budgets owned by the requested billing account. - * @type string $next_page_token - * If not empty, indicates that there may be more budgets that match the - * request; this value should be passed in a new `ListBudgetsRequest`. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetService::initOnce(); - parent::__construct($data); - } - - /** - * List of the budgets owned by the requested billing account. - * - * Generated from protobuf field repeated .google.cloud.billing.budgets.v1beta1.Budget budgets = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getBudgets() - { - return $this->budgets; - } - - /** - * List of the budgets owned by the requested billing account. - * - * Generated from protobuf field repeated .google.cloud.billing.budgets.v1beta1.Budget budgets = 1; - * @param array<\Google\Cloud\Billing\Budgets\V1beta1\Budget>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setBudgets($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Billing\Budgets\V1beta1\Budget::class); - $this->budgets = $arr; - - return $this; - } - - /** - * If not empty, indicates that there may be more budgets that match the - * request; this value should be passed in a new `ListBudgetsRequest`. - * - * Generated from protobuf field string next_page_token = 2; - * @return string - */ - public function getNextPageToken() - { - return $this->next_page_token; - } - - /** - * If not empty, indicates that there may be more budgets that match the - * request; this value should be passed in a new `ListBudgetsRequest`. - * - * 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/BillingBudgets/src/V1beta1/ThresholdRule.php b/BillingBudgets/src/V1beta1/ThresholdRule.php deleted file mode 100644 index 9a0ab4082c14..000000000000 --- a/BillingBudgets/src/V1beta1/ThresholdRule.php +++ /dev/null @@ -1,130 +0,0 @@ -google.cloud.billing.budgets.v1beta1.ThresholdRule - */ -class ThresholdRule extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Send an alert when this threshold is exceeded. - * This is a 1.0-based percentage, so 0.5 = 50%. - * Validation: non-negative number. - * - * Generated from protobuf field double threshold_percent = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $threshold_percent = 0.0; - /** - * Optional. The type of basis used to determine if spend has passed the - * threshold. Behavior defaults to CURRENT_SPEND if not set. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.ThresholdRule.Basis spend_basis = 2 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $spend_basis = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type float $threshold_percent - * Required. Send an alert when this threshold is exceeded. - * This is a 1.0-based percentage, so 0.5 = 50%. - * Validation: non-negative number. - * @type int $spend_basis - * Optional. The type of basis used to determine if spend has passed the - * threshold. Behavior defaults to CURRENT_SPEND if not set. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetModel::initOnce(); - parent::__construct($data); - } - - /** - * Required. Send an alert when this threshold is exceeded. - * This is a 1.0-based percentage, so 0.5 = 50%. - * Validation: non-negative number. - * - * Generated from protobuf field double threshold_percent = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return float - */ - public function getThresholdPercent() - { - return $this->threshold_percent; - } - - /** - * Required. Send an alert when this threshold is exceeded. - * This is a 1.0-based percentage, so 0.5 = 50%. - * Validation: non-negative number. - * - * Generated from protobuf field double threshold_percent = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param float $var - * @return $this - */ - public function setThresholdPercent($var) - { - GPBUtil::checkDouble($var); - $this->threshold_percent = $var; - - return $this; - } - - /** - * Optional. The type of basis used to determine if spend has passed the - * threshold. Behavior defaults to CURRENT_SPEND if not set. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.ThresholdRule.Basis spend_basis = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @return int - */ - public function getSpendBasis() - { - return $this->spend_basis; - } - - /** - * Optional. The type of basis used to determine if spend has passed the - * threshold. Behavior defaults to CURRENT_SPEND if not set. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.ThresholdRule.Basis spend_basis = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @param int $var - * @return $this - */ - public function setSpendBasis($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Billing\Budgets\V1beta1\ThresholdRule\Basis::class); - $this->spend_basis = $var; - - return $this; - } - -} - diff --git a/BillingBudgets/src/V1beta1/ThresholdRule/Basis.php b/BillingBudgets/src/V1beta1/ThresholdRule/Basis.php deleted file mode 100644 index fa5003a40e02..000000000000 --- a/BillingBudgets/src/V1beta1/ThresholdRule/Basis.php +++ /dev/null @@ -1,67 +0,0 @@ -google.cloud.billing.budgets.v1beta1.ThresholdRule.Basis - */ -class Basis -{ - /** - * Unspecified threshold basis. - * - * Generated from protobuf enum BASIS_UNSPECIFIED = 0; - */ - const BASIS_UNSPECIFIED = 0; - /** - * Use current spend as the basis for comparison against the threshold. - * - * Generated from protobuf enum CURRENT_SPEND = 1; - */ - const CURRENT_SPEND = 1; - /** - * Use forecasted spend for the period as the basis for comparison against - * the threshold. - * FORECASTED_SPEND can only be set when the budget's time period is a - * [Filter.calendar_period][google.cloud.billing.budgets.v1beta1.Filter.calendar_period]. - * It cannot be set in combination with - * [Filter.custom_period][google.cloud.billing.budgets.v1beta1.Filter.custom_period]. - * - * Generated from protobuf enum FORECASTED_SPEND = 2; - */ - const FORECASTED_SPEND = 2; - - private static $valueToName = [ - self::BASIS_UNSPECIFIED => 'BASIS_UNSPECIFIED', - self::CURRENT_SPEND => 'CURRENT_SPEND', - self::FORECASTED_SPEND => 'FORECASTED_SPEND', - ]; - - 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/BillingBudgets/src/V1beta1/UpdateBudgetRequest.php b/BillingBudgets/src/V1beta1/UpdateBudgetRequest.php deleted file mode 100644 index 83d428663993..000000000000 --- a/BillingBudgets/src/V1beta1/UpdateBudgetRequest.php +++ /dev/null @@ -1,145 +0,0 @@ -google.cloud.billing.budgets.v1beta1.UpdateBudgetRequest - */ -class UpdateBudgetRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The updated budget object. - * The budget to update is specified by the budget name in the budget. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Budget budget = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $budget = null; - /** - * Optional. Indicates which fields in the provided budget to update. - * Read-only fields (such as `name`) cannot be changed. If this is not - * provided, then only fields with non-default values from the request are - * updated. See - * https://developers.google.com/protocol-buffers/docs/proto3#default for more - * details about default values. - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $update_mask = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Billing\Budgets\V1beta1\Budget $budget - * Required. The updated budget object. - * The budget to update is specified by the budget name in the budget. - * @type \Google\Protobuf\FieldMask $update_mask - * Optional. Indicates which fields in the provided budget to update. - * Read-only fields (such as `name`) cannot be changed. If this is not - * provided, then only fields with non-default values from the request are - * updated. See - * https://developers.google.com/protocol-buffers/docs/proto3#default for more - * details about default values. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Billing\Budgets\V1Beta1\BudgetService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The updated budget object. - * The budget to update is specified by the budget name in the budget. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Budget budget = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Billing\Budgets\V1beta1\Budget|null - */ - public function getBudget() - { - return $this->budget; - } - - public function hasBudget() - { - return isset($this->budget); - } - - public function clearBudget() - { - unset($this->budget); - } - - /** - * Required. The updated budget object. - * The budget to update is specified by the budget name in the budget. - * - * Generated from protobuf field .google.cloud.billing.budgets.v1beta1.Budget budget = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\Billing\Budgets\V1beta1\Budget $var - * @return $this - */ - public function setBudget($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Billing\Budgets\V1beta1\Budget::class); - $this->budget = $var; - - return $this; - } - - /** - * Optional. Indicates which fields in the provided budget to update. - * Read-only fields (such as `name`) cannot be changed. If this is not - * provided, then only fields with non-default values from the request are - * updated. See - * https://developers.google.com/protocol-buffers/docs/proto3#default for more - * details about default values. - * - * 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. Indicates which fields in the provided budget to update. - * Read-only fields (such as `name`) cannot be changed. If this is not - * provided, then only fields with non-default values from the request are - * updated. See - * https://developers.google.com/protocol-buffers/docs/proto3#default for more - * details about default values. - * - * 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/BillingBudgets/src/V1beta1/gapic_metadata.json b/BillingBudgets/src/V1beta1/gapic_metadata.json deleted file mode 100644 index a880292b3529..000000000000 --- a/BillingBudgets/src/V1beta1/gapic_metadata.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", - "language": "php", - "protoPackage": "google.cloud.billing.budgets.v1beta1", - "libraryPackage": "Google\\Cloud\\Billing\\Budgets\\V1beta1", - "services": { - "BudgetService": { - "clients": { - "grpc": { - "libraryClient": "BudgetServiceGapicClient", - "rpcs": { - "CreateBudget": { - "methods": [ - "createBudget" - ] - }, - "DeleteBudget": { - "methods": [ - "deleteBudget" - ] - }, - "GetBudget": { - "methods": [ - "getBudget" - ] - }, - "ListBudgets": { - "methods": [ - "listBudgets" - ] - }, - "UpdateBudget": { - "methods": [ - "updateBudget" - ] - } - } - } - } - } - } -} \ No newline at end of file diff --git a/BillingBudgets/src/V1beta1/resources/budget_service_client_config.json b/BillingBudgets/src/V1beta1/resources/budget_service_client_config.json deleted file mode 100644 index 14d9d8c92e24..000000000000 --- a/BillingBudgets/src/V1beta1/resources/budget_service_client_config.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "interfaces": { - "google.cloud.billing.budgets.v1beta1.BudgetService": { - "retry_codes": { - "no_retry_codes": [], - "no_retry_1_codes": [], - "retry_policy_1_codes": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "no_retry_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 0, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 0, - "total_timeout_millis": 0 - }, - "no_retry_1_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 60000 - }, - "retry_policy_1_params": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 60000 - } - }, - "methods": { - "CreateBudget": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, - "DeleteBudget": { - "timeout_millis": 60000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "GetBudget": { - "timeout_millis": 60000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "ListBudgets": { - "timeout_millis": 60000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "UpdateBudget": { - "timeout_millis": 60000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - } - } - } - } -} diff --git a/BillingBudgets/src/V1beta1/resources/budget_service_descriptor_config.php b/BillingBudgets/src/V1beta1/resources/budget_service_descriptor_config.php deleted file mode 100644 index 8f504ebc81ff..000000000000 --- a/BillingBudgets/src/V1beta1/resources/budget_service_descriptor_config.php +++ /dev/null @@ -1,38 +0,0 @@ - [ - 'google.cloud.billing.budgets.v1beta1.BudgetService' => [ - 'ListBudgets' => [ - 'pageStreaming' => [ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getBudgets', - ], - ], - ], - ], -]; diff --git a/BillingBudgets/src/V1beta1/resources/budget_service_rest_client_config.php b/BillingBudgets/src/V1beta1/resources/budget_service_rest_client_config.php deleted file mode 100644 index 65465df381b2..000000000000 --- a/BillingBudgets/src/V1beta1/resources/budget_service_rest_client_config.php +++ /dev/null @@ -1,87 +0,0 @@ - [ - 'google.cloud.billing.budgets.v1beta1.BudgetService' => [ - 'CreateBudget' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{parent=billingAccounts/*}/budgets', - 'body' => '*', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'DeleteBudget' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta1/{name=billingAccounts/*/budgets/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'GetBudget' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=billingAccounts/*/budgets/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ListBudgets' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{parent=billingAccounts/*}/budgets', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'UpdateBudget' => [ - 'method' => 'patch', - 'uriTemplate' => '/v1beta1/{budget.name=billingAccounts/*/budgets/*}', - 'body' => '*', - 'placeholders' => [ - 'budget.name' => [ - 'getters' => [ - 'getBudget', - 'getName', - ], - ], - ], - ], - ], - ], - 'numericEnums' => true, -]; diff --git a/BillingBudgets/tests/Unit/V1/BudgetServiceClientTest.php b/BillingBudgets/tests/Unit/V1/BudgetServiceClientTest.php deleted file mode 100644 index 548f1ff1e135..000000000000 --- a/BillingBudgets/tests/Unit/V1/BudgetServiceClientTest.php +++ /dev/null @@ -1,393 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return BudgetServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new BudgetServiceClient($options); - } - - /** @test */ - public function createBudgetTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $etag = 'etag3123477'; - $expectedResponse = new Budget(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->billingAccountName('[BILLING_ACCOUNT]'); - $budget = new Budget(); - $budgetAmount = new BudgetAmount(); - $budget->setAmount($budgetAmount); - $response = $gapicClient->createBudget($formattedParent, $budget); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.billing.budgets.v1.BudgetService/CreateBudget', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getBudget(); - $this->assertProtobufEquals($budget, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createBudgetExceptionTest() - { - $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->billingAccountName('[BILLING_ACCOUNT]'); - $budget = new Budget(); - $budgetAmount = new BudgetAmount(); - $budget->setAmount($budgetAmount); - try { - $gapicClient->createBudget($formattedParent, $budget); - // 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 deleteBudgetTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - $gapicClient->deleteBudget($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.billing.budgets.v1.BudgetService/DeleteBudget', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteBudgetExceptionTest() - { - $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->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - try { - $gapicClient->deleteBudget($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 getBudgetTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $etag = 'etag3123477'; - $expectedResponse = new Budget(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - $response = $gapicClient->getBudget($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.billing.budgets.v1.BudgetService/GetBudget', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getBudgetExceptionTest() - { - $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->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - try { - $gapicClient->getBudget($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 listBudgetsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $budgetsElement = new Budget(); - $budgets = [ - $budgetsElement, - ]; - $expectedResponse = new ListBudgetsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setBudgets($budgets); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->billingAccountName('[BILLING_ACCOUNT]'); - $response = $gapicClient->listBudgets($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getBudgets()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.billing.budgets.v1.BudgetService/ListBudgets', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listBudgetsExceptionTest() - { - $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->billingAccountName('[BILLING_ACCOUNT]'); - try { - $gapicClient->listBudgets($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 updateBudgetTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $etag = 'etag3123477'; - $expectedResponse = new Budget(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $budget = new Budget(); - $budgetAmount = new BudgetAmount(); - $budget->setAmount($budgetAmount); - $response = $gapicClient->updateBudget($budget); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.billing.budgets.v1.BudgetService/UpdateBudget', $actualFuncCall); - $actualValue = $actualRequestObject->getBudget(); - $this->assertProtobufEquals($budget, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateBudgetExceptionTest() - { - $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 - $budget = new Budget(); - $budgetAmount = new BudgetAmount(); - $budget->setAmount($budgetAmount); - try { - $gapicClient->updateBudget($budget); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/BillingBudgets/tests/Unit/V1/Client/BudgetServiceClientTest.php b/BillingBudgets/tests/Unit/V1/Client/BudgetServiceClientTest.php index 5f98d592e286..05c78dacdecd 100644 --- a/BillingBudgets/tests/Unit/V1/Client/BudgetServiceClientTest.php +++ b/BillingBudgets/tests/Unit/V1/Client/BudgetServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return BudgetServiceClient */ @@ -89,9 +91,7 @@ public function createBudgetTest() $budget = new Budget(); $budgetAmount = new BudgetAmount(); $budget->setAmount($budgetAmount); - $request = (new CreateBudgetRequest()) - ->setParent($formattedParent) - ->setBudget($budget); + $request = (new CreateBudgetRequest())->setParent($formattedParent)->setBudget($budget); $response = $gapicClient->createBudget($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -117,21 +117,22 @@ public function createBudgetExceptionTest() $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); + $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->billingAccountName('[BILLING_ACCOUNT]'); $budget = new Budget(); $budgetAmount = new BudgetAmount(); $budget->setAmount($budgetAmount); - $request = (new CreateBudgetRequest()) - ->setParent($formattedParent) - ->setBudget($budget); + $request = (new CreateBudgetRequest())->setParent($formattedParent)->setBudget($budget); try { $gapicClient->createBudget($request); // If the $gapicClient method call did not throw, fail the test @@ -158,8 +159,7 @@ public function deleteBudgetTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - $request = (new DeleteBudgetRequest()) - ->setName($formattedName); + $request = (new DeleteBudgetRequest())->setName($formattedName); $gapicClient->deleteBudget($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -182,17 +182,19 @@ public function deleteBudgetExceptionTest() $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); + $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->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - $request = (new DeleteBudgetRequest()) - ->setName($formattedName); + $request = (new DeleteBudgetRequest())->setName($formattedName); try { $gapicClient->deleteBudget($request); // If the $gapicClient method call did not throw, fail the test @@ -225,8 +227,7 @@ public function getBudgetTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - $request = (new GetBudgetRequest()) - ->setName($formattedName); + $request = (new GetBudgetRequest())->setName($formattedName); $response = $gapicClient->getBudget($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -250,17 +251,19 @@ public function getBudgetExceptionTest() $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); + $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->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - $request = (new GetBudgetRequest()) - ->setName($formattedName); + $request = (new GetBudgetRequest())->setName($formattedName); try { $gapicClient->getBudget($request); // If the $gapicClient method call did not throw, fail the test @@ -285,17 +288,14 @@ public function listBudgetsTest() // Mock response $nextPageToken = ''; $budgetsElement = new Budget(); - $budgets = [ - $budgetsElement, - ]; + $budgets = [$budgetsElement]; $expectedResponse = new ListBudgetsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setBudgets($budgets); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->billingAccountName('[BILLING_ACCOUNT]'); - $request = (new ListBudgetsRequest()) - ->setParent($formattedParent); + $request = (new ListBudgetsRequest())->setParent($formattedParent); $response = $gapicClient->listBudgets($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -322,17 +322,19 @@ public function listBudgetsExceptionTest() $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); + $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->billingAccountName('[BILLING_ACCOUNT]'); - $request = (new ListBudgetsRequest()) - ->setParent($formattedParent); + $request = (new ListBudgetsRequest())->setParent($formattedParent); try { $gapicClient->listBudgets($request); // If the $gapicClient method call did not throw, fail the test @@ -367,8 +369,7 @@ public function updateBudgetTest() $budget = new Budget(); $budgetAmount = new BudgetAmount(); $budget->setAmount($budgetAmount); - $request = (new UpdateBudgetRequest()) - ->setBudget($budget); + $request = (new UpdateBudgetRequest())->setBudget($budget); $response = $gapicClient->updateBudget($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -392,19 +393,21 @@ public function updateBudgetExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $budget = new Budget(); $budgetAmount = new BudgetAmount(); $budget->setAmount($budgetAmount); - $request = (new UpdateBudgetRequest()) - ->setBudget($budget); + $request = (new UpdateBudgetRequest())->setBudget($budget); try { $gapicClient->updateBudget($request); // If the $gapicClient method call did not throw, fail the test @@ -440,9 +443,7 @@ public function createBudgetAsyncTest() $budget = new Budget(); $budgetAmount = new BudgetAmount(); $budget->setAmount($budgetAmount); - $request = (new CreateBudgetRequest()) - ->setParent($formattedParent) - ->setBudget($budget); + $request = (new CreateBudgetRequest())->setParent($formattedParent)->setBudget($budget); $response = $gapicClient->createBudgetAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); diff --git a/BillingBudgets/tests/Unit/V1beta1/BudgetServiceClientTest.php b/BillingBudgets/tests/Unit/V1beta1/BudgetServiceClientTest.php deleted file mode 100644 index 3dbfc38f2759..000000000000 --- a/BillingBudgets/tests/Unit/V1beta1/BudgetServiceClientTest.php +++ /dev/null @@ -1,393 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return BudgetServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new BudgetServiceClient($options); - } - - /** @test */ - public function createBudgetTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $etag = 'etag3123477'; - $expectedResponse = new Budget(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->billingAccountName('[BILLING_ACCOUNT]'); - $budget = new Budget(); - $budgetAmount = new BudgetAmount(); - $budget->setAmount($budgetAmount); - $response = $gapicClient->createBudget($formattedParent, $budget); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.billing.budgets.v1beta1.BudgetService/CreateBudget', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getBudget(); - $this->assertProtobufEquals($budget, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createBudgetExceptionTest() - { - $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->billingAccountName('[BILLING_ACCOUNT]'); - $budget = new Budget(); - $budgetAmount = new BudgetAmount(); - $budget->setAmount($budgetAmount); - try { - $gapicClient->createBudget($formattedParent, $budget); - // 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 deleteBudgetTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - $gapicClient->deleteBudget($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.billing.budgets.v1beta1.BudgetService/DeleteBudget', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteBudgetExceptionTest() - { - $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->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - try { - $gapicClient->deleteBudget($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 getBudgetTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $etag = 'etag3123477'; - $expectedResponse = new Budget(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - $response = $gapicClient->getBudget($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.billing.budgets.v1beta1.BudgetService/GetBudget', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getBudgetExceptionTest() - { - $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->budgetName('[BILLING_ACCOUNT]', '[BUDGET]'); - try { - $gapicClient->getBudget($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 listBudgetsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $budgetsElement = new Budget(); - $budgets = [ - $budgetsElement, - ]; - $expectedResponse = new ListBudgetsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setBudgets($budgets); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->billingAccountName('[BILLING_ACCOUNT]'); - $response = $gapicClient->listBudgets($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getBudgets()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.billing.budgets.v1beta1.BudgetService/ListBudgets', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listBudgetsExceptionTest() - { - $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->billingAccountName('[BILLING_ACCOUNT]'); - try { - $gapicClient->listBudgets($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 updateBudgetTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $etag = 'etag3123477'; - $expectedResponse = new Budget(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $budget = new Budget(); - $budgetAmount = new BudgetAmount(); - $budget->setAmount($budgetAmount); - $response = $gapicClient->updateBudget($budget); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.billing.budgets.v1beta1.BudgetService/UpdateBudget', $actualFuncCall); - $actualValue = $actualRequestObject->getBudget(); - $this->assertProtobufEquals($budget, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateBudgetExceptionTest() - { - $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 - $budget = new Budget(); - $budgetAmount = new BudgetAmount(); - $budget->setAmount($budgetAmount); - try { - $gapicClient->updateBudget($budget); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/ContactCenterInsights/.OwlBot.yaml b/ContactCenterInsights/.OwlBot.yaml index 199f16198223..a0c160d16f3f 100644 --- a/ContactCenterInsights/.OwlBot.yaml +++ b/ContactCenterInsights/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/contactcenterinsights/v1/.*-php/(.*) - dest: /owl-bot-staging/ContactCenterInsights/v1/$1 + - source: /google/cloud/contactcenterinsights/(v1)/.*-php/(.*) + dest: /owl-bot-staging/ContactCenterInsights/$1/$2 api-name: ContactCenterInsights diff --git a/ContactCenterInsights/owlbot.py b/ContactCenterInsights/owlbot.py index 35f373259081..6f600aa66b5f 100644 --- a/ContactCenterInsights/owlbot.py +++ b/ContactCenterInsights/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,13 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php" - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -47,28 +41,6 @@ + "\n", '') - - - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - # format generated clients subprocess.run([ 'npm', @@ -77,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/ContactCenterInsights/src/V1/Analysis.php b/ContactCenterInsights/src/V1/Analysis.php index 3f4727a349af..880a55f553be 100644 --- a/ContactCenterInsights/src/V1/Analysis.php +++ b/ContactCenterInsights/src/V1/Analysis.php @@ -22,34 +22,34 @@ class Analysis extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. The time at which the analysis was requested. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $request_time = null; + protected $request_time = null; /** * Output only. The time at which the analysis was created, which occurs when * the long-running operation completes. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The result of the analysis, which is populated when the * analysis finishes. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnalysisResult analysis_result = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $analysis_result = null; + protected $analysis_result = null; /** * To select the annotators to run and the phrase matchers to use * (if any). If not specified, all annotators will be run. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotatorSelector annotator_selector = 8; */ - private $annotator_selector = null; + protected $annotator_selector = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/AnalysisResult.php b/ContactCenterInsights/src/V1/AnalysisResult.php index 407b483c3963..f3f49c60cfdc 100644 --- a/ContactCenterInsights/src/V1/AnalysisResult.php +++ b/ContactCenterInsights/src/V1/AnalysisResult.php @@ -20,7 +20,7 @@ class AnalysisResult extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp end_time = 1; */ - private $end_time = null; + protected $end_time = null; protected $metadata; /** diff --git a/ContactCenterInsights/src/V1/AnalysisResult/CallAnalysisMetadata.php b/ContactCenterInsights/src/V1/AnalysisResult/CallAnalysisMetadata.php index b7afe4fdbeec..e5eaf71af190 100644 --- a/ContactCenterInsights/src/V1/AnalysisResult/CallAnalysisMetadata.php +++ b/ContactCenterInsights/src/V1/AnalysisResult/CallAnalysisMetadata.php @@ -50,7 +50,7 @@ class CallAnalysisMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueModelResult issue_model_result = 8; */ - private $issue_model_result = null; + protected $issue_model_result = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/AnnotationBoundary.php b/ContactCenterInsights/src/V1/AnnotationBoundary.php index 3d6295d530dc..f36dc2dfdf24 100644 --- a/ContactCenterInsights/src/V1/AnnotationBoundary.php +++ b/ContactCenterInsights/src/V1/AnnotationBoundary.php @@ -21,7 +21,7 @@ class AnnotationBoundary extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 transcript_index = 1; */ - private $transcript_index = 0; + protected $transcript_index = 0; protected $detailed_boundary; /** diff --git a/ContactCenterInsights/src/V1/AnnotatorSelector.php b/ContactCenterInsights/src/V1/AnnotatorSelector.php index b5e89f767489..d2548d2c4a3f 100644 --- a/ContactCenterInsights/src/V1/AnnotatorSelector.php +++ b/ContactCenterInsights/src/V1/AnnotatorSelector.php @@ -20,19 +20,19 @@ class AnnotatorSelector extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool run_interruption_annotator = 1; */ - private $run_interruption_annotator = false; + protected $run_interruption_annotator = false; /** * Whether to run the silence annotator. * * Generated from protobuf field bool run_silence_annotator = 2; */ - private $run_silence_annotator = false; + protected $run_silence_annotator = false; /** * Whether to run the active phrase matcher annotator(s). * * Generated from protobuf field bool run_phrase_matcher_annotator = 3; */ - private $run_phrase_matcher_annotator = false; + protected $run_phrase_matcher_annotator = false; /** * The list of phrase matchers to run. If not provided, all active phrase * matchers will be used. If inactive phrase matchers are provided, they will @@ -48,26 +48,26 @@ class AnnotatorSelector extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool run_sentiment_annotator = 5; */ - private $run_sentiment_annotator = false; + protected $run_sentiment_annotator = false; /** * Whether to run the entity annotator. * * Generated from protobuf field bool run_entity_annotator = 6; */ - private $run_entity_annotator = false; + protected $run_entity_annotator = false; /** * Whether to run the intent annotator. * * Generated from protobuf field bool run_intent_annotator = 7; */ - private $run_intent_annotator = false; + protected $run_intent_annotator = false; /** * Whether to run the issue model annotator. A model should have already been * deployed for this to take effect. * * Generated from protobuf field bool run_issue_model_annotator = 8; */ - private $run_issue_model_annotator = false; + protected $run_issue_model_annotator = false; /** * The issue model to run. If not provided, the most recently deployed topic * model will be used. The provided issue model will only be used for @@ -83,13 +83,13 @@ class AnnotatorSelector extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool run_summarization_annotator = 9; */ - private $run_summarization_annotator = false; + protected $run_summarization_annotator = false; /** * Configuration for the summarization annotator. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotatorSelector.SummarizationConfig summarization_config = 11; */ - private $summarization_config = null; + protected $summarization_config = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/AnswerFeedback.php b/ContactCenterInsights/src/V1/AnswerFeedback.php index f387096206fe..213afb4ccc53 100644 --- a/ContactCenterInsights/src/V1/AnswerFeedback.php +++ b/ContactCenterInsights/src/V1/AnswerFeedback.php @@ -21,20 +21,20 @@ class AnswerFeedback extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnswerFeedback.CorrectnessLevel correctness_level = 1; */ - private $correctness_level = 0; + protected $correctness_level = 0; /** * Indicates whether an answer or item was clicked by the human agent. * * Generated from protobuf field bool clicked = 2; */ - private $clicked = false; + protected $clicked = false; /** * Indicates whether an answer or item was displayed to the human agent in the * agent desktop UI. * * Generated from protobuf field bool displayed = 3; */ - private $displayed = false; + protected $displayed = false; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/ArticleSuggestionData.php b/ContactCenterInsights/src/V1/ArticleSuggestionData.php index b26ec91cae99..e6fec5e3efb9 100644 --- a/ContactCenterInsights/src/V1/ArticleSuggestionData.php +++ b/ContactCenterInsights/src/V1/ArticleSuggestionData.php @@ -20,13 +20,13 @@ class ArticleSuggestionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string title = 1; */ - private $title = ''; + protected $title = ''; /** * Article URI. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * The system's confidence score that this article is a good match for this * conversation, ranging from 0.0 (completely uncertain) to 1.0 (completely @@ -34,7 +34,7 @@ class ArticleSuggestionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float confidence_score = 3; */ - private $confidence_score = 0.0; + protected $confidence_score = 0.0; /** * Map that contains metadata about the Article Suggestion and the document * that it originates from. @@ -49,7 +49,7 @@ class ArticleSuggestionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string query_record = 5; */ - private $query_record = ''; + protected $query_record = ''; /** * The knowledge document that this answer was extracted from. * Format: @@ -57,7 +57,7 @@ class ArticleSuggestionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source = 6; */ - private $source = ''; + protected $source = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/BulkAnalyzeConversationsMetadata.php b/ContactCenterInsights/src/V1/BulkAnalyzeConversationsMetadata.php index 76fc72e7586f..f93ac9e68a44 100644 --- a/ContactCenterInsights/src/V1/BulkAnalyzeConversationsMetadata.php +++ b/ContactCenterInsights/src/V1/BulkAnalyzeConversationsMetadata.php @@ -20,38 +20,38 @@ class BulkAnalyzeConversationsMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; */ - private $create_time = null; + protected $create_time = null; /** * The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2; */ - private $end_time = null; + protected $end_time = null; /** * The original request for bulk analyze. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.BulkAnalyzeConversationsRequest request = 3; */ - private $request = null; + protected $request = null; /** * The number of requested analyses that have completed successfully so far. * * Generated from protobuf field int32 completed_analyses_count = 4; */ - private $completed_analyses_count = 0; + protected $completed_analyses_count = 0; /** * The number of requested analyses that have failed so far. * * Generated from protobuf field int32 failed_analyses_count = 5; */ - private $failed_analyses_count = 0; + protected $failed_analyses_count = 0; /** * Total number of analyses requested. Computed by the number of conversations * returned by `filter` multiplied by `analysis_percentage` in the request. * * Generated from protobuf field int32 total_requested_analyses_count = 6; */ - private $total_requested_analyses_count = 0; + protected $total_requested_analyses_count = 0; /** * Output only. Partial errors during bulk analyze operation that might cause * the operation output to be incomplete. diff --git a/ContactCenterInsights/src/V1/BulkAnalyzeConversationsRequest.php b/ContactCenterInsights/src/V1/BulkAnalyzeConversationsRequest.php index 964dd57553d4..b73df51d31e4 100644 --- a/ContactCenterInsights/src/V1/BulkAnalyzeConversationsRequest.php +++ b/ContactCenterInsights/src/V1/BulkAnalyzeConversationsRequest.php @@ -20,27 +20,27 @@ class BulkAnalyzeConversationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. Filter used to select the subset of conversations to analyze. * * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $filter = ''; + protected $filter = ''; /** * Required. Percentage of selected conversation to analyze, between * [0, 100]. * * Generated from protobuf field float analysis_percentage = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $analysis_percentage = 0.0; + protected $analysis_percentage = 0.0; /** * To select the annotators to run and the phrase matchers to use * (if any). If not specified, all annotators will be run. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotatorSelector annotator_selector = 8; */ - private $annotator_selector = null; + protected $annotator_selector = null; /** * @param string $parent Required. The parent resource to create analyses in. Please see diff --git a/ContactCenterInsights/src/V1/BulkAnalyzeConversationsResponse.php b/ContactCenterInsights/src/V1/BulkAnalyzeConversationsResponse.php index e41fef87f220..adccae48897f 100644 --- a/ContactCenterInsights/src/V1/BulkAnalyzeConversationsResponse.php +++ b/ContactCenterInsights/src/V1/BulkAnalyzeConversationsResponse.php @@ -20,13 +20,13 @@ class BulkAnalyzeConversationsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 successful_analysis_count = 1; */ - private $successful_analysis_count = 0; + protected $successful_analysis_count = 0; /** * Count of failed analyses. * * Generated from protobuf field int32 failed_analysis_count = 2; */ - private $failed_analysis_count = 0; + protected $failed_analysis_count = 0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/BulkDeleteConversationsMetadata.php b/ContactCenterInsights/src/V1/BulkDeleteConversationsMetadata.php index 07df62854257..753b1ea23b0e 100644 --- a/ContactCenterInsights/src/V1/BulkDeleteConversationsMetadata.php +++ b/ContactCenterInsights/src/V1/BulkDeleteConversationsMetadata.php @@ -20,19 +20,19 @@ class BulkDeleteConversationsMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; */ - private $create_time = null; + protected $create_time = null; /** * The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2; */ - private $end_time = null; + protected $end_time = null; /** * The original request for bulk delete. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.BulkDeleteConversationsRequest request = 3; */ - private $request = null; + protected $request = null; /** * Partial errors during bulk delete conversations operation that might cause * the operation output to be incomplete. diff --git a/ContactCenterInsights/src/V1/BulkDeleteConversationsRequest.php b/ContactCenterInsights/src/V1/BulkDeleteConversationsRequest.php index b701206c4d4f..90e90424bd7f 100644 --- a/ContactCenterInsights/src/V1/BulkDeleteConversationsRequest.php +++ b/ContactCenterInsights/src/V1/BulkDeleteConversationsRequest.php @@ -22,19 +22,19 @@ class BulkDeleteConversationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Filter used to select the subset of conversations to delete. * * Generated from protobuf field string filter = 2; */ - private $filter = ''; + protected $filter = ''; /** * Maximum number of conversations to delete. * * Generated from protobuf field int32 max_delete_count = 3; */ - private $max_delete_count = 0; + protected $max_delete_count = 0; /** * If set to true, all of this conversation's analyses will also be deleted. * Otherwise, the request will only succeed if the conversation has no @@ -42,7 +42,7 @@ class BulkDeleteConversationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool force = 4; */ - private $force = false; + protected $force = false; /** * @param string $parent Required. The parent resource to delete conversations from. diff --git a/ContactCenterInsights/src/V1/CalculateIssueModelStatsRequest.php b/ContactCenterInsights/src/V1/CalculateIssueModelStatsRequest.php index c1ba08f71155..8daa93a4a679 100644 --- a/ContactCenterInsights/src/V1/CalculateIssueModelStatsRequest.php +++ b/ContactCenterInsights/src/V1/CalculateIssueModelStatsRequest.php @@ -20,7 +20,7 @@ class CalculateIssueModelStatsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string issue_model = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $issue_model = ''; + protected $issue_model = ''; /** * @param string $issueModel Required. The resource name of the issue model to query against. Please see diff --git a/ContactCenterInsights/src/V1/CalculateIssueModelStatsResponse.php b/ContactCenterInsights/src/V1/CalculateIssueModelStatsResponse.php index 2728db38209f..932814766c92 100644 --- a/ContactCenterInsights/src/V1/CalculateIssueModelStatsResponse.php +++ b/ContactCenterInsights/src/V1/CalculateIssueModelStatsResponse.php @@ -21,7 +21,7 @@ class CalculateIssueModelStatsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueModelLabelStats current_stats = 4; */ - private $current_stats = null; + protected $current_stats = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/CalculateStatsRequest.php b/ContactCenterInsights/src/V1/CalculateStatsRequest.php index 0480d6dcc56f..5f422bb77f78 100644 --- a/ContactCenterInsights/src/V1/CalculateStatsRequest.php +++ b/ContactCenterInsights/src/V1/CalculateStatsRequest.php @@ -20,14 +20,14 @@ class CalculateStatsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string location = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $location = ''; + protected $location = ''; /** * A filter to reduce results to a specific subset. This field is useful for * getting statistics about conversations with specific properties. * * Generated from protobuf field string filter = 2; */ - private $filter = ''; + protected $filter = ''; /** * @param string $location Required. The location of the conversations. Please see diff --git a/ContactCenterInsights/src/V1/CalculateStatsResponse.php b/ContactCenterInsights/src/V1/CalculateStatsResponse.php index 10bc2a123133..973f3b649b1e 100644 --- a/ContactCenterInsights/src/V1/CalculateStatsResponse.php +++ b/ContactCenterInsights/src/V1/CalculateStatsResponse.php @@ -21,19 +21,19 @@ class CalculateStatsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration average_duration = 1; */ - private $average_duration = null; + protected $average_duration = null; /** * The average number of turns per conversation. * * Generated from protobuf field int32 average_turn_count = 2; */ - private $average_turn_count = 0; + protected $average_turn_count = 0; /** * The total number of conversations. * * Generated from protobuf field int32 conversation_count = 3; */ - private $conversation_count = 0; + protected $conversation_count = 0; /** * A map associating each smart highlighter display name with its respective * number of matches in the set of conversations. @@ -72,7 +72,7 @@ class CalculateStatsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.CalculateStatsResponse.TimeSeries conversation_count_time_series = 7; */ - private $conversation_count_time_series = null; + protected $conversation_count_time_series = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/CalculateStatsResponse/TimeSeries.php b/ContactCenterInsights/src/V1/CalculateStatsResponse/TimeSeries.php index 009b7e9dbfe2..0b6893ebc034 100644 --- a/ContactCenterInsights/src/V1/CalculateStatsResponse/TimeSeries.php +++ b/ContactCenterInsights/src/V1/CalculateStatsResponse/TimeSeries.php @@ -20,7 +20,7 @@ class TimeSeries extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration interval_duration = 1; */ - private $interval_duration = null; + protected $interval_duration = null; /** * An ordered list of intervals from earliest to latest, where each interval * represents the number of conversations that transpired during the time diff --git a/ContactCenterInsights/src/V1/CalculateStatsResponse/TimeSeries/Interval.php b/ContactCenterInsights/src/V1/CalculateStatsResponse/TimeSeries/Interval.php index ce42dadd19b0..d3633435f4ed 100644 --- a/ContactCenterInsights/src/V1/CalculateStatsResponse/TimeSeries/Interval.php +++ b/ContactCenterInsights/src/V1/CalculateStatsResponse/TimeSeries/Interval.php @@ -20,13 +20,13 @@ class Interval extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp start_time = 1; */ - private $start_time = null; + protected $start_time = null; /** * The number of conversations created in this interval. * * Generated from protobuf field int32 conversation_count = 2; */ - private $conversation_count = 0; + protected $conversation_count = 0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/CallAnnotation.php b/ContactCenterInsights/src/V1/CallAnnotation.php index cf72b3613c65..9b2679366c44 100644 --- a/ContactCenterInsights/src/V1/CallAnnotation.php +++ b/ContactCenterInsights/src/V1/CallAnnotation.php @@ -21,19 +21,19 @@ class CallAnnotation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 channel_tag = 1; */ - private $channel_tag = 0; + protected $channel_tag = 0; /** * The boundary in the conversation where the annotation starts, inclusive. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotationBoundary annotation_start_boundary = 4; */ - private $annotation_start_boundary = null; + protected $annotation_start_boundary = null; /** * The boundary in the conversation where the annotation ends, inclusive. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotationBoundary annotation_end_boundary = 5; */ - private $annotation_end_boundary = null; + protected $annotation_end_boundary = null; protected $data; /** diff --git a/ContactCenterInsights/src/V1/Client/ContactCenterInsightsClient.php b/ContactCenterInsights/src/V1/Client/ContactCenterInsightsClient.php index 347ac9a20793..fca384bdd4f0 100644 --- a/ContactCenterInsights/src/V1/Client/ContactCenterInsightsClient.php +++ b/ContactCenterInsights/src/V1/Client/ContactCenterInsightsClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a analysis * resource. @@ -229,8 +248,12 @@ public function resumeOperation($operationName, $methodName = null) * * @return string The formatted analysis resource. */ - public static function analysisName(string $project, string $location, string $conversation, string $analysis): string - { + public static function analysisName( + string $project, + string $location, + string $conversation, + string $analysis + ): string { return self::getPathTemplate('analysis')->render([ 'project' => $project, 'location' => $location, @@ -268,8 +291,11 @@ public static function conversationName(string $project, string $location, strin * * @return string The formatted conversation_profile resource. */ - public static function conversationProfileName(string $project, string $location, string $conversationProfile): string - { + public static function conversationProfileName( + string $project, + string $location, + string $conversationProfile + ): string { return self::getPathTemplate('conversationProfile')->render([ 'project' => $project, 'location' => $location, @@ -382,8 +408,11 @@ public static function phraseMatcherName(string $project, string $location, stri * * @return string The formatted project_conversation_participant resource. */ - public static function projectConversationParticipantName(string $project, string $conversation, string $participant): string - { + public static function projectConversationParticipantName( + string $project, + string $conversation, + string $participant + ): string { return self::getPathTemplate('projectConversationParticipant')->render([ 'project' => $project, 'conversation' => $conversation, @@ -402,8 +431,12 @@ public static function projectConversationParticipantName(string $project, strin * * @return string The formatted project_location_conversation_participant resource. */ - public static function projectLocationConversationParticipantName(string $project, string $location, string $conversation, string $participant): string - { + public static function projectLocationConversationParticipantName( + string $project, + string $location, + string $conversation, + string $participant + ): string { return self::getPathTemplate('projectLocationConversationParticipant')->render([ 'project' => $project, 'location' => $location, @@ -597,8 +630,10 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function bulkAnalyzeConversations(BulkAnalyzeConversationsRequest $request, array $callOptions = []): OperationResponse - { + public function bulkAnalyzeConversations( + BulkAnalyzeConversationsRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('BulkAnalyzeConversations', $request, $callOptions)->wait(); } @@ -624,8 +659,10 @@ public function bulkAnalyzeConversations(BulkAnalyzeConversationsRequest $reques * * @throws ApiException Thrown if the API call fails. */ - public function bulkDeleteConversations(BulkDeleteConversationsRequest $request, array $callOptions = []): OperationResponse - { + public function bulkDeleteConversations( + BulkDeleteConversationsRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('BulkDeleteConversations', $request, $callOptions)->wait(); } @@ -651,8 +688,10 @@ public function bulkDeleteConversations(BulkDeleteConversationsRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function calculateIssueModelStats(CalculateIssueModelStatsRequest $request, array $callOptions = []): CalculateIssueModelStatsResponse - { + public function calculateIssueModelStats( + CalculateIssueModelStatsRequest $request, + array $callOptions = [] + ): CalculateIssueModelStatsResponse { return $this->startApiCall('CalculateIssueModelStats', $request, $callOptions)->wait(); } diff --git a/ContactCenterInsights/src/V1/ContactCenterInsightsClient.php b/ContactCenterInsights/src/V1/ContactCenterInsightsClient.php deleted file mode 100644 index 6e74aeaaf0fb..000000000000 --- a/ContactCenterInsights/src/V1/ContactCenterInsightsClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\Conversation', 'decode'], - $metadata, $options); - } - - /** - * Create a longrunning conversation upload operation. This method differs - * from CreateConversation by allowing audio transcription and optional DLP - * redaction. - * @param \Google\Cloud\ContactCenterInsights\V1\UploadConversationRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UploadConversation(\Google\Cloud\ContactCenterInsights\V1\UploadConversationRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UploadConversation', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Updates a conversation. - * @param \Google\Cloud\ContactCenterInsights\V1\UpdateConversationRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateConversation(\Google\Cloud\ContactCenterInsights\V1\UpdateConversationRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\Conversation', 'decode'], - $metadata, $options); - } - - /** - * Gets a conversation. - * @param \Google\Cloud\ContactCenterInsights\V1\GetConversationRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetConversation(\Google\Cloud\ContactCenterInsights\V1\GetConversationRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetConversation', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\Conversation', 'decode'], - $metadata, $options); - } - - /** - * Lists conversations. - * @param \Google\Cloud\ContactCenterInsights\V1\ListConversationsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListConversations(\Google\Cloud\ContactCenterInsights\V1\ListConversationsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\ListConversationsResponse', 'decode'], - $metadata, $options); - } - - /** - * Deletes a conversation. - * @param \Google\Cloud\ContactCenterInsights\V1\DeleteConversationRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteConversation(\Google\Cloud\ContactCenterInsights\V1\DeleteConversationRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Creates an analysis. The long running operation is done when the analysis - * has completed. - * @param \Google\Cloud\ContactCenterInsights\V1\CreateAnalysisRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateAnalysis(\Google\Cloud\ContactCenterInsights\V1\CreateAnalysisRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Gets an analysis. - * @param \Google\Cloud\ContactCenterInsights\V1\GetAnalysisRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetAnalysis(\Google\Cloud\ContactCenterInsights\V1\GetAnalysisRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysis', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\Analysis', 'decode'], - $metadata, $options); - } - - /** - * Lists analyses. - * @param \Google\Cloud\ContactCenterInsights\V1\ListAnalysesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListAnalyses(\Google\Cloud\ContactCenterInsights\V1\ListAnalysesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalyses', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\ListAnalysesResponse', 'decode'], - $metadata, $options); - } - - /** - * Deletes an analysis. - * @param \Google\Cloud\ContactCenterInsights\V1\DeleteAnalysisRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteAnalysis(\Google\Cloud\ContactCenterInsights\V1\DeleteAnalysisRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Analyzes multiple conversations in a single request. - * @param \Google\Cloud\ContactCenterInsights\V1\BulkAnalyzeConversationsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function BulkAnalyzeConversations(\Google\Cloud\ContactCenterInsights\V1\BulkAnalyzeConversationsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Imports conversations and processes them according to the user's - * configuration. - * @param \Google\Cloud\ContactCenterInsights\V1\IngestConversationsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function IngestConversations(\Google\Cloud\ContactCenterInsights\V1\IngestConversationsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/IngestConversations', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Export insights data to a destination defined in the request body. - * @param \Google\Cloud\ContactCenterInsights\V1\ExportInsightsDataRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ExportInsightsData(\Google\Cloud\ContactCenterInsights\V1\ExportInsightsDataRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Creates an issue model. - * @param \Google\Cloud\ContactCenterInsights\V1\CreateIssueModelRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateIssueModel(\Google\Cloud\ContactCenterInsights\V1\CreateIssueModelRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Updates an issue model. - * @param \Google\Cloud\ContactCenterInsights\V1\UpdateIssueModelRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateIssueModel(\Google\Cloud\ContactCenterInsights\V1\UpdateIssueModelRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\IssueModel', 'decode'], - $metadata, $options); - } - - /** - * Gets an issue model. - * @param \Google\Cloud\ContactCenterInsights\V1\GetIssueModelRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetIssueModel(\Google\Cloud\ContactCenterInsights\V1\GetIssueModelRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\IssueModel', 'decode'], - $metadata, $options); - } - - /** - * Lists issue models. - * @param \Google\Cloud\ContactCenterInsights\V1\ListIssueModelsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListIssueModels(\Google\Cloud\ContactCenterInsights\V1\ListIssueModelsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\ListIssueModelsResponse', 'decode'], - $metadata, $options); - } - - /** - * Deletes an issue model. - * @param \Google\Cloud\ContactCenterInsights\V1\DeleteIssueModelRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteIssueModel(\Google\Cloud\ContactCenterInsights\V1\DeleteIssueModelRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\ContactCenterInsights\V1\DeployIssueModelRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeployIssueModel(\Google\Cloud\ContactCenterInsights\V1\DeployIssueModelRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Undeploys an issue model. - * An issue model can not be used in analysis after it has been undeployed. - * @param \Google\Cloud\ContactCenterInsights\V1\UndeployIssueModelRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UndeployIssueModel(\Google\Cloud\ContactCenterInsights\V1\UndeployIssueModelRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Gets an issue. - * @param \Google\Cloud\ContactCenterInsights\V1\GetIssueRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetIssue(\Google\Cloud\ContactCenterInsights\V1\GetIssueRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssue', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\Issue', 'decode'], - $metadata, $options); - } - - /** - * Lists issues. - * @param \Google\Cloud\ContactCenterInsights\V1\ListIssuesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListIssues(\Google\Cloud\ContactCenterInsights\V1\ListIssuesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssues', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\ListIssuesResponse', 'decode'], - $metadata, $options); - } - - /** - * Updates an issue. - * @param \Google\Cloud\ContactCenterInsights\V1\UpdateIssueRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateIssue(\Google\Cloud\ContactCenterInsights\V1\UpdateIssueRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\Issue', 'decode'], - $metadata, $options); - } - - /** - * Deletes an issue. - * @param \Google\Cloud\ContactCenterInsights\V1\DeleteIssueRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteIssue(\Google\Cloud\ContactCenterInsights\V1\DeleteIssueRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssue', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Gets an issue model's statistics. - * @param \Google\Cloud\ContactCenterInsights\V1\CalculateIssueModelStatsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CalculateIssueModelStats(\Google\Cloud\ContactCenterInsights\V1\CalculateIssueModelStatsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\CalculateIssueModelStatsResponse', 'decode'], - $metadata, $options); - } - - /** - * Creates a phrase matcher. - * @param \Google\Cloud\ContactCenterInsights\V1\CreatePhraseMatcherRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreatePhraseMatcher(\Google\Cloud\ContactCenterInsights\V1\CreatePhraseMatcherRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\PhraseMatcher', 'decode'], - $metadata, $options); - } - - /** - * Gets a phrase matcher. - * @param \Google\Cloud\ContactCenterInsights\V1\GetPhraseMatcherRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetPhraseMatcher(\Google\Cloud\ContactCenterInsights\V1\GetPhraseMatcherRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\PhraseMatcher', 'decode'], - $metadata, $options); - } - - /** - * Lists phrase matchers. - * @param \Google\Cloud\ContactCenterInsights\V1\ListPhraseMatchersRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListPhraseMatchers(\Google\Cloud\ContactCenterInsights\V1\ListPhraseMatchersRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\ListPhraseMatchersResponse', 'decode'], - $metadata, $options); - } - - /** - * Deletes a phrase matcher. - * @param \Google\Cloud\ContactCenterInsights\V1\DeletePhraseMatcherRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeletePhraseMatcher(\Google\Cloud\ContactCenterInsights\V1\DeletePhraseMatcherRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Updates a phrase matcher. - * @param \Google\Cloud\ContactCenterInsights\V1\UpdatePhraseMatcherRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdatePhraseMatcher(\Google\Cloud\ContactCenterInsights\V1\UpdatePhraseMatcherRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\PhraseMatcher', 'decode'], - $metadata, $options); - } - - /** - * Gets conversation statistics. - * @param \Google\Cloud\ContactCenterInsights\V1\CalculateStatsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CalculateStats(\Google\Cloud\ContactCenterInsights\V1\CalculateStatsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\CalculateStatsResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets project-level settings. - * @param \Google\Cloud\ContactCenterInsights\V1\GetSettingsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetSettings(\Google\Cloud\ContactCenterInsights\V1\GetSettingsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetSettings', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\Settings', 'decode'], - $metadata, $options); - } - - /** - * Updates project-level settings. - * @param \Google\Cloud\ContactCenterInsights\V1\UpdateSettingsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateSettings(\Google\Cloud\ContactCenterInsights\V1\UpdateSettingsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\Settings', 'decode'], - $metadata, $options); - } - - /** - * Creates a view. - * @param \Google\Cloud\ContactCenterInsights\V1\CreateViewRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateView(\Google\Cloud\ContactCenterInsights\V1\CreateViewRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\View', 'decode'], - $metadata, $options); - } - - /** - * Gets a view. - * @param \Google\Cloud\ContactCenterInsights\V1\GetViewRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetView(\Google\Cloud\ContactCenterInsights\V1\GetViewRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\View', 'decode'], - $metadata, $options); - } - - /** - * Lists views. - * @param \Google\Cloud\ContactCenterInsights\V1\ListViewsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListViews(\Google\Cloud\ContactCenterInsights\V1\ListViewsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\ListViewsResponse', 'decode'], - $metadata, $options); - } - - /** - * Updates a view. - * @param \Google\Cloud\ContactCenterInsights\V1\UpdateViewRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateView(\Google\Cloud\ContactCenterInsights\V1\UpdateViewRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView', - $argument, - ['\Google\Cloud\ContactCenterInsights\V1\View', 'decode'], - $metadata, $options); - } - - /** - * Deletes a view. - * @param \Google\Cloud\ContactCenterInsights\V1\DeleteViewRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteView(\Google\Cloud\ContactCenterInsights\V1\DeleteViewRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - -} diff --git a/ContactCenterInsights/src/V1/Conversation.php b/ContactCenterInsights/src/V1/Conversation.php index 2908651f732c..1de28cfd8c8d 100644 --- a/ContactCenterInsights/src/V1/Conversation.php +++ b/ContactCenterInsights/src/V1/Conversation.php @@ -22,44 +22,44 @@ class Conversation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * The source of the audio and transcription for the conversation. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ConversationDataSource data_source = 2; */ - private $data_source = null; + protected $data_source = null; /** * Output only. The time at which the conversation was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The most recent time at which the conversation was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * The time at which the conversation started. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 17; */ - private $start_time = null; + protected $start_time = null; /** * A user-specified language code for the conversation. * * Generated from protobuf field string language_code = 14; */ - private $language_code = ''; + protected $language_code = ''; /** * An opaque, user-specified string representing the human agent who handled * the conversation. * * Generated from protobuf field string agent_id = 5; */ - private $agent_id = ''; + protected $agent_id = ''; /** * A map for the user to specify any custom fields. A maximum of 20 labels per * conversation is allowed, with a maximum of 256 characters per entry. @@ -72,44 +72,44 @@ class Conversation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Conversation.QualityMetadata quality_metadata = 24; */ - private $quality_metadata = null; + protected $quality_metadata = null; /** * Output only. The conversation transcript. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Conversation.Transcript transcript = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $transcript = null; + protected $transcript = null; /** * Immutable. The conversation medium, if unspecified will default to * PHONE_CALL. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Conversation.Medium medium = 9 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $medium = 0; + protected $medium = 0; /** * Output only. The duration of the conversation. * * Generated from protobuf field .google.protobuf.Duration duration = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $duration = null; + protected $duration = null; /** * Output only. The number of turns in the conversation. * * Generated from protobuf field int32 turn_count = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $turn_count = 0; + protected $turn_count = 0; /** * Output only. The conversation's latest analysis, if one exists. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Analysis latest_analysis = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $latest_analysis = null; + protected $latest_analysis = null; /** * Output only. Latest summary of the conversation. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ConversationSummarizationSuggestionData latest_summary = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $latest_summary = null; + protected $latest_summary = null; /** * Output only. The annotations that were generated during the customer and * agent interaction. @@ -130,7 +130,7 @@ class Conversation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string obfuscated_user_id = 21; */ - private $obfuscated_user_id = ''; + protected $obfuscated_user_id = ''; protected $metadata; protected $expiration; diff --git a/ContactCenterInsights/src/V1/Conversation/CallMetadata.php b/ContactCenterInsights/src/V1/Conversation/CallMetadata.php index 42a4b1757fec..220bea1a9c1e 100644 --- a/ContactCenterInsights/src/V1/Conversation/CallMetadata.php +++ b/ContactCenterInsights/src/V1/Conversation/CallMetadata.php @@ -20,13 +20,13 @@ class CallMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 customer_channel = 1; */ - private $customer_channel = 0; + protected $customer_channel = 0; /** * The audio channel that contains the agent. * * Generated from protobuf field int32 agent_channel = 2; */ - private $agent_channel = 0; + protected $agent_channel = 0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Conversation/QualityMetadata.php b/ContactCenterInsights/src/V1/Conversation/QualityMetadata.php index db37db1e5315..6a93ca527fb7 100644 --- a/ContactCenterInsights/src/V1/Conversation/QualityMetadata.php +++ b/ContactCenterInsights/src/V1/Conversation/QualityMetadata.php @@ -20,19 +20,19 @@ class QualityMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 customer_satisfaction_rating = 1; */ - private $customer_satisfaction_rating = 0; + protected $customer_satisfaction_rating = 0; /** * The amount of time the customer waited to connect with an agent. * * Generated from protobuf field .google.protobuf.Duration wait_duration = 2; */ - private $wait_duration = null; + protected $wait_duration = null; /** * An arbitrary string value specifying the menu path the customer took. * * Generated from protobuf field string menu_path = 3; */ - private $menu_path = ''; + protected $menu_path = ''; /** * Information about agents involved in the call. * diff --git a/ContactCenterInsights/src/V1/Conversation/QualityMetadata/AgentInfo.php b/ContactCenterInsights/src/V1/Conversation/QualityMetadata/AgentInfo.php index a70b3e0ea4d1..ac0dbc6bc718 100644 --- a/ContactCenterInsights/src/V1/Conversation/QualityMetadata/AgentInfo.php +++ b/ContactCenterInsights/src/V1/Conversation/QualityMetadata/AgentInfo.php @@ -20,26 +20,26 @@ class AgentInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string agent_id = 1; */ - private $agent_id = ''; + protected $agent_id = ''; /** * The agent's name. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * A user-specified string representing the agent's team. * * Generated from protobuf field string team = 3; */ - private $team = ''; + protected $team = ''; /** * A user-provided string indicating the outcome of the agent's segment of * the call. * * Generated from protobuf field string disposition_code = 4; */ - private $disposition_code = ''; + protected $disposition_code = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment.php b/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment.php index 4b17fdc2910e..c9085129a938 100644 --- a/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment.php +++ b/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment.php @@ -20,20 +20,20 @@ class TranscriptSegment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp message_time = 6; */ - private $message_time = null; + protected $message_time = null; /** * The text of this segment. * * Generated from protobuf field string text = 1; */ - private $text = ''; + protected $text = ''; /** * A confidence estimate between 0.0 and 1.0 of the fidelity of this * segment. A default value of 0.0 indicates that the value is unset. * * Generated from protobuf field float confidence = 2; */ - private $confidence = 0.0; + protected $confidence = 0.0; /** * A list of the word-specific information for each word in the segment. * @@ -47,7 +47,7 @@ class TranscriptSegment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string language_code = 4; */ - private $language_code = ''; + protected $language_code = ''; /** * For conversations derived from multi-channel audio, this is the channel * number corresponding to the audio from that channel. For @@ -56,25 +56,25 @@ class TranscriptSegment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 channel_tag = 5; */ - private $channel_tag = 0; + protected $channel_tag = 0; /** * The participant of this segment. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ConversationParticipant segment_participant = 9; */ - private $segment_participant = null; + protected $segment_participant = null; /** * CCAI metadata relating to the current transcript segment. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata dialogflow_segment_metadata = 10; */ - private $dialogflow_segment_metadata = null; + protected $dialogflow_segment_metadata = null; /** * The sentiment for this transcript segment. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.SentimentData sentiment = 11; */ - private $sentiment = null; + protected $sentiment = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment/DialogflowSegmentMetadata.php b/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment/DialogflowSegmentMetadata.php index 1b93eacf40d9..5c0f10fbae5b 100644 --- a/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment/DialogflowSegmentMetadata.php +++ b/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment/DialogflowSegmentMetadata.php @@ -21,7 +21,7 @@ class DialogflowSegmentMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool smart_reply_allowlist_covered = 1; */ - private $smart_reply_allowlist_covered = false; + protected $smart_reply_allowlist_covered = false; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment/WordInfo.php b/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment/WordInfo.php index f393ed415261..b4226378aac7 100644 --- a/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment/WordInfo.php +++ b/ContactCenterInsights/src/V1/Conversation/Transcript/TranscriptSegment/WordInfo.php @@ -21,27 +21,27 @@ class WordInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration start_offset = 1; */ - private $start_offset = null; + protected $start_offset = null; /** * Time offset of the end of this word relative to the beginning of the * total conversation. * * Generated from protobuf field .google.protobuf.Duration end_offset = 2; */ - private $end_offset = null; + protected $end_offset = null; /** * The word itself. Includes punctuation marks that surround the word. * * Generated from protobuf field string word = 3; */ - private $word = ''; + protected $word = ''; /** * A confidence estimate between 0.0 and 1.0 of the fidelity of this * word. A default value of 0.0 indicates that the value is unset. * * Generated from protobuf field float confidence = 4; */ - private $confidence = 0.0; + protected $confidence = 0.0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/ConversationLevelSentiment.php b/ContactCenterInsights/src/V1/ConversationLevelSentiment.php index 1e823a9fe230..c716a63ac554 100644 --- a/ContactCenterInsights/src/V1/ConversationLevelSentiment.php +++ b/ContactCenterInsights/src/V1/ConversationLevelSentiment.php @@ -20,13 +20,13 @@ class ConversationLevelSentiment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 channel_tag = 1; */ - private $channel_tag = 0; + protected $channel_tag = 0; /** * Data specifying sentiment. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.SentimentData sentiment_data = 2; */ - private $sentiment_data = null; + protected $sentiment_data = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/ConversationParticipant.php b/ContactCenterInsights/src/V1/ConversationParticipant.php index f9166bafeff5..88a7157efd55 100644 --- a/ContactCenterInsights/src/V1/ConversationParticipant.php +++ b/ContactCenterInsights/src/V1/ConversationParticipant.php @@ -29,13 +29,13 @@ class ConversationParticipant extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string obfuscated_external_user_id = 3; */ - private $obfuscated_external_user_id = ''; + protected $obfuscated_external_user_id = ''; /** * The role of the participant. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ConversationParticipant.Role role = 2; */ - private $role = 0; + protected $role = 0; protected $participant; /** diff --git a/ContactCenterInsights/src/V1/ConversationSummarizationSuggestionData.php b/ContactCenterInsights/src/V1/ConversationSummarizationSuggestionData.php index 76c56c4338e8..d4f5e94ae1eb 100644 --- a/ContactCenterInsights/src/V1/ConversationSummarizationSuggestionData.php +++ b/ContactCenterInsights/src/V1/ConversationSummarizationSuggestionData.php @@ -20,7 +20,7 @@ class ConversationSummarizationSuggestionData extends \Google\Protobuf\Internal\ * * Generated from protobuf field string text = 1; */ - private $text = ''; + protected $text = ''; /** * The summarization content that is divided into sections. The key is the * section's name and the value is the section's content. There is no @@ -34,7 +34,7 @@ class ConversationSummarizationSuggestionData extends \Google\Protobuf\Internal\ * * Generated from protobuf field float confidence = 2; */ - private $confidence = 0.0; + protected $confidence = 0.0; /** * A map that contains metadata about the summarization and the document * from which it originates. @@ -49,7 +49,7 @@ class ConversationSummarizationSuggestionData extends \Google\Protobuf\Internal\ * * Generated from protobuf field string answer_record = 4; */ - private $answer_record = ''; + protected $answer_record = ''; /** * The name of the model that generates this summary. * Format: @@ -57,7 +57,7 @@ class ConversationSummarizationSuggestionData extends \Google\Protobuf\Internal\ * * Generated from protobuf field string conversation_model = 6; */ - private $conversation_model = ''; + protected $conversation_model = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/CreateAnalysisOperationMetadata.php b/ContactCenterInsights/src/V1/CreateAnalysisOperationMetadata.php index d7ba7868718f..7afe57a43f92 100644 --- a/ContactCenterInsights/src/V1/CreateAnalysisOperationMetadata.php +++ b/ContactCenterInsights/src/V1/CreateAnalysisOperationMetadata.php @@ -20,25 +20,25 @@ class CreateAnalysisOperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. The Conversation that this Analysis Operation belongs to. * * Generated from protobuf field string conversation = 3 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $conversation = ''; + protected $conversation = ''; /** * Output only. The annotator selector used for the analysis (if any). * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotatorSelector annotator_selector = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $annotator_selector = null; + protected $annotator_selector = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/CreateAnalysisRequest.php b/ContactCenterInsights/src/V1/CreateAnalysisRequest.php index 827f686832a8..08fb29f0ae68 100644 --- a/ContactCenterInsights/src/V1/CreateAnalysisRequest.php +++ b/ContactCenterInsights/src/V1/CreateAnalysisRequest.php @@ -20,13 +20,13 @@ class CreateAnalysisRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The analysis to create. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Analysis analysis = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $analysis = null; + protected $analysis = null; /** * @param string $parent Required. The parent resource of the analysis. Please see diff --git a/ContactCenterInsights/src/V1/CreateConversationRequest.php b/ContactCenterInsights/src/V1/CreateConversationRequest.php index 15aa9d22fd00..b0ee61eaae6c 100644 --- a/ContactCenterInsights/src/V1/CreateConversationRequest.php +++ b/ContactCenterInsights/src/V1/CreateConversationRequest.php @@ -20,13 +20,13 @@ class CreateConversationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The conversation resource to create. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Conversation conversation = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $conversation = null; + protected $conversation = null; /** * A unique ID for the new conversation. This ID will become the final * component of the conversation's resource name. If no ID is specified, a @@ -36,7 +36,7 @@ class CreateConversationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string conversation_id = 3; */ - private $conversation_id = ''; + protected $conversation_id = ''; /** * @param string $parent Required. The parent resource of the conversation. Please see diff --git a/ContactCenterInsights/src/V1/CreateIssueModelMetadata.php b/ContactCenterInsights/src/V1/CreateIssueModelMetadata.php index 5fb8a8532412..17845309a6c8 100644 --- a/ContactCenterInsights/src/V1/CreateIssueModelMetadata.php +++ b/ContactCenterInsights/src/V1/CreateIssueModelMetadata.php @@ -20,19 +20,19 @@ class CreateIssueModelMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * The original request for creation. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.CreateIssueModelRequest request = 3; */ - private $request = null; + protected $request = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/CreateIssueModelRequest.php b/ContactCenterInsights/src/V1/CreateIssueModelRequest.php index 9e4bd7522be7..8b1409a079c1 100644 --- a/ContactCenterInsights/src/V1/CreateIssueModelRequest.php +++ b/ContactCenterInsights/src/V1/CreateIssueModelRequest.php @@ -20,13 +20,13 @@ class CreateIssueModelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The issue model to create. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueModel issue_model = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $issue_model = null; + protected $issue_model = null; /** * @param string $parent Required. The parent resource of the issue model. Please see diff --git a/ContactCenterInsights/src/V1/CreatePhraseMatcherRequest.php b/ContactCenterInsights/src/V1/CreatePhraseMatcherRequest.php index 8c619e20a885..e92bfabbf423 100644 --- a/ContactCenterInsights/src/V1/CreatePhraseMatcherRequest.php +++ b/ContactCenterInsights/src/V1/CreatePhraseMatcherRequest.php @@ -23,13 +23,13 @@ class CreatePhraseMatcherRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The phrase matcher resource to create. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.PhraseMatcher phrase_matcher = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $phrase_matcher = null; + protected $phrase_matcher = null; /** * @param string $parent Required. The parent resource of the phrase matcher. Required. The location diff --git a/ContactCenterInsights/src/V1/CreateViewRequest.php b/ContactCenterInsights/src/V1/CreateViewRequest.php index 6a7c51f57564..f87e03ecb161 100644 --- a/ContactCenterInsights/src/V1/CreateViewRequest.php +++ b/ContactCenterInsights/src/V1/CreateViewRequest.php @@ -23,13 +23,13 @@ class CreateViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The view resource to create. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.View view = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $view = null; + protected $view = null; /** * @param string $parent Required. The parent resource of the view. Required. The location to create diff --git a/ContactCenterInsights/src/V1/DeleteAnalysisRequest.php b/ContactCenterInsights/src/V1/DeleteAnalysisRequest.php index 5574a1858be7..b8265d5a574d 100644 --- a/ContactCenterInsights/src/V1/DeleteAnalysisRequest.php +++ b/ContactCenterInsights/src/V1/DeleteAnalysisRequest.php @@ -20,7 +20,7 @@ class DeleteAnalysisRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the analysis to delete. Please see diff --git a/ContactCenterInsights/src/V1/DeleteConversationRequest.php b/ContactCenterInsights/src/V1/DeleteConversationRequest.php index 3122f0d595e8..78a161a7339e 100644 --- a/ContactCenterInsights/src/V1/DeleteConversationRequest.php +++ b/ContactCenterInsights/src/V1/DeleteConversationRequest.php @@ -20,7 +20,7 @@ class DeleteConversationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * If set to true, all of this conversation's analyses will also be deleted. * Otherwise, the request will only succeed if the conversation has no @@ -28,7 +28,7 @@ class DeleteConversationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool force = 2; */ - private $force = false; + protected $force = false; /** * @param string $name Required. The name of the conversation to delete. Please see diff --git a/ContactCenterInsights/src/V1/DeleteIssueModelMetadata.php b/ContactCenterInsights/src/V1/DeleteIssueModelMetadata.php index 95de1f97f8c5..87dafed4f5f2 100644 --- a/ContactCenterInsights/src/V1/DeleteIssueModelMetadata.php +++ b/ContactCenterInsights/src/V1/DeleteIssueModelMetadata.php @@ -20,19 +20,19 @@ class DeleteIssueModelMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * The original request for deletion. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.DeleteIssueModelRequest request = 3; */ - private $request = null; + protected $request = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/DeleteIssueModelRequest.php b/ContactCenterInsights/src/V1/DeleteIssueModelRequest.php index 54ca658f19b6..7c7da6389c8d 100644 --- a/ContactCenterInsights/src/V1/DeleteIssueModelRequest.php +++ b/ContactCenterInsights/src/V1/DeleteIssueModelRequest.php @@ -20,7 +20,7 @@ class DeleteIssueModelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the issue model to delete. Please see diff --git a/ContactCenterInsights/src/V1/DeleteIssueRequest.php b/ContactCenterInsights/src/V1/DeleteIssueRequest.php index 84aea4551610..8096f2bda03b 100644 --- a/ContactCenterInsights/src/V1/DeleteIssueRequest.php +++ b/ContactCenterInsights/src/V1/DeleteIssueRequest.php @@ -20,7 +20,7 @@ class DeleteIssueRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the issue to delete. Please see diff --git a/ContactCenterInsights/src/V1/DeletePhraseMatcherRequest.php b/ContactCenterInsights/src/V1/DeletePhraseMatcherRequest.php index fecffd58b953..b3ea8b0caeb4 100644 --- a/ContactCenterInsights/src/V1/DeletePhraseMatcherRequest.php +++ b/ContactCenterInsights/src/V1/DeletePhraseMatcherRequest.php @@ -20,7 +20,7 @@ class DeletePhraseMatcherRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the phrase matcher to delete. Please see diff --git a/ContactCenterInsights/src/V1/DeleteViewRequest.php b/ContactCenterInsights/src/V1/DeleteViewRequest.php index 20cb8504cbf9..2980595cc4e5 100644 --- a/ContactCenterInsights/src/V1/DeleteViewRequest.php +++ b/ContactCenterInsights/src/V1/DeleteViewRequest.php @@ -20,7 +20,7 @@ class DeleteViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the view to delete. Please see diff --git a/ContactCenterInsights/src/V1/DeployIssueModelMetadata.php b/ContactCenterInsights/src/V1/DeployIssueModelMetadata.php index b2eb5b00b735..b9fc941ac602 100644 --- a/ContactCenterInsights/src/V1/DeployIssueModelMetadata.php +++ b/ContactCenterInsights/src/V1/DeployIssueModelMetadata.php @@ -20,19 +20,19 @@ class DeployIssueModelMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * The original request for deployment. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.DeployIssueModelRequest request = 3; */ - private $request = null; + protected $request = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/DeployIssueModelRequest.php b/ContactCenterInsights/src/V1/DeployIssueModelRequest.php index c50c60fe2e98..05417f098460 100644 --- a/ContactCenterInsights/src/V1/DeployIssueModelRequest.php +++ b/ContactCenterInsights/src/V1/DeployIssueModelRequest.php @@ -20,7 +20,7 @@ class DeployIssueModelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The issue model to deploy. Please see diff --git a/ContactCenterInsights/src/V1/DialogflowIntent.php b/ContactCenterInsights/src/V1/DialogflowIntent.php index 0a3ad976ff68..43c3bee200f3 100644 --- a/ContactCenterInsights/src/V1/DialogflowIntent.php +++ b/ContactCenterInsights/src/V1/DialogflowIntent.php @@ -21,7 +21,7 @@ class DialogflowIntent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/DialogflowInteractionData.php b/ContactCenterInsights/src/V1/DialogflowInteractionData.php index 0196fadfeedf..c651d75b244f 100644 --- a/ContactCenterInsights/src/V1/DialogflowInteractionData.php +++ b/ContactCenterInsights/src/V1/DialogflowInteractionData.php @@ -21,14 +21,14 @@ class DialogflowInteractionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string dialogflow_intent_id = 1; */ - private $dialogflow_intent_id = ''; + protected $dialogflow_intent_id = ''; /** * The confidence of the match ranging from 0.0 (completely uncertain) to 1.0 * (completely certain). * * Generated from protobuf field float confidence = 2; */ - private $confidence = 0.0; + protected $confidence = 0.0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/DialogflowSource.php b/ContactCenterInsights/src/V1/DialogflowSource.php index 92ea6664a16a..34caa82bc523 100644 --- a/ContactCenterInsights/src/V1/DialogflowSource.php +++ b/ContactCenterInsights/src/V1/DialogflowSource.php @@ -22,14 +22,14 @@ class DialogflowSource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string dialogflow_conversation = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $dialogflow_conversation = ''; + protected $dialogflow_conversation = ''; /** * Cloud Storage URI that points to a file that contains the conversation * audio. * * Generated from protobuf field string audio_uri = 3; */ - private $audio_uri = ''; + protected $audio_uri = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Entity.php b/ContactCenterInsights/src/V1/Entity.php index ccdca7a212b4..0d8782c3a647 100644 --- a/ContactCenterInsights/src/V1/Entity.php +++ b/ContactCenterInsights/src/V1/Entity.php @@ -22,13 +22,13 @@ class Entity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * The entity type. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Entity.Type type = 2; */ - private $type = 0; + protected $type = 0; /** * Metadata associated with the entity. * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) @@ -47,13 +47,13 @@ class Entity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float salience = 4; */ - private $salience = 0.0; + protected $salience = 0.0; /** * The aggregate sentiment expressed for this entity in the conversation. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.SentimentData sentiment = 5; */ - private $sentiment = null; + protected $sentiment = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/EntityMentionData.php b/ContactCenterInsights/src/V1/EntityMentionData.php index 99d2311a8bd2..eba6ca9bc46f 100644 --- a/ContactCenterInsights/src/V1/EntityMentionData.php +++ b/ContactCenterInsights/src/V1/EntityMentionData.php @@ -22,19 +22,19 @@ class EntityMentionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string entity_unique_id = 1; */ - private $entity_unique_id = ''; + protected $entity_unique_id = ''; /** * The type of the entity mention. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.EntityMentionData.MentionType type = 2; */ - private $type = 0; + protected $type = 0; /** * Sentiment expressed for this mention of the entity. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.SentimentData sentiment = 3; */ - private $sentiment = null; + protected $sentiment = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/ExactMatchConfig.php b/ContactCenterInsights/src/V1/ExactMatchConfig.php index 9bb84cd09afb..f9f8af221b17 100644 --- a/ContactCenterInsights/src/V1/ExactMatchConfig.php +++ b/ContactCenterInsights/src/V1/ExactMatchConfig.php @@ -20,7 +20,7 @@ class ExactMatchConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool case_sensitive = 1; */ - private $case_sensitive = false; + protected $case_sensitive = false; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/ExportInsightsDataMetadata.php b/ContactCenterInsights/src/V1/ExportInsightsDataMetadata.php index 4e031556261e..f4808758212b 100644 --- a/ContactCenterInsights/src/V1/ExportInsightsDataMetadata.php +++ b/ContactCenterInsights/src/V1/ExportInsightsDataMetadata.php @@ -20,19 +20,19 @@ class ExportInsightsDataMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * The original request for export. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ExportInsightsDataRequest request = 3; */ - private $request = null; + protected $request = null; /** * Partial errors during export operation that might cause the operation * output to be incomplete. diff --git a/ContactCenterInsights/src/V1/ExportInsightsDataRequest.php b/ContactCenterInsights/src/V1/ExportInsightsDataRequest.php index cbb5940edaa1..6e4f506ab972 100644 --- a/ContactCenterInsights/src/V1/ExportInsightsDataRequest.php +++ b/ContactCenterInsights/src/V1/ExportInsightsDataRequest.php @@ -20,14 +20,14 @@ class ExportInsightsDataRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * A filter to reduce results to a specific subset. Useful for exporting * conversations with specific properties. * * Generated from protobuf field string filter = 3; */ - private $filter = ''; + protected $filter = ''; /** * A fully qualified KMS key name for BigQuery tables protected by CMEK. * Format: @@ -35,13 +35,13 @@ class ExportInsightsDataRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string kms_key = 4; */ - private $kms_key = ''; + protected $kms_key = ''; /** * Options for what to do if the destination table already exists. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ExportInsightsDataRequest.WriteDisposition write_disposition = 5; */ - private $write_disposition = 0; + protected $write_disposition = 0; protected $destination; /** diff --git a/ContactCenterInsights/src/V1/ExportInsightsDataRequest/BigQueryDestination.php b/ContactCenterInsights/src/V1/ExportInsightsDataRequest/BigQueryDestination.php index bf45bb39fe39..e1a2d3df5429 100644 --- a/ContactCenterInsights/src/V1/ExportInsightsDataRequest/BigQueryDestination.php +++ b/ContactCenterInsights/src/V1/ExportInsightsDataRequest/BigQueryDestination.php @@ -22,7 +22,7 @@ class BigQueryDestination extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string project_id = 3; */ - private $project_id = ''; + protected $project_id = ''; /** * Required. The name of the BigQuery dataset that the snapshot result * should be exported to. If this dataset does not exist, the export call @@ -30,7 +30,7 @@ class BigQueryDestination extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string dataset = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $dataset = ''; + protected $dataset = ''; /** * The BigQuery table name to which the insights data should be written. * If this table does not exist, the export call returns an INVALID_ARGUMENT @@ -38,7 +38,7 @@ class BigQueryDestination extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table = 2; */ - private $table = ''; + protected $table = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/FaqAnswerData.php b/ContactCenterInsights/src/V1/FaqAnswerData.php index d80cb5319b93..e6d8e8c35931 100644 --- a/ContactCenterInsights/src/V1/FaqAnswerData.php +++ b/ContactCenterInsights/src/V1/FaqAnswerData.php @@ -20,7 +20,7 @@ class FaqAnswerData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string answer = 1; */ - private $answer = ''; + protected $answer = ''; /** * The system's confidence score that this answer is a good match for this * conversation, ranging from 0.0 (completely uncertain) to 1.0 (completely @@ -28,13 +28,13 @@ class FaqAnswerData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float confidence_score = 2; */ - private $confidence_score = 0.0; + protected $confidence_score = 0.0; /** * The corresponding FAQ question. * * Generated from protobuf field string question = 3; */ - private $question = ''; + protected $question = ''; /** * Map that contains metadata about the FAQ answer and the document that * it originates from. @@ -49,7 +49,7 @@ class FaqAnswerData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string query_record = 5; */ - private $query_record = ''; + protected $query_record = ''; /** * The knowledge document that this answer was extracted from. * Format: @@ -57,7 +57,7 @@ class FaqAnswerData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source = 6; */ - private $source = ''; + protected $source = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Gapic/ContactCenterInsightsGapicClient.php b/ContactCenterInsights/src/V1/Gapic/ContactCenterInsightsGapicClient.php deleted file mode 100644 index ea4580a5b760..000000000000 --- a/ContactCenterInsights/src/V1/Gapic/ContactCenterInsightsGapicClient.php +++ /dev/null @@ -1,3329 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $filter = 'filter'; - * $analysisPercentage = 0.0; - * $operationResponse = $contactCenterInsightsClient->bulkAnalyzeConversations($formattedParent, $filter, $analysisPercentage); - * $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 = $contactCenterInsightsClient->bulkAnalyzeConversations($formattedParent, $filter, $analysisPercentage); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'bulkAnalyzeConversations'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\ContactCenterInsights\V1\Client\ContactCenterInsightsClient}. - */ -class ContactCenterInsightsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.contactcenterinsights.v1.ContactCenterInsights'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'contactcenterinsights.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'contactcenterinsights.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $analysisNameTemplate; - - private static $conversationNameTemplate; - - private static $conversationProfileNameTemplate; - - private static $issueNameTemplate; - - private static $issueModelNameTemplate; - - private static $locationNameTemplate; - - private static $participantNameTemplate; - - private static $phraseMatcherNameTemplate; - - private static $projectConversationParticipantNameTemplate; - - private static $projectLocationConversationParticipantNameTemplate; - - private static $recognizerNameTemplate; - - private static $settingsNameTemplate; - - private static $viewNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getAnalysisNameTemplate() - { - if (self::$analysisNameTemplate == null) { - self::$analysisNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis}' - ); - } - - return self::$analysisNameTemplate; - } - - private static function getConversationNameTemplate() - { - if (self::$conversationNameTemplate == null) { - self::$conversationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/conversations/{conversation}' - ); - } - - return self::$conversationNameTemplate; - } - - private static function getConversationProfileNameTemplate() - { - if (self::$conversationProfileNameTemplate == null) { - self::$conversationProfileNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/conversationProfiles/{conversation_profile}' - ); - } - - return self::$conversationProfileNameTemplate; - } - - private static function getIssueNameTemplate() - { - if (self::$issueNameTemplate == null) { - self::$issueNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue}' - ); - } - - return self::$issueNameTemplate; - } - - private static function getIssueModelNameTemplate() - { - if (self::$issueModelNameTemplate == null) { - self::$issueModelNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/issueModels/{issue_model}' - ); - } - - return self::$issueModelNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getParticipantNameTemplate() - { - if (self::$participantNameTemplate == null) { - self::$participantNameTemplate = new PathTemplate( - 'projects/{project}/conversations/{conversation}/participants/{participant}' - ); - } - - return self::$participantNameTemplate; - } - - private static function getPhraseMatcherNameTemplate() - { - if (self::$phraseMatcherNameTemplate == null) { - self::$phraseMatcherNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}' - ); - } - - return self::$phraseMatcherNameTemplate; - } - - private static function getProjectConversationParticipantNameTemplate() - { - if (self::$projectConversationParticipantNameTemplate == null) { - self::$projectConversationParticipantNameTemplate = new PathTemplate( - 'projects/{project}/conversations/{conversation}/participants/{participant}' - ); - } - - return self::$projectConversationParticipantNameTemplate; - } - - private static function getProjectLocationConversationParticipantNameTemplate() - { - if (self::$projectLocationConversationParticipantNameTemplate == null) { - self::$projectLocationConversationParticipantNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant}' - ); - } - - return self::$projectLocationConversationParticipantNameTemplate; - } - - private static function getRecognizerNameTemplate() - { - if (self::$recognizerNameTemplate == null) { - self::$recognizerNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/recognizers/{recognizer}' - ); - } - - return self::$recognizerNameTemplate; - } - - private static function getSettingsNameTemplate() - { - if (self::$settingsNameTemplate == null) { - self::$settingsNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/settings' - ); - } - - return self::$settingsNameTemplate; - } - - private static function getViewNameTemplate() - { - if (self::$viewNameTemplate == null) { - self::$viewNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/views/{view}' - ); - } - - return self::$viewNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'analysis' => self::getAnalysisNameTemplate(), - 'conversation' => self::getConversationNameTemplate(), - 'conversationProfile' => self::getConversationProfileNameTemplate(), - 'issue' => self::getIssueNameTemplate(), - 'issueModel' => self::getIssueModelNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'participant' => self::getParticipantNameTemplate(), - 'phraseMatcher' => self::getPhraseMatcherNameTemplate(), - 'projectConversationParticipant' => self::getProjectConversationParticipantNameTemplate(), - 'projectLocationConversationParticipant' => self::getProjectLocationConversationParticipantNameTemplate(), - 'recognizer' => self::getRecognizerNameTemplate(), - 'settings' => self::getSettingsNameTemplate(), - 'view' => self::getViewNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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( - $project, - $location, - $conversation, - $analysis - ) { - return self::getAnalysisNameTemplate()->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($project, $location, $conversation) - { - return self::getConversationNameTemplate()->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( - $project, - $location, - $conversationProfile - ) { - return self::getConversationProfileNameTemplate()->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($project, $location, $issueModel, $issue) - { - return self::getIssueNameTemplate()->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($project, $location, $issueModel) - { - return self::getIssueModelNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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( - $project, - $conversation, - $participant - ) { - return self::getParticipantNameTemplate()->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( - $project, - $location, - $phraseMatcher - ) { - return self::getPhraseMatcherNameTemplate()->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( - $project, - $conversation, - $participant - ) { - return self::getProjectConversationParticipantNameTemplate()->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( - $project, - $location, - $conversation, - $participant - ) { - return self::getProjectLocationConversationParticipantNameTemplate()->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($project, $location, $recognizer) - { - return self::getRecognizerNameTemplate()->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($project, $location) - { - return self::getSettingsNameTemplate()->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($project, $location, $view) - { - return self::getViewNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Analyzes multiple conversations in a single request. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $filter = 'filter'; - * $analysisPercentage = 0.0; - * $operationResponse = $contactCenterInsightsClient->bulkAnalyzeConversations($formattedParent, $filter, $analysisPercentage); - * $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 = $contactCenterInsightsClient->bulkAnalyzeConversations($formattedParent, $filter, $analysisPercentage); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'bulkAnalyzeConversations'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource to create analyses in. - * @param string $filter Required. Filter used to select the subset of conversations to analyze. - * @param float $analysisPercentage Required. Percentage of selected conversation to analyze, between - * [0, 100]. - * @param array $optionalArgs { - * Optional. - * - * @type AnnotatorSelector $annotatorSelector - * To select the annotators to run and the phrase matchers to use - * (if any). If not specified, all annotators will be run. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 bulkAnalyzeConversations( - $parent, - $filter, - $analysisPercentage, - array $optionalArgs = [] - ) { - $request = new BulkAnalyzeConversationsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setFilter($filter); - $request->setAnalysisPercentage($analysisPercentage); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['annotatorSelector'])) { - $request->setAnnotatorSelector($optionalArgs['annotatorSelector']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'BulkAnalyzeConversations', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes multiple conversations in a single request. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $operationResponse = $contactCenterInsightsClient->bulkDeleteConversations($formattedParent); - * $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 = $contactCenterInsightsClient->bulkDeleteConversations($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'bulkDeleteConversations'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource to delete conversations from. - * Format: - * projects/{project}/locations/{location} - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * Filter used to select the subset of conversations to delete. - * @type int $maxDeleteCount - * Maximum number of conversations to delete. - * @type bool $force - * If set to true, all of this conversation's analyses will also be deleted. - * Otherwise, the request will only succeed if the conversation has no - * analyses. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 bulkDeleteConversations($parent, array $optionalArgs = []) - { - $request = new BulkDeleteConversationsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['maxDeleteCount'])) { - $request->setMaxDeleteCount($optionalArgs['maxDeleteCount']); - } - - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'BulkDeleteConversations', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets an issue model's statistics. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedIssueModel = $contactCenterInsightsClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - * $response = $contactCenterInsightsClient->calculateIssueModelStats($formattedIssueModel); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $issueModel Required. The resource name of the issue model to query against. - * @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\ContactCenterInsights\V1\CalculateIssueModelStatsResponse - * - * @throws ApiException if the remote call fails - */ - public function calculateIssueModelStats( - $issueModel, - array $optionalArgs = [] - ) { - $request = new CalculateIssueModelStatsRequest(); - $requestParamHeaders = []; - $request->setIssueModel($issueModel); - $requestParamHeaders['issue_model'] = $issueModel; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CalculateIssueModelStats', - CalculateIssueModelStatsResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets conversation statistics. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedLocation = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $response = $contactCenterInsightsClient->calculateStats($formattedLocation); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $location Required. The location of the conversations. - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * A filter to reduce results to a specific subset. This field is useful for - * getting statistics about conversations with specific properties. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\ContactCenterInsights\V1\CalculateStatsResponse - * - * @throws ApiException if the remote call fails - */ - public function calculateStats($location, array $optionalArgs = []) - { - $request = new CalculateStatsRequest(); - $requestParamHeaders = []; - $request->setLocation($location); - $requestParamHeaders['location'] = $location; - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CalculateStats', - CalculateStatsResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Creates an analysis. The long running operation is done when the analysis - * has completed. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - * $analysis = new Analysis(); - * $operationResponse = $contactCenterInsightsClient->createAnalysis($formattedParent, $analysis); - * $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 = $contactCenterInsightsClient->createAnalysis($formattedParent, $analysis); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'createAnalysis'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the analysis. - * @param Analysis $analysis Required. The analysis to create. - * @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 createAnalysis($parent, $analysis, array $optionalArgs = []) - { - $request = new CreateAnalysisRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setAnalysis($analysis); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateAnalysis', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Creates a conversation. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $conversation = new Conversation(); - * $response = $contactCenterInsightsClient->createConversation($formattedParent, $conversation); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the conversation. - * @param Conversation $conversation Required. The conversation resource to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $conversationId - * A unique ID for the new conversation. This ID will become the final - * component of the conversation's resource name. If no ID is specified, a - * server-generated ID will be used. - * - * This value should be 4-64 characters and must match the regular - * expression `^[a-z0-9-]{4,64}$`. Valid characters 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 - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\ContactCenterInsights\V1\Conversation - * - * @throws ApiException if the remote call fails - */ - public function createConversation( - $parent, - $conversation, - array $optionalArgs = [] - ) { - $request = new CreateConversationRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setConversation($conversation); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['conversationId'])) { - $request->setConversationId($optionalArgs['conversationId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateConversation', - Conversation::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Creates an issue model. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $issueModel = new IssueModel(); - * $operationResponse = $contactCenterInsightsClient->createIssueModel($formattedParent, $issueModel); - * $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 = $contactCenterInsightsClient->createIssueModel($formattedParent, $issueModel); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'createIssueModel'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the issue model. - * @param IssueModel $issueModel Required. The issue model to create. - * @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 createIssueModel( - $parent, - $issueModel, - array $optionalArgs = [] - ) { - $request = new CreateIssueModelRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setIssueModel($issueModel); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateIssueModel', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Creates a phrase matcher. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $phraseMatcher = new PhraseMatcher(); - * $response = $contactCenterInsightsClient->createPhraseMatcher($formattedParent, $phraseMatcher); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the phrase matcher. Required. The location - * to create a phrase matcher for. Format: `projects//locations/` or `projects//locations/` - * @param PhraseMatcher $phraseMatcher Required. The phrase matcher resource to create. - * @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\ContactCenterInsights\V1\PhraseMatcher - * - * @throws ApiException if the remote call fails - */ - public function createPhraseMatcher( - $parent, - $phraseMatcher, - array $optionalArgs = [] - ) { - $request = new CreatePhraseMatcherRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setPhraseMatcher($phraseMatcher); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreatePhraseMatcher', - PhraseMatcher::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Creates a view. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $view = new View(); - * $response = $contactCenterInsightsClient->createView($formattedParent, $view); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the view. Required. The location to create - * a view for. - * Format: `projects//locations/` or - * `projects//locations/` - * @param View $view Required. The view resource to create. - * @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\ContactCenterInsights\V1\View - * - * @throws ApiException if the remote call fails - */ - public function createView($parent, $view, array $optionalArgs = []) - { - $request = new CreateViewRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setView($view); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateView', - View::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes an analysis. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - * $contactCenterInsightsClient->deleteAnalysis($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the analysis to delete. - * @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 deleteAnalysis($name, array $optionalArgs = []) - { - $request = new DeleteAnalysisRequest(); - $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( - 'DeleteAnalysis', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a conversation. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - * $contactCenterInsightsClient->deleteConversation($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the conversation to delete. - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * If set to true, all of this conversation's analyses will also be deleted. - * Otherwise, the request will only succeed if the conversation has no - * analyses. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 deleteConversation($name, array $optionalArgs = []) - { - $request = new DeleteConversationRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'DeleteConversation', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes an issue. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - * $contactCenterInsightsClient->deleteIssue($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the issue to delete. - * @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 deleteIssue($name, array $optionalArgs = []) - { - $request = new DeleteIssueRequest(); - $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( - 'DeleteIssue', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes an issue model. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - * $operationResponse = $contactCenterInsightsClient->deleteIssueModel($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 = $contactCenterInsightsClient->deleteIssueModel($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'deleteIssueModel'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the issue model to delete. - * @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 deleteIssueModel($name, array $optionalArgs = []) - { - $request = new DeleteIssueModelRequest(); - $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( - 'DeleteIssueModel', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a phrase matcher. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - * $contactCenterInsightsClient->deletePhraseMatcher($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the phrase matcher to delete. - * @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 deletePhraseMatcher($name, array $optionalArgs = []) - { - $request = new DeletePhraseMatcherRequest(); - $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( - 'DeletePhraseMatcher', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a view. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - * $contactCenterInsightsClient->deleteView($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the view to delete. - * @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 deleteView($name, array $optionalArgs = []) - { - $request = new DeleteViewRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'DeleteView', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * 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. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - * $operationResponse = $contactCenterInsightsClient->deployIssueModel($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 = $contactCenterInsightsClient->deployIssueModel($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'deployIssueModel'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The issue model to deploy. - * @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 deployIssueModel($name, array $optionalArgs = []) - { - $request = new DeployIssueModelRequest(); - $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( - 'DeployIssueModel', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Export insights data to a destination defined in the request body. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $operationResponse = $contactCenterInsightsClient->exportInsightsData($formattedParent); - * $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 = $contactCenterInsightsClient->exportInsightsData($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'exportInsightsData'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource to export data from. - * @param array $optionalArgs { - * Optional. - * - * @type BigQueryDestination $bigQueryDestination - * Specified if sink is a BigQuery table. - * @type string $filter - * A filter to reduce results to a specific subset. Useful for exporting - * conversations with specific properties. - * @type string $kmsKey - * A fully qualified KMS key name for BigQuery tables protected by CMEK. - * Format: - * projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}/cryptoKeyVersions/{version} - * @type int $writeDisposition - * Options for what to do if the destination table already exists. - * For allowed values, use constants defined on {@see \Google\Cloud\ContactCenterInsights\V1\ExportInsightsDataRequest\WriteDisposition} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 exportInsightsData($parent, array $optionalArgs = []) - { - $request = new ExportInsightsDataRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['bigQueryDestination'])) { - $request->setBigQueryDestination( - $optionalArgs['bigQueryDestination'] - ); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['kmsKey'])) { - $request->setKmsKey($optionalArgs['kmsKey']); - } - - if (isset($optionalArgs['writeDisposition'])) { - $request->setWriteDisposition($optionalArgs['writeDisposition']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'ExportInsightsData', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets an analysis. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - * $response = $contactCenterInsightsClient->getAnalysis($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the analysis to get. - * @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\ContactCenterInsights\V1\Analysis - * - * @throws ApiException if the remote call fails - */ - public function getAnalysis($name, array $optionalArgs = []) - { - $request = new GetAnalysisRequest(); - $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( - 'GetAnalysis', - Analysis::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets a conversation. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - * $response = $contactCenterInsightsClient->getConversation($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the conversation to get. - * @param array $optionalArgs { - * Optional. - * - * @type int $view - * The level of details of the conversation. Default is `FULL`. - * For allowed values, use constants defined on {@see \Google\Cloud\ContactCenterInsights\V1\ConversationView} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\ContactCenterInsights\V1\Conversation - * - * @throws ApiException if the remote call fails - */ - public function getConversation($name, array $optionalArgs = []) - { - $request = new GetConversationRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetConversation', - Conversation::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets an issue. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - * $response = $contactCenterInsightsClient->getIssue($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the issue to get. - * @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\ContactCenterInsights\V1\Issue - * - * @throws ApiException if the remote call fails - */ - public function getIssue($name, array $optionalArgs = []) - { - $request = new GetIssueRequest(); - $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( - 'GetIssue', - Issue::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets an issue model. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - * $response = $contactCenterInsightsClient->getIssueModel($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the issue model to get. - * @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\ContactCenterInsights\V1\IssueModel - * - * @throws ApiException if the remote call fails - */ - public function getIssueModel($name, array $optionalArgs = []) - { - $request = new GetIssueModelRequest(); - $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( - 'GetIssueModel', - IssueModel::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets a phrase matcher. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - * $response = $contactCenterInsightsClient->getPhraseMatcher($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the phrase matcher to get. - * @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\ContactCenterInsights\V1\PhraseMatcher - * - * @throws ApiException if the remote call fails - */ - public function getPhraseMatcher($name, array $optionalArgs = []) - { - $request = new GetPhraseMatcherRequest(); - $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( - 'GetPhraseMatcher', - PhraseMatcher::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets project-level settings. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->settingsName('[PROJECT]', '[LOCATION]'); - * $response = $contactCenterInsightsClient->getSettings($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the settings resource to get. - * @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\ContactCenterInsights\V1\Settings - * - * @throws ApiException if the remote call fails - */ - public function getSettings($name, array $optionalArgs = []) - { - $request = new GetSettingsRequest(); - $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( - 'GetSettings', - Settings::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets a view. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - * $response = $contactCenterInsightsClient->getView($formattedName); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the view to get. - * @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\ContactCenterInsights\V1\View - * - * @throws ApiException if the remote call fails - */ - public function getView($name, array $optionalArgs = []) - { - $request = new GetViewRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetView', - View::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Imports conversations and processes them according to the user's - * configuration. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $operationResponse = $contactCenterInsightsClient->ingestConversations($formattedParent); - * $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 = $contactCenterInsightsClient->ingestConversations($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'ingestConversations'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource for new conversations. - * @param array $optionalArgs { - * Optional. - * - * @type GcsSource $gcsSource - * A cloud storage bucket source. Note that any previously ingested objects - * from the source will be skipped to avoid duplication. - * @type TranscriptObjectConfig $transcriptObjectConfig - * Configuration for when `source` contains conversation transcripts. - * @type ConversationConfig $conversationConfig - * Configuration that applies to all conversations. - * @type RedactionConfig $redactionConfig - * Optional. DLP settings for transcript redaction. Optional, will default to - * the config specified in Settings. - * @type SpeechConfig $speechConfig - * Optional. Default Speech-to-Text configuration. Optional, will default to - * the config specified in Settings. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 ingestConversations($parent, array $optionalArgs = []) - { - $request = new IngestConversationsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['gcsSource'])) { - $request->setGcsSource($optionalArgs['gcsSource']); - } - - if (isset($optionalArgs['transcriptObjectConfig'])) { - $request->setTranscriptObjectConfig( - $optionalArgs['transcriptObjectConfig'] - ); - } - - if (isset($optionalArgs['conversationConfig'])) { - $request->setConversationConfig( - $optionalArgs['conversationConfig'] - ); - } - - if (isset($optionalArgs['redactionConfig'])) { - $request->setRedactionConfig($optionalArgs['redactionConfig']); - } - - if (isset($optionalArgs['speechConfig'])) { - $request->setSpeechConfig($optionalArgs['speechConfig']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'IngestConversations', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Lists analyses. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - * // Iterate over pages of elements - * $pagedResponse = $contactCenterInsightsClient->listAnalyses($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $contactCenterInsightsClient->listAnalyses($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the analyses. - * @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 string $filter - * A filter to reduce results to a specific subset. Useful for querying - * conversations with specific properties. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listAnalyses($parent, array $optionalArgs = []) - { - $request = new ListAnalysesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListAnalyses', - $optionalArgs, - ListAnalysesResponse::class, - $request - ); - } - - /** - * Lists conversations. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $contactCenterInsightsClient->listConversations($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $contactCenterInsightsClient->listConversations($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the conversation. - * @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 string $filter - * A filter to reduce results to a specific subset. Useful for querying - * conversations with specific properties. - * @type int $view - * The level of details of the conversation. Default is `BASIC`. - * For allowed values, use constants defined on {@see \Google\Cloud\ContactCenterInsights\V1\ConversationView} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listConversations($parent, array $optionalArgs = []) - { - $request = new ListConversationsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListConversations', - $optionalArgs, - ListConversationsResponse::class, - $request - ); - } - - /** - * Lists issue models. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $response = $contactCenterInsightsClient->listIssueModels($formattedParent); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the issue model. - * @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\ContactCenterInsights\V1\ListIssueModelsResponse - * - * @throws ApiException if the remote call fails - */ - public function listIssueModels($parent, array $optionalArgs = []) - { - $request = new ListIssueModelsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'ListIssueModels', - ListIssueModelsResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists issues. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - * $response = $contactCenterInsightsClient->listIssues($formattedParent); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the issue. - * @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\ContactCenterInsights\V1\ListIssuesResponse - * - * @throws ApiException if the remote call fails - */ - public function listIssues($parent, array $optionalArgs = []) - { - $request = new ListIssuesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'ListIssues', - ListIssuesResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists phrase matchers. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $contactCenterInsightsClient->listPhraseMatchers($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $contactCenterInsightsClient->listPhraseMatchers($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the phrase matcher. - * @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 string $filter - * A filter to reduce results to a specific subset. Useful for querying - * phrase matchers with specific properties. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listPhraseMatchers($parent, array $optionalArgs = []) - { - $request = new ListPhraseMatchersRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListPhraseMatchers', - $optionalArgs, - ListPhraseMatchersResponse::class, - $request - ); - } - - /** - * Lists views. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $contactCenterInsightsClient->listViews($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $contactCenterInsightsClient->listViews($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the views. - * @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 listViews($parent, array $optionalArgs = []) - { - $request = new ListViewsRequest(); - $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( - 'ListViews', - $optionalArgs, - ListViewsResponse::class, - $request - ); - } - - /** - * Undeploys an issue model. - * An issue model can not be used in analysis after it has been undeployed. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedName = $contactCenterInsightsClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - * $operationResponse = $contactCenterInsightsClient->undeployIssueModel($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 = $contactCenterInsightsClient->undeployIssueModel($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'undeployIssueModel'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $name Required. The issue model to undeploy. - * @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 undeployIssueModel($name, array $optionalArgs = []) - { - $request = new UndeployIssueModelRequest(); - $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( - 'UndeployIssueModel', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Updates a conversation. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $conversation = new Conversation(); - * $response = $contactCenterInsightsClient->updateConversation($conversation); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param Conversation $conversation Required. The new values for the conversation. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to 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\ContactCenterInsights\V1\Conversation - * - * @throws ApiException if the remote call fails - */ - public function updateConversation($conversation, array $optionalArgs = []) - { - $request = new UpdateConversationRequest(); - $requestParamHeaders = []; - $request->setConversation($conversation); - $requestParamHeaders['conversation.name'] = $conversation->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( - 'UpdateConversation', - Conversation::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates an issue. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $issue = new Issue(); - * $response = $contactCenterInsightsClient->updateIssue($issue); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param Issue $issue Required. The new values for the issue. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to 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\ContactCenterInsights\V1\Issue - * - * @throws ApiException if the remote call fails - */ - public function updateIssue($issue, array $optionalArgs = []) - { - $request = new UpdateIssueRequest(); - $requestParamHeaders = []; - $request->setIssue($issue); - $requestParamHeaders['issue.name'] = $issue->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( - 'UpdateIssue', - Issue::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates an issue model. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $issueModel = new IssueModel(); - * $response = $contactCenterInsightsClient->updateIssueModel($issueModel); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param IssueModel $issueModel Required. The new values for the issue model. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to 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\ContactCenterInsights\V1\IssueModel - * - * @throws ApiException if the remote call fails - */ - public function updateIssueModel($issueModel, array $optionalArgs = []) - { - $request = new UpdateIssueModelRequest(); - $requestParamHeaders = []; - $request->setIssueModel($issueModel); - $requestParamHeaders['issue_model.name'] = $issueModel->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( - 'UpdateIssueModel', - IssueModel::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates a phrase matcher. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $phraseMatcher = new PhraseMatcher(); - * $response = $contactCenterInsightsClient->updatePhraseMatcher($phraseMatcher); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param PhraseMatcher $phraseMatcher Required. The new values for the phrase matcher. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to 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\ContactCenterInsights\V1\PhraseMatcher - * - * @throws ApiException if the remote call fails - */ - public function updatePhraseMatcher( - $phraseMatcher, - array $optionalArgs = [] - ) { - $request = new UpdatePhraseMatcherRequest(); - $requestParamHeaders = []; - $request->setPhraseMatcher($phraseMatcher); - $requestParamHeaders['phrase_matcher.name'] = $phraseMatcher->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( - 'UpdatePhraseMatcher', - PhraseMatcher::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates project-level settings. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $settings = new Settings(); - * $updateMask = new FieldMask(); - * $response = $contactCenterInsightsClient->updateSettings($settings, $updateMask); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param Settings $settings Required. The new settings values. - * @param FieldMask $updateMask Required. The list of fields to be updated. - * @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\ContactCenterInsights\V1\Settings - * - * @throws ApiException if the remote call fails - */ - public function updateSettings( - $settings, - $updateMask, - array $optionalArgs = [] - ) { - $request = new UpdateSettingsRequest(); - $requestParamHeaders = []; - $request->setSettings($settings); - $request->setUpdateMask($updateMask); - $requestParamHeaders['settings.name'] = $settings->getName(); - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'UpdateSettings', - Settings::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates a view. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $view = new View(); - * $response = $contactCenterInsightsClient->updateView($view); - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param View $view Required. The new view. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to 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\ContactCenterInsights\V1\View - * - * @throws ApiException if the remote call fails - */ - public function updateView($view, array $optionalArgs = []) - { - $request = new UpdateViewRequest(); - $requestParamHeaders = []; - $request->setView($view); - $requestParamHeaders['view.name'] = $view->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( - 'UpdateView', - View::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Create a longrunning conversation upload operation. This method differs - * from CreateConversation by allowing audio transcription and optional DLP - * redaction. - * - * Sample code: - * ``` - * $contactCenterInsightsClient = new ContactCenterInsightsClient(); - * try { - * $formattedParent = $contactCenterInsightsClient->locationName('[PROJECT]', '[LOCATION]'); - * $conversation = new Conversation(); - * $operationResponse = $contactCenterInsightsClient->uploadConversation($formattedParent, $conversation); - * $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 = $contactCenterInsightsClient->uploadConversation($formattedParent, $conversation); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $contactCenterInsightsClient->resumeOperation($operationName, 'uploadConversation'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $contactCenterInsightsClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the conversation. - * @param Conversation $conversation Required. The conversation resource to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $conversationId - * Optional. A unique ID for the new conversation. This ID will become the - * final component of the conversation's resource name. If no ID is specified, - * a server-generated ID will be used. - * - * This value should be 4-64 characters and must match the regular - * expression `^[a-z0-9-]{4,64}$`. Valid characters are `[a-z][0-9]-` - * @type RedactionConfig $redactionConfig - * Optional. DLP settings for transcript redaction. Will default to the config - * specified in Settings. - * @type SpeechConfig $speechConfig - * Optional. Speech-to-Text configuration. Will default to the config - * specified in Settings. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 uploadConversation( - $parent, - $conversation, - array $optionalArgs = [] - ) { - $request = new UploadConversationRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setConversation($conversation); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['conversationId'])) { - $request->setConversationId($optionalArgs['conversationId']); - } - - if (isset($optionalArgs['redactionConfig'])) { - $request->setRedactionConfig($optionalArgs['redactionConfig']); - } - - if (isset($optionalArgs['speechConfig'])) { - $request->setSpeechConfig($optionalArgs['speechConfig']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UploadConversation', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } -} diff --git a/ContactCenterInsights/src/V1/GcsSource.php b/ContactCenterInsights/src/V1/GcsSource.php index 72ae101fc2a0..2125a846c4af 100644 --- a/ContactCenterInsights/src/V1/GcsSource.php +++ b/ContactCenterInsights/src/V1/GcsSource.php @@ -21,14 +21,14 @@ class GcsSource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string audio_uri = 1; */ - private $audio_uri = ''; + protected $audio_uri = ''; /** * Immutable. Cloud Storage URI that points to a file that contains the * conversation transcript. * * Generated from protobuf field string transcript_uri = 2 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $transcript_uri = ''; + protected $transcript_uri = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/GetAnalysisRequest.php b/ContactCenterInsights/src/V1/GetAnalysisRequest.php index ee844c5c57fe..a46e863a67e9 100644 --- a/ContactCenterInsights/src/V1/GetAnalysisRequest.php +++ b/ContactCenterInsights/src/V1/GetAnalysisRequest.php @@ -20,7 +20,7 @@ class GetAnalysisRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the analysis to get. Please see diff --git a/ContactCenterInsights/src/V1/GetConversationRequest.php b/ContactCenterInsights/src/V1/GetConversationRequest.php index 8b218f73d494..7c69e507e417 100644 --- a/ContactCenterInsights/src/V1/GetConversationRequest.php +++ b/ContactCenterInsights/src/V1/GetConversationRequest.php @@ -20,13 +20,13 @@ class GetConversationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * The level of details of the conversation. Default is `FULL`. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ConversationView view = 2; */ - private $view = 0; + protected $view = 0; /** * @param string $name Required. The name of the conversation to get. Please see diff --git a/ContactCenterInsights/src/V1/GetIssueModelRequest.php b/ContactCenterInsights/src/V1/GetIssueModelRequest.php index ad513854ce47..0de9b87c59ea 100644 --- a/ContactCenterInsights/src/V1/GetIssueModelRequest.php +++ b/ContactCenterInsights/src/V1/GetIssueModelRequest.php @@ -20,7 +20,7 @@ class GetIssueModelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the issue model to get. Please see diff --git a/ContactCenterInsights/src/V1/GetIssueRequest.php b/ContactCenterInsights/src/V1/GetIssueRequest.php index e774e506a9ca..6ce5364cc99a 100644 --- a/ContactCenterInsights/src/V1/GetIssueRequest.php +++ b/ContactCenterInsights/src/V1/GetIssueRequest.php @@ -20,7 +20,7 @@ class GetIssueRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the issue to get. Please see diff --git a/ContactCenterInsights/src/V1/GetPhraseMatcherRequest.php b/ContactCenterInsights/src/V1/GetPhraseMatcherRequest.php index d14ebd231deb..cfdbf04b0d0f 100644 --- a/ContactCenterInsights/src/V1/GetPhraseMatcherRequest.php +++ b/ContactCenterInsights/src/V1/GetPhraseMatcherRequest.php @@ -20,7 +20,7 @@ class GetPhraseMatcherRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the phrase matcher to get. Please see diff --git a/ContactCenterInsights/src/V1/GetSettingsRequest.php b/ContactCenterInsights/src/V1/GetSettingsRequest.php index 775890e0785e..91add76d1818 100644 --- a/ContactCenterInsights/src/V1/GetSettingsRequest.php +++ b/ContactCenterInsights/src/V1/GetSettingsRequest.php @@ -20,7 +20,7 @@ class GetSettingsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the settings resource to get. Please see diff --git a/ContactCenterInsights/src/V1/GetViewRequest.php b/ContactCenterInsights/src/V1/GetViewRequest.php index 8bd3e74f3c6c..0f38bc1c31e2 100644 --- a/ContactCenterInsights/src/V1/GetViewRequest.php +++ b/ContactCenterInsights/src/V1/GetViewRequest.php @@ -20,7 +20,7 @@ class GetViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the view to get. Please see diff --git a/ContactCenterInsights/src/V1/IngestConversationsMetadata.php b/ContactCenterInsights/src/V1/IngestConversationsMetadata.php index 0fe91b0ffb2f..5923845b70e2 100644 --- a/ContactCenterInsights/src/V1/IngestConversationsMetadata.php +++ b/ContactCenterInsights/src/V1/IngestConversationsMetadata.php @@ -20,19 +20,19 @@ class IngestConversationsMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. The original request for ingest. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IngestConversationsRequest request = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $request = null; + protected $request = null; /** * Output only. Partial errors during ingest operation that might cause the * operation output to be incomplete. @@ -45,7 +45,7 @@ class IngestConversationsMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IngestConversationsMetadata.IngestConversationsStats ingest_conversations_stats = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $ingest_conversations_stats = null; + protected $ingest_conversations_stats = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IngestConversationsMetadata/IngestConversationsStats.php b/ContactCenterInsights/src/V1/IngestConversationsMetadata/IngestConversationsStats.php index 46c515e700b0..05733dee77d2 100644 --- a/ContactCenterInsights/src/V1/IngestConversationsMetadata/IngestConversationsStats.php +++ b/ContactCenterInsights/src/V1/IngestConversationsMetadata/IngestConversationsStats.php @@ -20,28 +20,28 @@ class IngestConversationsStats extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 processed_object_count = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $processed_object_count = 0; + protected $processed_object_count = 0; /** * Output only. The number of objects skipped because another conversation * with the same transcript uri had already been ingested. * * Generated from protobuf field int32 duplicates_skipped_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $duplicates_skipped_count = 0; + protected $duplicates_skipped_count = 0; /** * Output only. The number of new conversations added during this ingest * operation. * * Generated from protobuf field int32 successful_ingest_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $successful_ingest_count = 0; + protected $successful_ingest_count = 0; /** * Output only. The number of objects which were unable to be ingested due * to errors. The errors are populated in the partial_errors field. * * Generated from protobuf field int32 failed_ingest_count = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $failed_ingest_count = 0; + protected $failed_ingest_count = 0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IngestConversationsRequest.php b/ContactCenterInsights/src/V1/IngestConversationsRequest.php index 1f6b574db18f..96c359e2ee87 100644 --- a/ContactCenterInsights/src/V1/IngestConversationsRequest.php +++ b/ContactCenterInsights/src/V1/IngestConversationsRequest.php @@ -20,27 +20,27 @@ class IngestConversationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Configuration that applies to all conversations. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IngestConversationsRequest.ConversationConfig conversation_config = 4; */ - private $conversation_config = null; + protected $conversation_config = null; /** * Optional. DLP settings for transcript redaction. Optional, will default to * the config specified in Settings. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.RedactionConfig redaction_config = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $redaction_config = null; + protected $redaction_config = null; /** * Optional. Default Speech-to-Text configuration. Optional, will default to * the config specified in Settings. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.SpeechConfig speech_config = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $speech_config = null; + protected $speech_config = null; protected $source; protected $object_config; diff --git a/ContactCenterInsights/src/V1/IngestConversationsRequest/ConversationConfig.php b/ContactCenterInsights/src/V1/IngestConversationsRequest/ConversationConfig.php index 7ef44795ed89..d1fce0b70425 100644 --- a/ContactCenterInsights/src/V1/IngestConversationsRequest/ConversationConfig.php +++ b/ContactCenterInsights/src/V1/IngestConversationsRequest/ConversationConfig.php @@ -21,7 +21,7 @@ class ConversationConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string agent_id = 1; */ - private $agent_id = ''; + protected $agent_id = ''; /** * Optional. Indicates which of the channels, 1 or 2, contains the agent. * Note that this must be set for conversations to be properly displayed and @@ -29,7 +29,7 @@ class ConversationConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 agent_channel = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $agent_channel = 0; + protected $agent_channel = 0; /** * Optional. Indicates which of the channels, 1 or 2, contains the agent. * Note that this must be set for conversations to be properly displayed and @@ -37,7 +37,7 @@ class ConversationConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 customer_channel = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $customer_channel = 0; + protected $customer_channel = 0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IngestConversationsRequest/GcsSource.php b/ContactCenterInsights/src/V1/IngestConversationsRequest/GcsSource.php index 1a60bb089050..ac6730cabde1 100644 --- a/ContactCenterInsights/src/V1/IngestConversationsRequest/GcsSource.php +++ b/ContactCenterInsights/src/V1/IngestConversationsRequest/GcsSource.php @@ -20,13 +20,13 @@ class GcsSource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string bucket_uri = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $bucket_uri = ''; + protected $bucket_uri = ''; /** * Optional. Specifies the type of the objects in `bucket_uri`. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IngestConversationsRequest.GcsSource.BucketObjectType bucket_object_type = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $bucket_object_type = 0; + protected $bucket_object_type = 0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IngestConversationsRequest/TranscriptObjectConfig.php b/ContactCenterInsights/src/V1/IngestConversationsRequest/TranscriptObjectConfig.php index e1e790ea1cb0..aa83cb48d58c 100644 --- a/ContactCenterInsights/src/V1/IngestConversationsRequest/TranscriptObjectConfig.php +++ b/ContactCenterInsights/src/V1/IngestConversationsRequest/TranscriptObjectConfig.php @@ -20,7 +20,7 @@ class TranscriptObjectConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Conversation.Medium medium = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $medium = 0; + protected $medium = 0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Intent.php b/ContactCenterInsights/src/V1/Intent.php index 801ba7a5de8a..74f40304f91e 100644 --- a/ContactCenterInsights/src/V1/Intent.php +++ b/ContactCenterInsights/src/V1/Intent.php @@ -21,13 +21,13 @@ class Intent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * The human-readable name of the intent. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IntentMatchData.php b/ContactCenterInsights/src/V1/IntentMatchData.php index 402aad996aac..7997dc89a081 100644 --- a/ContactCenterInsights/src/V1/IntentMatchData.php +++ b/ContactCenterInsights/src/V1/IntentMatchData.php @@ -24,7 +24,7 @@ class IntentMatchData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string intent_unique_id = 1; */ - private $intent_unique_id = ''; + protected $intent_unique_id = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Issue.php b/ContactCenterInsights/src/V1/Issue.php index 2721c8a2308a..7c46c7d9df38 100644 --- a/ContactCenterInsights/src/V1/Issue.php +++ b/ContactCenterInsights/src/V1/Issue.php @@ -22,25 +22,25 @@ class Issue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * The representative name for the issue. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. The time at which this issue was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The most recent time that this issue was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Output only. Resource names of the sample representative utterances that * match to this issue. diff --git a/ContactCenterInsights/src/V1/IssueAssignment.php b/ContactCenterInsights/src/V1/IssueAssignment.php index 9e579b9b7975..bfe826f1fadc 100644 --- a/ContactCenterInsights/src/V1/IssueAssignment.php +++ b/ContactCenterInsights/src/V1/IssueAssignment.php @@ -20,21 +20,21 @@ class IssueAssignment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string issue = 1; */ - private $issue = ''; + protected $issue = ''; /** * Score indicating the likelihood of the issue assignment. * currently bounded on [0,1]. * * Generated from protobuf field double score = 2; */ - private $score = 0.0; + protected $score = 0.0; /** * Immutable. Display name of the assigned issue. This field is set at time of * analyis and immutable since then. * * Generated from protobuf field string display_name = 3 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IssueMatchData.php b/ContactCenterInsights/src/V1/IssueMatchData.php index dbfbcb8ffd43..a0efc3fe72dd 100644 --- a/ContactCenterInsights/src/V1/IssueMatchData.php +++ b/ContactCenterInsights/src/V1/IssueMatchData.php @@ -20,7 +20,7 @@ class IssueMatchData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueAssignment issue_assignment = 1; */ - private $issue_assignment = null; + protected $issue_assignment = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IssueModel.php b/ContactCenterInsights/src/V1/IssueModel.php index b836c8731f94..5f48567214a1 100644 --- a/ContactCenterInsights/src/V1/IssueModel.php +++ b/ContactCenterInsights/src/V1/IssueModel.php @@ -22,62 +22,62 @@ class IssueModel extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * The representative name for the issue model. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. The time at which this issue model was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The most recent time at which the issue model was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Output only. Number of issues in this issue model. * * Generated from protobuf field int64 issue_count = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $issue_count = 0; + protected $issue_count = 0; /** * Output only. State of the model. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueModel.State state = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Configs for the input data that used to create the issue model. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueModel.InputDataConfig input_data_config = 6; */ - private $input_data_config = null; + protected $input_data_config = null; /** * Output only. Immutable. The issue model's label statistics on its training * data. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueModelLabelStats training_stats = 7 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE]; */ - private $training_stats = null; + protected $training_stats = null; /** * Type of the model. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueModel.ModelType model_type = 9; */ - private $model_type = 0; + protected $model_type = 0; /** * Language of the model. * * Generated from protobuf field string language_code = 10; */ - private $language_code = ''; + protected $language_code = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IssueModel/InputDataConfig.php b/ContactCenterInsights/src/V1/IssueModel/InputDataConfig.php index fc1a627ac7ad..52c2f5dbe51f 100644 --- a/ContactCenterInsights/src/V1/IssueModel/InputDataConfig.php +++ b/ContactCenterInsights/src/V1/IssueModel/InputDataConfig.php @@ -29,14 +29,14 @@ class InputDataConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 training_conversations_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $training_conversations_count = 0; + protected $training_conversations_count = 0; /** * A filter to reduce the conversations used for training the model to a * specific subset. * * Generated from protobuf field string filter = 3; */ - private $filter = ''; + protected $filter = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IssueModelLabelStats.php b/ContactCenterInsights/src/V1/IssueModelLabelStats.php index 8b7c5c46193b..13e20a42460f 100644 --- a/ContactCenterInsights/src/V1/IssueModelLabelStats.php +++ b/ContactCenterInsights/src/V1/IssueModelLabelStats.php @@ -20,14 +20,14 @@ class IssueModelLabelStats extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 analyzed_conversations_count = 1; */ - private $analyzed_conversations_count = 0; + protected $analyzed_conversations_count = 0; /** * Number of analyzed conversations for which no issue was applicable at this * point in time. * * Generated from protobuf field int64 unclassified_conversations_count = 2; */ - private $unclassified_conversations_count = 0; + protected $unclassified_conversations_count = 0; /** * Statistics on each issue. Key is the issue's resource name. * diff --git a/ContactCenterInsights/src/V1/IssueModelLabelStats/IssueStats.php b/ContactCenterInsights/src/V1/IssueModelLabelStats/IssueStats.php index 719958987763..58e71c319209 100644 --- a/ContactCenterInsights/src/V1/IssueModelLabelStats/IssueStats.php +++ b/ContactCenterInsights/src/V1/IssueModelLabelStats/IssueStats.php @@ -22,19 +22,19 @@ class IssueStats extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string issue = 1; */ - private $issue = ''; + protected $issue = ''; /** * Number of conversations attached to the issue at this point in time. * * Generated from protobuf field int64 labeled_conversations_count = 2; */ - private $labeled_conversations_count = 0; + protected $labeled_conversations_count = 0; /** * Display name of the issue. * * Generated from protobuf field string display_name = 3; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/IssueModelResult.php b/ContactCenterInsights/src/V1/IssueModelResult.php index 205d95a74ef1..80a0ea58e065 100644 --- a/ContactCenterInsights/src/V1/IssueModelResult.php +++ b/ContactCenterInsights/src/V1/IssueModelResult.php @@ -21,7 +21,7 @@ class IssueModelResult extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string issue_model = 1 [(.google.api.resource_reference) = { */ - private $issue_model = ''; + protected $issue_model = ''; /** * All the matched issues. * diff --git a/ContactCenterInsights/src/V1/ListAnalysesRequest.php b/ContactCenterInsights/src/V1/ListAnalysesRequest.php index cde537f27336..0ca0f63bbf9a 100644 --- a/ContactCenterInsights/src/V1/ListAnalysesRequest.php +++ b/ContactCenterInsights/src/V1/ListAnalysesRequest.php @@ -20,7 +20,7 @@ class ListAnalysesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of analyses to return in the response. If this * value is zero, the service will select a default size. A call might return @@ -29,7 +29,7 @@ class ListAnalysesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The value returned by the last `ListAnalysesResponse`; indicates * that this is a continuation of a prior `ListAnalyses` call and @@ -37,14 +37,14 @@ class ListAnalysesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * A filter to reduce results to a specific subset. Useful for querying * conversations with specific properties. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The parent resource of the analyses. Please see diff --git a/ContactCenterInsights/src/V1/ListAnalysesResponse.php b/ContactCenterInsights/src/V1/ListAnalysesResponse.php index 4874f86581d0..c1a8d2ea3c7c 100644 --- a/ContactCenterInsights/src/V1/ListAnalysesResponse.php +++ b/ContactCenterInsights/src/V1/ListAnalysesResponse.php @@ -27,7 +27,7 @@ class ListAnalysesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/ListConversationsRequest.php b/ContactCenterInsights/src/V1/ListConversationsRequest.php index 85840a366415..cfe31fa3fb41 100644 --- a/ContactCenterInsights/src/V1/ListConversationsRequest.php +++ b/ContactCenterInsights/src/V1/ListConversationsRequest.php @@ -20,7 +20,7 @@ class ListConversationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of conversations to return in the response. A valid page * size ranges from 0 to 1,000 inclusive. If the page size is zero or @@ -29,7 +29,7 @@ class ListConversationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The value returned by the last `ListConversationsResponse`. This value * indicates that this is a continuation of a prior `ListConversations` call @@ -37,20 +37,20 @@ class ListConversationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * A filter to reduce results to a specific subset. Useful for querying * conversations with specific properties. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * The level of details of the conversation. Default is `BASIC`. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ConversationView view = 5; */ - private $view = 0; + protected $view = 0; /** * @param string $parent Required. The parent resource of the conversation. Please see diff --git a/ContactCenterInsights/src/V1/ListConversationsResponse.php b/ContactCenterInsights/src/V1/ListConversationsResponse.php index 11c92fc8aad4..d43bf9bd86f7 100644 --- a/ContactCenterInsights/src/V1/ListConversationsResponse.php +++ b/ContactCenterInsights/src/V1/ListConversationsResponse.php @@ -28,7 +28,7 @@ class ListConversationsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/ListIssueModelsRequest.php b/ContactCenterInsights/src/V1/ListIssueModelsRequest.php index cad35fffb817..797cc70091fb 100644 --- a/ContactCenterInsights/src/V1/ListIssueModelsRequest.php +++ b/ContactCenterInsights/src/V1/ListIssueModelsRequest.php @@ -20,7 +20,7 @@ class ListIssueModelsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * @param string $parent Required. The parent resource of the issue model. Please see diff --git a/ContactCenterInsights/src/V1/ListIssuesRequest.php b/ContactCenterInsights/src/V1/ListIssuesRequest.php index 60503724aba6..9c33a0640c2a 100644 --- a/ContactCenterInsights/src/V1/ListIssuesRequest.php +++ b/ContactCenterInsights/src/V1/ListIssuesRequest.php @@ -20,7 +20,7 @@ class ListIssuesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * @param string $parent Required. The parent resource of the issue. Please see diff --git a/ContactCenterInsights/src/V1/ListPhraseMatchersRequest.php b/ContactCenterInsights/src/V1/ListPhraseMatchersRequest.php index 2931a7233e1f..531bf84f176f 100644 --- a/ContactCenterInsights/src/V1/ListPhraseMatchersRequest.php +++ b/ContactCenterInsights/src/V1/ListPhraseMatchersRequest.php @@ -20,7 +20,7 @@ class ListPhraseMatchersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of phrase matchers to return in the response. If this * value is zero, the service will select a default size. A call might return @@ -29,7 +29,7 @@ class ListPhraseMatchersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The value returned by the last `ListPhraseMatchersResponse`. This value * indicates that this is a continuation of a prior `ListPhraseMatchers` call @@ -37,14 +37,14 @@ class ListPhraseMatchersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * A filter to reduce results to a specific subset. Useful for querying * phrase matchers with specific properties. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The parent resource of the phrase matcher. Please see diff --git a/ContactCenterInsights/src/V1/ListPhraseMatchersResponse.php b/ContactCenterInsights/src/V1/ListPhraseMatchersResponse.php index 47de3de2e8d8..a757fadd7624 100644 --- a/ContactCenterInsights/src/V1/ListPhraseMatchersResponse.php +++ b/ContactCenterInsights/src/V1/ListPhraseMatchersResponse.php @@ -27,7 +27,7 @@ class ListPhraseMatchersResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/ListViewsRequest.php b/ContactCenterInsights/src/V1/ListViewsRequest.php index aa57105df716..6beedf23a10a 100644 --- a/ContactCenterInsights/src/V1/ListViewsRequest.php +++ b/ContactCenterInsights/src/V1/ListViewsRequest.php @@ -20,7 +20,7 @@ class ListViewsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of views to return in the response. If this * value is zero, the service will select a default size. A call may return @@ -29,7 +29,7 @@ class ListViewsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The value returned by the last `ListViewsResponse`; indicates * that this is a continuation of a prior `ListViews` call and @@ -37,7 +37,7 @@ class ListViewsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The parent resource of the views. Please see diff --git a/ContactCenterInsights/src/V1/ListViewsResponse.php b/ContactCenterInsights/src/V1/ListViewsResponse.php index dbd458856e51..18ad9605fc2b 100644 --- a/ContactCenterInsights/src/V1/ListViewsResponse.php +++ b/ContactCenterInsights/src/V1/ListViewsResponse.php @@ -27,7 +27,7 @@ class ListViewsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/PhraseMatchData.php b/ContactCenterInsights/src/V1/PhraseMatchData.php index 69175364f841..976b4005d028 100644 --- a/ContactCenterInsights/src/V1/PhraseMatchData.php +++ b/ContactCenterInsights/src/V1/PhraseMatchData.php @@ -21,13 +21,13 @@ class PhraseMatchData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string phrase_matcher = 1; */ - private $phrase_matcher = ''; + protected $phrase_matcher = ''; /** * The human-readable name of the phrase matcher. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/PhraseMatchRule.php b/ContactCenterInsights/src/V1/PhraseMatchRule.php index 3d039a893850..7c378d92751c 100644 --- a/ContactCenterInsights/src/V1/PhraseMatchRule.php +++ b/ContactCenterInsights/src/V1/PhraseMatchRule.php @@ -20,21 +20,21 @@ class PhraseMatchRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string query = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $query = ''; + protected $query = ''; /** * Specifies whether the phrase must be missing from the transcript segment or * present in the transcript segment. * * Generated from protobuf field bool negated = 2; */ - private $negated = false; + protected $negated = false; /** * Provides additional information about the rule that specifies how to apply * the rule. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.PhraseMatchRuleConfig config = 3; */ - private $config = null; + protected $config = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/PhraseMatchRuleGroup.php b/ContactCenterInsights/src/V1/PhraseMatchRuleGroup.php index 538812a2c4c9..3349ff2378e3 100644 --- a/ContactCenterInsights/src/V1/PhraseMatchRuleGroup.php +++ b/ContactCenterInsights/src/V1/PhraseMatchRuleGroup.php @@ -20,7 +20,7 @@ class PhraseMatchRuleGroup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.PhraseMatchRuleGroup.PhraseMatchRuleGroupType type = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = 0; + protected $type = 0; /** * A list of phrase match rules that are included in this group. * diff --git a/ContactCenterInsights/src/V1/PhraseMatcher.php b/ContactCenterInsights/src/V1/PhraseMatcher.php index dbd5169352d1..44a2e86faddd 100644 --- a/ContactCenterInsights/src/V1/PhraseMatcher.php +++ b/ContactCenterInsights/src/V1/PhraseMatcher.php @@ -22,7 +22,7 @@ class PhraseMatcher extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. Immutable. The revision ID of the phrase matcher. * A new revision is committed whenever the matcher is changed, except when it @@ -31,39 +31,39 @@ class PhraseMatcher extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string revision_id = 2 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $revision_id = ''; + protected $revision_id = ''; /** * The customized version tag to use for the phrase matcher. If not specified, * it will default to `revision_id`. * * Generated from protobuf field string version_tag = 3; */ - private $version_tag = ''; + protected $version_tag = ''; /** * Output only. The timestamp of when the revision was created. It is also the * create time when a new matcher is added. * * Generated from protobuf field .google.protobuf.Timestamp revision_create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $revision_create_time = null; + protected $revision_create_time = null; /** * The human-readable name of the phrase matcher. * * Generated from protobuf field string display_name = 5; */ - private $display_name = ''; + protected $display_name = ''; /** * Required. The type of this phrase matcher. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.PhraseMatcher.PhraseMatcherType type = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = 0; + protected $type = 0; /** * Applies the phrase matcher only when it is active. * * Generated from protobuf field bool active = 7; */ - private $active = false; + protected $active = false; /** * A list of phase match rule groups that are included in this matcher. * @@ -76,7 +76,7 @@ class PhraseMatcher extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp activation_update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $activation_update_time = null; + protected $activation_update_time = null; /** * The role whose utterances the phrase matcher should be matched * against. If the role is ROLE_UNSPECIFIED it will be matched against any @@ -84,13 +84,13 @@ class PhraseMatcher extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.ConversationParticipant.Role role_match = 10; */ - private $role_match = 0; + protected $role_match = 0; /** * Output only. The most recent time at which the phrase matcher was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/RedactionConfig.php b/ContactCenterInsights/src/V1/RedactionConfig.php index 2b6efaebcedd..ebcf981ef8e4 100644 --- a/ContactCenterInsights/src/V1/RedactionConfig.php +++ b/ContactCenterInsights/src/V1/RedactionConfig.php @@ -22,7 +22,7 @@ class RedactionConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string deidentify_template = 1; */ - private $deidentify_template = ''; + protected $deidentify_template = ''; /** * The fully-qualified DLP inspect template resource name. * Format: @@ -30,7 +30,7 @@ class RedactionConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string inspect_template = 2; */ - private $inspect_template = ''; + protected $inspect_template = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/RuntimeAnnotation.php b/ContactCenterInsights/src/V1/RuntimeAnnotation.php index f5730e546758..6d27085452d2 100644 --- a/ContactCenterInsights/src/V1/RuntimeAnnotation.php +++ b/ContactCenterInsights/src/V1/RuntimeAnnotation.php @@ -22,31 +22,31 @@ class RuntimeAnnotation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string annotation_id = 1; */ - private $annotation_id = ''; + protected $annotation_id = ''; /** * The time at which this annotation was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2; */ - private $create_time = null; + protected $create_time = null; /** * The boundary in the conversation where the annotation starts, inclusive. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotationBoundary start_boundary = 3; */ - private $start_boundary = null; + protected $start_boundary = null; /** * The boundary in the conversation where the annotation ends, inclusive. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotationBoundary end_boundary = 4; */ - private $end_boundary = null; + protected $end_boundary = null; /** * The feedback that the customer has about the answer in `data`. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnswerFeedback answer_feedback = 5; */ - private $answer_feedback = null; + protected $answer_feedback = null; protected $data; /** diff --git a/ContactCenterInsights/src/V1/SentimentData.php b/ContactCenterInsights/src/V1/SentimentData.php index d6f85a373a5f..ce03d00b710a 100644 --- a/ContactCenterInsights/src/V1/SentimentData.php +++ b/ContactCenterInsights/src/V1/SentimentData.php @@ -21,13 +21,13 @@ class SentimentData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float magnitude = 1; */ - private $magnitude = 0.0; + protected $magnitude = 0.0; /** * The sentiment score between -1.0 (negative) and 1.0 (positive). * * Generated from protobuf field float score = 2; */ - private $score = 0.0; + protected $score = 0.0; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Settings.php b/ContactCenterInsights/src/V1/Settings.php index b41ea8a26c79..4c92a6b67f20 100644 --- a/ContactCenterInsights/src/V1/Settings.php +++ b/ContactCenterInsights/src/V1/Settings.php @@ -22,19 +22,19 @@ class Settings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. The time at which the settings was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time at which the settings were last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * A language code to be applied to each transcript segment unless the segment * already specifies a language code. Language code defaults to "en-US" if it @@ -42,7 +42,7 @@ class Settings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string language_code = 4; */ - private $language_code = ''; + protected $language_code = ''; /** * The default TTL for newly-created conversations. If a conversation has a * specified expiration, that value will be used instead. Changing this @@ -51,7 +51,7 @@ class Settings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration conversation_ttl = 5; */ - private $conversation_ttl = null; + protected $conversation_ttl = null; /** * A map that maps a notification trigger to a Pub/Sub topic. Each time a * specified trigger occurs, Insights will notify the corresponding Pub/Sub @@ -74,21 +74,21 @@ class Settings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Settings.AnalysisConfig analysis_config = 7; */ - private $analysis_config = null; + protected $analysis_config = null; /** * Default DLP redaction resources to be applied while ingesting * conversations. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.RedactionConfig redaction_config = 10; */ - private $redaction_config = null; + protected $redaction_config = null; /** * Optional. Default Speech-to-Text resources to be used while ingesting audio * files. Optional, CCAI Insights will create a default if not provided. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.SpeechConfig speech_config = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $speech_config = null; + protected $speech_config = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/Settings/AnalysisConfig.php b/ContactCenterInsights/src/V1/Settings/AnalysisConfig.php index bbab40ac4c86..501ce99e2013 100644 --- a/ContactCenterInsights/src/V1/Settings/AnalysisConfig.php +++ b/ContactCenterInsights/src/V1/Settings/AnalysisConfig.php @@ -21,21 +21,21 @@ class AnalysisConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double runtime_integration_analysis_percentage = 1; */ - private $runtime_integration_analysis_percentage = 0.0; + protected $runtime_integration_analysis_percentage = 0.0; /** * Percentage of conversations created using the UploadConversation endpoint * to analyze automatically, between [0, 100]. * * Generated from protobuf field double upload_conversation_analysis_percentage = 6; */ - private $upload_conversation_analysis_percentage = 0.0; + protected $upload_conversation_analysis_percentage = 0.0; /** * To select the annotators to run and the phrase matchers to use * (if any). If not specified, all annotators will be run. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.AnnotatorSelector annotator_selector = 5; */ - private $annotator_selector = null; + protected $annotator_selector = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/SmartComposeSuggestionData.php b/ContactCenterInsights/src/V1/SmartComposeSuggestionData.php index a0b9b5d84099..abf22b896d3a 100644 --- a/ContactCenterInsights/src/V1/SmartComposeSuggestionData.php +++ b/ContactCenterInsights/src/V1/SmartComposeSuggestionData.php @@ -20,7 +20,7 @@ class SmartComposeSuggestionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string suggestion = 1; */ - private $suggestion = ''; + protected $suggestion = ''; /** * The system's confidence score that this suggestion is a good match for this * conversation, ranging from 0.0 (completely uncertain) to 1.0 (completely @@ -28,7 +28,7 @@ class SmartComposeSuggestionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double confidence_score = 2; */ - private $confidence_score = 0.0; + protected $confidence_score = 0.0; /** * Map that contains metadata about the Smart Compose suggestion and the * document from which it originates. @@ -43,7 +43,7 @@ class SmartComposeSuggestionData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string query_record = 4; */ - private $query_record = ''; + protected $query_record = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/SmartReplyData.php b/ContactCenterInsights/src/V1/SmartReplyData.php index 806ccb89465d..2da4d03c9e50 100644 --- a/ContactCenterInsights/src/V1/SmartReplyData.php +++ b/ContactCenterInsights/src/V1/SmartReplyData.php @@ -20,7 +20,7 @@ class SmartReplyData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string reply = 1; */ - private $reply = ''; + protected $reply = ''; /** * The system's confidence score that this reply is a good match for this * conversation, ranging from 0.0 (completely uncertain) to 1.0 (completely @@ -28,7 +28,7 @@ class SmartReplyData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double confidence_score = 2; */ - private $confidence_score = 0.0; + protected $confidence_score = 0.0; /** * Map that contains metadata about the Smart Reply and the document from * which it originates. @@ -43,7 +43,7 @@ class SmartReplyData extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string query_record = 4; */ - private $query_record = ''; + protected $query_record = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/SpeechConfig.php b/ContactCenterInsights/src/V1/SpeechConfig.php index aba59713fcb2..26829b4fdee5 100644 --- a/ContactCenterInsights/src/V1/SpeechConfig.php +++ b/ContactCenterInsights/src/V1/SpeechConfig.php @@ -22,7 +22,7 @@ class SpeechConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string speech_recognizer = 1 [(.google.api.resource_reference) = { */ - private $speech_recognizer = ''; + protected $speech_recognizer = ''; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/UndeployIssueModelMetadata.php b/ContactCenterInsights/src/V1/UndeployIssueModelMetadata.php index fac1c37bc95d..e6995db42e6e 100644 --- a/ContactCenterInsights/src/V1/UndeployIssueModelMetadata.php +++ b/ContactCenterInsights/src/V1/UndeployIssueModelMetadata.php @@ -20,19 +20,19 @@ class UndeployIssueModelMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * The original request for undeployment. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.UndeployIssueModelRequest request = 3; */ - private $request = null; + protected $request = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/UndeployIssueModelRequest.php b/ContactCenterInsights/src/V1/UndeployIssueModelRequest.php index 431a770b1bb5..7db5b4fe3288 100644 --- a/ContactCenterInsights/src/V1/UndeployIssueModelRequest.php +++ b/ContactCenterInsights/src/V1/UndeployIssueModelRequest.php @@ -20,7 +20,7 @@ class UndeployIssueModelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The issue model to undeploy. Please see diff --git a/ContactCenterInsights/src/V1/UpdateConversationRequest.php b/ContactCenterInsights/src/V1/UpdateConversationRequest.php index 0ee5e20a94dd..454731ba405c 100644 --- a/ContactCenterInsights/src/V1/UpdateConversationRequest.php +++ b/ContactCenterInsights/src/V1/UpdateConversationRequest.php @@ -20,13 +20,13 @@ class UpdateConversationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Conversation conversation = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $conversation = null; + protected $conversation = null; /** * The list of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\ContactCenterInsights\V1\Conversation $conversation Required. The new values for the conversation. diff --git a/ContactCenterInsights/src/V1/UpdateIssueModelRequest.php b/ContactCenterInsights/src/V1/UpdateIssueModelRequest.php index ae665a3967ed..2cc1f7c36565 100644 --- a/ContactCenterInsights/src/V1/UpdateIssueModelRequest.php +++ b/ContactCenterInsights/src/V1/UpdateIssueModelRequest.php @@ -20,13 +20,13 @@ class UpdateIssueModelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.IssueModel issue_model = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $issue_model = null; + protected $issue_model = null; /** * The list of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\ContactCenterInsights\V1\IssueModel $issueModel Required. The new values for the issue model. diff --git a/ContactCenterInsights/src/V1/UpdateIssueRequest.php b/ContactCenterInsights/src/V1/UpdateIssueRequest.php index 4b00367beec7..0be9746fae85 100644 --- a/ContactCenterInsights/src/V1/UpdateIssueRequest.php +++ b/ContactCenterInsights/src/V1/UpdateIssueRequest.php @@ -20,13 +20,13 @@ class UpdateIssueRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Issue issue = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $issue = null; + protected $issue = null; /** * The list of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\ContactCenterInsights\V1\Issue $issue Required. The new values for the issue. diff --git a/ContactCenterInsights/src/V1/UpdatePhraseMatcherRequest.php b/ContactCenterInsights/src/V1/UpdatePhraseMatcherRequest.php index 407920655bc3..f161bd6098d5 100644 --- a/ContactCenterInsights/src/V1/UpdatePhraseMatcherRequest.php +++ b/ContactCenterInsights/src/V1/UpdatePhraseMatcherRequest.php @@ -20,13 +20,13 @@ class UpdatePhraseMatcherRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.PhraseMatcher phrase_matcher = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $phrase_matcher = null; + protected $phrase_matcher = null; /** * The list of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\ContactCenterInsights\V1\PhraseMatcher $phraseMatcher Required. The new values for the phrase matcher. diff --git a/ContactCenterInsights/src/V1/UpdateSettingsRequest.php b/ContactCenterInsights/src/V1/UpdateSettingsRequest.php index a06491fd9e4d..83a51d0c3938 100644 --- a/ContactCenterInsights/src/V1/UpdateSettingsRequest.php +++ b/ContactCenterInsights/src/V1/UpdateSettingsRequest.php @@ -20,13 +20,13 @@ class UpdateSettingsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Settings settings = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $settings = null; + protected $settings = null; /** * Required. The list of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\ContactCenterInsights\V1\Settings $settings Required. The new settings values. diff --git a/ContactCenterInsights/src/V1/UpdateViewRequest.php b/ContactCenterInsights/src/V1/UpdateViewRequest.php index d9f46f3bac51..c1adc1132a5f 100644 --- a/ContactCenterInsights/src/V1/UpdateViewRequest.php +++ b/ContactCenterInsights/src/V1/UpdateViewRequest.php @@ -20,13 +20,13 @@ class UpdateViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.View view = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $view = null; + protected $view = null; /** * The list of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\ContactCenterInsights\V1\View $view Required. The new view. diff --git a/ContactCenterInsights/src/V1/UploadConversationMetadata.php b/ContactCenterInsights/src/V1/UploadConversationMetadata.php index 84d912c3ee0d..3d20791c0681 100644 --- a/ContactCenterInsights/src/V1/UploadConversationMetadata.php +++ b/ContactCenterInsights/src/V1/UploadConversationMetadata.php @@ -20,32 +20,32 @@ class UploadConversationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. The original request. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.UploadConversationRequest request = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $request = null; + protected $request = null; /** * Output only. The operation name for a successfully created analysis * operation, if any. * * Generated from protobuf field string analysis_operation = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $analysis_operation = ''; + protected $analysis_operation = ''; /** * Output only. The redaction config applied to the uploaded conversation. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.RedactionConfig applied_redaction_config = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $applied_redaction_config = null; + protected $applied_redaction_config = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/UploadConversationRequest.php b/ContactCenterInsights/src/V1/UploadConversationRequest.php index e6d8abed38a8..443a3b1398eb 100644 --- a/ContactCenterInsights/src/V1/UploadConversationRequest.php +++ b/ContactCenterInsights/src/V1/UploadConversationRequest.php @@ -20,13 +20,13 @@ class UploadConversationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The conversation resource to create. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.Conversation conversation = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $conversation = null; + protected $conversation = null; /** * Optional. A unique ID for the new conversation. This ID will become the * final component of the conversation's resource name. If no ID is specified, @@ -36,21 +36,21 @@ class UploadConversationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string conversation_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $conversation_id = ''; + protected $conversation_id = ''; /** * Optional. DLP settings for transcript redaction. Will default to the config * specified in Settings. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.RedactionConfig redaction_config = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $redaction_config = null; + protected $redaction_config = null; /** * Optional. Speech-to-Text configuration. Will default to the config * specified in Settings. * * Generated from protobuf field .google.cloud.contactcenterinsights.v1.SpeechConfig speech_config = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $speech_config = null; + protected $speech_config = null; /** * Constructor. diff --git a/ContactCenterInsights/src/V1/View.php b/ContactCenterInsights/src/V1/View.php index 365931fafad4..286533d5ad37 100644 --- a/ContactCenterInsights/src/V1/View.php +++ b/ContactCenterInsights/src/V1/View.php @@ -22,31 +22,31 @@ class View extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * The human-readable display name of the view. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. The time at which this view was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The most recent time at which the view was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * String with specific view properties, must be non-empty. * * Generated from protobuf field string value = 5; */ - private $value = ''; + protected $value = ''; /** * Constructor. diff --git a/ContactCenterInsights/tests/Unit/V1/Client/ContactCenterInsightsClientTest.php b/ContactCenterInsights/tests/Unit/V1/Client/ContactCenterInsightsClientTest.php index 8d30e3cd0b4d..3d50510bcf7a 100644 --- a/ContactCenterInsights/tests/Unit/V1/Client/ContactCenterInsightsClientTest.php +++ b/ContactCenterInsights/tests/Unit/V1/Client/ContactCenterInsightsClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ContactCenterInsightsClient */ @@ -175,7 +177,10 @@ public function bulkAnalyzeConversationsTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getFilter(); @@ -225,12 +230,15 @@ public function bulkAnalyzeConversationsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -293,8 +301,7 @@ public function bulkDeleteConversationsTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new BulkDeleteConversationsRequest()) - ->setParent($formattedParent); + $request = (new BulkDeleteConversationsRequest())->setParent($formattedParent); $response = $gapicClient->bulkDeleteConversations($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -304,7 +311,10 @@ public function bulkDeleteConversationsTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkDeleteConversations', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkDeleteConversations', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -350,17 +360,19 @@ public function bulkDeleteConversationsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new BulkDeleteConversationsRequest()) - ->setParent($formattedParent); + $request = (new BulkDeleteConversationsRequest())->setParent($formattedParent); $response = $gapicClient->bulkDeleteConversations($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -396,15 +408,17 @@ public function calculateIssueModelStatsTest() $transport->addResponse($expectedResponse); // Mock request $formattedIssueModel = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new CalculateIssueModelStatsRequest()) - ->setIssueModel($formattedIssueModel); + $request = (new CalculateIssueModelStatsRequest())->setIssueModel($formattedIssueModel); $response = $gapicClient->calculateIssueModelStats($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.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', + $actualFuncCall + ); $actualValue = $actualRequestObject->getIssueModel(); $this->assertProtobufEquals($formattedIssueModel, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -421,17 +435,19 @@ public function calculateIssueModelStatsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedIssueModel = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new CalculateIssueModelStatsRequest()) - ->setIssueModel($formattedIssueModel); + $request = (new CalculateIssueModelStatsRequest())->setIssueModel($formattedIssueModel); try { $gapicClient->calculateIssueModelStats($request); // If the $gapicClient method call did not throw, fail the test @@ -462,15 +478,17 @@ public function calculateStatsTest() $transport->addResponse($expectedResponse); // Mock request $formattedLocation = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new CalculateStatsRequest()) - ->setLocation($formattedLocation); + $request = (new CalculateStatsRequest())->setLocation($formattedLocation); $response = $gapicClient->calculateStats($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.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', + $actualFuncCall + ); $actualValue = $actualRequestObject->getLocation(); $this->assertProtobufEquals($formattedLocation, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -487,17 +505,19 @@ public function calculateStatsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedLocation = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new CalculateStatsRequest()) - ->setLocation($formattedLocation); + $request = (new CalculateStatsRequest())->setLocation($formattedLocation); try { $gapicClient->calculateStats($request); // If the $gapicClient method call did not throw, fail the test @@ -545,9 +565,7 @@ public function createAnalysisTest() // Mock request $formattedParent = $gapicClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); $analysis = new Analysis(); - $request = (new CreateAnalysisRequest()) - ->setParent($formattedParent) - ->setAnalysis($analysis); + $request = (new CreateAnalysisRequest())->setParent($formattedParent)->setAnalysis($analysis); $response = $gapicClient->createAnalysis($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -557,7 +575,10 @@ public function createAnalysisTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getAnalysis(); @@ -605,19 +626,20 @@ public function createAnalysisExceptionTest() $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); + $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->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); $analysis = new Analysis(); - $request = (new CreateAnalysisRequest()) - ->setParent($formattedParent) - ->setAnalysis($analysis); + $request = (new CreateAnalysisRequest())->setParent($formattedParent)->setAnalysis($analysis); $response = $gapicClient->createAnalysis($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -664,16 +686,17 @@ public function createConversationTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $conversation = new Conversation(); - $request = (new CreateConversationRequest()) - ->setParent($formattedParent) - ->setConversation($conversation); + $request = (new CreateConversationRequest())->setParent($formattedParent)->setConversation($conversation); $response = $gapicClient->createConversation($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.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getConversation(); @@ -692,19 +715,20 @@ public function createConversationExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); $conversation = new Conversation(); - $request = (new CreateConversationRequest()) - ->setParent($formattedParent) - ->setConversation($conversation); + $request = (new CreateConversationRequest())->setParent($formattedParent)->setConversation($conversation); try { $gapicClient->createConversation($request); // If the $gapicClient method call did not throw, fail the test @@ -758,9 +782,7 @@ public function createIssueModelTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $issueModel = new IssueModel(); - $request = (new CreateIssueModelRequest()) - ->setParent($formattedParent) - ->setIssueModel($issueModel); + $request = (new CreateIssueModelRequest())->setParent($formattedParent)->setIssueModel($issueModel); $response = $gapicClient->createIssueModel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -770,7 +792,10 @@ public function createIssueModelTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getIssueModel(); @@ -818,19 +843,20 @@ public function createIssueModelExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); $issueModel = new IssueModel(); - $request = (new CreateIssueModelRequest()) - ->setParent($formattedParent) - ->setIssueModel($issueModel); + $request = (new CreateIssueModelRequest())->setParent($formattedParent)->setIssueModel($issueModel); $response = $gapicClient->createIssueModel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -879,16 +905,17 @@ public function createPhraseMatcherTest() $phraseMatcher = new PhraseMatcher(); $phraseMatcherType = PhraseMatcherType::PHRASE_MATCHER_TYPE_UNSPECIFIED; $phraseMatcher->setType($phraseMatcherType); - $request = (new CreatePhraseMatcherRequest()) - ->setParent($formattedParent) - ->setPhraseMatcher($phraseMatcher); + $request = (new CreatePhraseMatcherRequest())->setParent($formattedParent)->setPhraseMatcher($phraseMatcher); $response = $gapicClient->createPhraseMatcher($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.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getPhraseMatcher(); @@ -907,21 +934,22 @@ public function createPhraseMatcherExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); $phraseMatcher = new PhraseMatcher(); $phraseMatcherType = PhraseMatcherType::PHRASE_MATCHER_TYPE_UNSPECIFIED; $phraseMatcher->setType($phraseMatcherType); - $request = (new CreatePhraseMatcherRequest()) - ->setParent($formattedParent) - ->setPhraseMatcher($phraseMatcher); + $request = (new CreatePhraseMatcherRequest())->setParent($formattedParent)->setPhraseMatcher($phraseMatcher); try { $gapicClient->createPhraseMatcher($request); // If the $gapicClient method call did not throw, fail the test @@ -955,9 +983,7 @@ public function createViewTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $view = new View(); - $request = (new CreateViewRequest()) - ->setParent($formattedParent) - ->setView($view); + $request = (new CreateViewRequest())->setParent($formattedParent)->setView($view); $response = $gapicClient->createView($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -983,19 +1009,20 @@ public function createViewExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); $view = new View(); - $request = (new CreateViewRequest()) - ->setParent($formattedParent) - ->setView($view); + $request = (new CreateViewRequest())->setParent($formattedParent)->setView($view); try { $gapicClient->createView($request); // If the $gapicClient method call did not throw, fail the test @@ -1022,14 +1049,16 @@ public function deleteAnalysisTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - $request = (new DeleteAnalysisRequest()) - ->setName($formattedName); + $request = (new DeleteAnalysisRequest())->setName($formattedName); $gapicClient->deleteAnalysis($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1046,17 +1075,19 @@ public function deleteAnalysisExceptionTest() $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); + $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->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - $request = (new DeleteAnalysisRequest()) - ->setName($formattedName); + $request = (new DeleteAnalysisRequest())->setName($formattedName); try { $gapicClient->deleteAnalysis($request); // If the $gapicClient method call did not throw, fail the test @@ -1083,14 +1114,16 @@ public function deleteConversationTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $request = (new DeleteConversationRequest()) - ->setName($formattedName); + $request = (new DeleteConversationRequest())->setName($formattedName); $gapicClient->deleteConversation($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1107,17 +1140,19 @@ public function deleteConversationExceptionTest() $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); + $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->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $request = (new DeleteConversationRequest()) - ->setName($formattedName); + $request = (new DeleteConversationRequest())->setName($formattedName); try { $gapicClient->deleteConversation($request); // If the $gapicClient method call did not throw, fail the test @@ -1144,8 +1179,7 @@ public function deleteIssueTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - $request = (new DeleteIssueRequest()) - ->setName($formattedName); + $request = (new DeleteIssueRequest())->setName($formattedName); $gapicClient->deleteIssue($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -1168,17 +1202,19 @@ public function deleteIssueExceptionTest() $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); + $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->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - $request = (new DeleteIssueRequest()) - ->setName($formattedName); + $request = (new DeleteIssueRequest())->setName($formattedName); try { $gapicClient->deleteIssue($request); // If the $gapicClient method call did not throw, fail the test @@ -1223,8 +1259,7 @@ public function deleteIssueModelTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new DeleteIssueModelRequest()) - ->setName($formattedName); + $request = (new DeleteIssueModelRequest())->setName($formattedName); $response = $gapicClient->deleteIssueModel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1234,7 +1269,10 @@ public function deleteIssueModelTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -1280,17 +1318,19 @@ public function deleteIssueModelExceptionTest() $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); + $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new DeleteIssueModelRequest()) - ->setName($formattedName); + $request = (new DeleteIssueModelRequest())->setName($formattedName); $response = $gapicClient->deleteIssueModel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1326,14 +1366,16 @@ public function deletePhraseMatcherTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - $request = (new DeletePhraseMatcherRequest()) - ->setName($formattedName); + $request = (new DeletePhraseMatcherRequest())->setName($formattedName); $gapicClient->deletePhraseMatcher($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1350,17 +1392,19 @@ public function deletePhraseMatcherExceptionTest() $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); + $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->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - $request = (new DeletePhraseMatcherRequest()) - ->setName($formattedName); + $request = (new DeletePhraseMatcherRequest())->setName($formattedName); try { $gapicClient->deletePhraseMatcher($request); // If the $gapicClient method call did not throw, fail the test @@ -1387,8 +1431,7 @@ public function deleteViewTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - $request = (new DeleteViewRequest()) - ->setName($formattedName); + $request = (new DeleteViewRequest())->setName($formattedName); $gapicClient->deleteView($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -1411,17 +1454,19 @@ public function deleteViewExceptionTest() $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); + $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->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - $request = (new DeleteViewRequest()) - ->setName($formattedName); + $request = (new DeleteViewRequest())->setName($formattedName); try { $gapicClient->deleteView($request); // If the $gapicClient method call did not throw, fail the test @@ -1466,8 +1511,7 @@ public function deployIssueModelTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new DeployIssueModelRequest()) - ->setName($formattedName); + $request = (new DeployIssueModelRequest())->setName($formattedName); $response = $gapicClient->deployIssueModel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1477,7 +1521,10 @@ public function deployIssueModelTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -1523,17 +1570,19 @@ public function deployIssueModelExceptionTest() $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); + $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new DeployIssueModelRequest()) - ->setName($formattedName); + $request = (new DeployIssueModelRequest())->setName($formattedName); $response = $gapicClient->deployIssueModel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1587,8 +1636,7 @@ public function exportInsightsDataTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ExportInsightsDataRequest()) - ->setParent($formattedParent); + $request = (new ExportInsightsDataRequest())->setParent($formattedParent); $response = $gapicClient->exportInsightsData($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1598,7 +1646,10 @@ public function exportInsightsDataTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -1644,17 +1695,19 @@ public function exportInsightsDataExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ExportInsightsDataRequest()) - ->setParent($formattedParent); + $request = (new ExportInsightsDataRequest())->setParent($formattedParent); $response = $gapicClient->exportInsightsData($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1692,8 +1745,7 @@ public function getAnalysisTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - $request = (new GetAnalysisRequest()) - ->setName($formattedName); + $request = (new GetAnalysisRequest())->setName($formattedName); $response = $gapicClient->getAnalysis($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1717,17 +1769,19 @@ public function getAnalysisExceptionTest() $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); + $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->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - $request = (new GetAnalysisRequest()) - ->setName($formattedName); + $request = (new GetAnalysisRequest())->setName($formattedName); try { $gapicClient->getAnalysis($request); // If the $gapicClient method call did not throw, fail the test @@ -1764,15 +1818,17 @@ public function getConversationTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $request = (new GetConversationRequest()) - ->setName($formattedName); + $request = (new GetConversationRequest())->setName($formattedName); $response = $gapicClient->getConversation($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.contactcenterinsights.v1.ContactCenterInsights/GetConversation', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetConversation', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1789,17 +1845,19 @@ public function getConversationExceptionTest() $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); + $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->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $request = (new GetConversationRequest()) - ->setName($formattedName); + $request = (new GetConversationRequest())->setName($formattedName); try { $gapicClient->getConversation($request); // If the $gapicClient method call did not throw, fail the test @@ -1830,8 +1888,7 @@ public function getIssueTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - $request = (new GetIssueRequest()) - ->setName($formattedName); + $request = (new GetIssueRequest())->setName($formattedName); $response = $gapicClient->getIssue($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1855,17 +1912,19 @@ public function getIssueExceptionTest() $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); + $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->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - $request = (new GetIssueRequest()) - ->setName($formattedName); + $request = (new GetIssueRequest())->setName($formattedName); try { $gapicClient->getIssue($request); // If the $gapicClient method call did not throw, fail the test @@ -1900,15 +1959,17 @@ public function getIssueModelTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new GetIssueModelRequest()) - ->setName($formattedName); + $request = (new GetIssueModelRequest())->setName($formattedName); $response = $gapicClient->getIssueModel($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.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1925,17 +1986,19 @@ public function getIssueModelExceptionTest() $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); + $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new GetIssueModelRequest()) - ->setName($formattedName); + $request = (new GetIssueModelRequest())->setName($formattedName); try { $gapicClient->getIssueModel($request); // If the $gapicClient method call did not throw, fail the test @@ -1972,15 +2035,17 @@ public function getPhraseMatcherTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - $request = (new GetPhraseMatcherRequest()) - ->setName($formattedName); + $request = (new GetPhraseMatcherRequest())->setName($formattedName); $response = $gapicClient->getPhraseMatcher($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.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1997,17 +2062,19 @@ public function getPhraseMatcherExceptionTest() $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); + $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->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - $request = (new GetPhraseMatcherRequest()) - ->setName($formattedName); + $request = (new GetPhraseMatcherRequest())->setName($formattedName); try { $gapicClient->getPhraseMatcher($request); // If the $gapicClient method call did not throw, fail the test @@ -2038,8 +2105,7 @@ public function getSettingsTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->settingsName('[PROJECT]', '[LOCATION]'); - $request = (new GetSettingsRequest()) - ->setName($formattedName); + $request = (new GetSettingsRequest())->setName($formattedName); $response = $gapicClient->getSettings($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2063,17 +2129,19 @@ public function getSettingsExceptionTest() $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); + $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->settingsName('[PROJECT]', '[LOCATION]'); - $request = (new GetSettingsRequest()) - ->setName($formattedName); + $request = (new GetSettingsRequest())->setName($formattedName); try { $gapicClient->getSettings($request); // If the $gapicClient method call did not throw, fail the test @@ -2106,8 +2174,7 @@ public function getViewTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - $request = (new GetViewRequest()) - ->setName($formattedName); + $request = (new GetViewRequest())->setName($formattedName); $response = $gapicClient->getView($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2131,17 +2198,19 @@ public function getViewExceptionTest() $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); + $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->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - $request = (new GetViewRequest()) - ->setName($formattedName); + $request = (new GetViewRequest())->setName($formattedName); try { $gapicClient->getView($request); // If the $gapicClient method call did not throw, fail the test @@ -2186,8 +2255,7 @@ public function ingestConversationsTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new IngestConversationsRequest()) - ->setParent($formattedParent); + $request = (new IngestConversationsRequest())->setParent($formattedParent); $response = $gapicClient->ingestConversations($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -2197,7 +2265,10 @@ public function ingestConversationsTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/IngestConversations', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/IngestConversations', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -2243,17 +2314,19 @@ public function ingestConversationsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new IngestConversationsRequest()) - ->setParent($formattedParent); + $request = (new IngestConversationsRequest())->setParent($formattedParent); $response = $gapicClient->ingestConversations($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -2287,17 +2360,14 @@ public function listAnalysesTest() // Mock response $nextPageToken = ''; $analysesElement = new Analysis(); - $analyses = [ - $analysesElement, - ]; + $analyses = [$analysesElement]; $expectedResponse = new ListAnalysesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAnalyses($analyses); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $request = (new ListAnalysesRequest()) - ->setParent($formattedParent); + $request = (new ListAnalysesRequest())->setParent($formattedParent); $response = $gapicClient->listAnalyses($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2324,17 +2394,19 @@ public function listAnalysesExceptionTest() $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); + $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->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $request = (new ListAnalysesRequest()) - ->setParent($formattedParent); + $request = (new ListAnalysesRequest())->setParent($formattedParent); try { $gapicClient->listAnalyses($request); // If the $gapicClient method call did not throw, fail the test @@ -2359,17 +2431,14 @@ public function listConversationsTest() // Mock response $nextPageToken = ''; $conversationsElement = new Conversation(); - $conversations = [ - $conversationsElement, - ]; + $conversations = [$conversationsElement]; $expectedResponse = new ListConversationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setConversations($conversations); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListConversationsRequest()) - ->setParent($formattedParent); + $request = (new ListConversationsRequest())->setParent($formattedParent); $response = $gapicClient->listConversations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2379,7 +2448,10 @@ public function listConversationsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -2396,17 +2468,19 @@ public function listConversationsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListConversationsRequest()) - ->setParent($formattedParent); + $request = (new ListConversationsRequest())->setParent($formattedParent); try { $gapicClient->listConversations($request); // If the $gapicClient method call did not throw, fail the test @@ -2433,15 +2507,17 @@ public function listIssueModelsTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListIssueModelsRequest()) - ->setParent($formattedParent); + $request = (new ListIssueModelsRequest())->setParent($formattedParent); $response = $gapicClient->listIssueModels($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.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -2458,17 +2534,19 @@ public function listIssueModelsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListIssueModelsRequest()) - ->setParent($formattedParent); + $request = (new ListIssueModelsRequest())->setParent($formattedParent); try { $gapicClient->listIssueModels($request); // If the $gapicClient method call did not throw, fail the test @@ -2495,8 +2573,7 @@ public function listIssuesTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new ListIssuesRequest()) - ->setParent($formattedParent); + $request = (new ListIssuesRequest())->setParent($formattedParent); $response = $gapicClient->listIssues($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2520,17 +2597,19 @@ public function listIssuesExceptionTest() $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); + $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new ListIssuesRequest()) - ->setParent($formattedParent); + $request = (new ListIssuesRequest())->setParent($formattedParent); try { $gapicClient->listIssues($request); // If the $gapicClient method call did not throw, fail the test @@ -2555,17 +2634,14 @@ public function listPhraseMatchersTest() // Mock response $nextPageToken = ''; $phraseMatchersElement = new PhraseMatcher(); - $phraseMatchers = [ - $phraseMatchersElement, - ]; + $phraseMatchers = [$phraseMatchersElement]; $expectedResponse = new ListPhraseMatchersResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setPhraseMatchers($phraseMatchers); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListPhraseMatchersRequest()) - ->setParent($formattedParent); + $request = (new ListPhraseMatchersRequest())->setParent($formattedParent); $response = $gapicClient->listPhraseMatchers($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2575,7 +2651,10 @@ public function listPhraseMatchersTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -2592,17 +2671,19 @@ public function listPhraseMatchersExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListPhraseMatchersRequest()) - ->setParent($formattedParent); + $request = (new ListPhraseMatchersRequest())->setParent($formattedParent); try { $gapicClient->listPhraseMatchers($request); // If the $gapicClient method call did not throw, fail the test @@ -2627,17 +2708,14 @@ public function listViewsTest() // Mock response $nextPageToken = ''; $viewsElement = new View(); - $views = [ - $viewsElement, - ]; + $views = [$viewsElement]; $expectedResponse = new ListViewsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setViews($views); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListViewsRequest()) - ->setParent($formattedParent); + $request = (new ListViewsRequest())->setParent($formattedParent); $response = $gapicClient->listViews($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2664,17 +2742,19 @@ public function listViewsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListViewsRequest()) - ->setParent($formattedParent); + $request = (new ListViewsRequest())->setParent($formattedParent); try { $gapicClient->listViews($request); // If the $gapicClient method call did not throw, fail the test @@ -2719,8 +2799,7 @@ public function undeployIssueModelTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new UndeployIssueModelRequest()) - ->setName($formattedName); + $request = (new UndeployIssueModelRequest())->setName($formattedName); $response = $gapicClient->undeployIssueModel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -2730,7 +2809,10 @@ public function undeployIssueModelTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -2776,17 +2858,19 @@ public function undeployIssueModelExceptionTest() $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); + $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $request = (new UndeployIssueModelRequest()) - ->setName($formattedName); + $request = (new UndeployIssueModelRequest())->setName($formattedName); $response = $gapicClient->undeployIssueModel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -2832,15 +2916,17 @@ public function updateConversationTest() $transport->addResponse($expectedResponse); // Mock request $conversation = new Conversation(); - $request = (new UpdateConversationRequest()) - ->setConversation($conversation); + $request = (new UpdateConversationRequest())->setConversation($conversation); $response = $gapicClient->updateConversation($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.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', + $actualFuncCall + ); $actualValue = $actualRequestObject->getConversation(); $this->assertProtobufEquals($conversation, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -2857,17 +2943,19 @@ public function updateConversationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $conversation = new Conversation(); - $request = (new UpdateConversationRequest()) - ->setConversation($conversation); + $request = (new UpdateConversationRequest())->setConversation($conversation); try { $gapicClient->updateConversation($request); // If the $gapicClient method call did not throw, fail the test @@ -2898,8 +2986,7 @@ public function updateIssueTest() $transport->addResponse($expectedResponse); // Mock request $issue = new Issue(); - $request = (new UpdateIssueRequest()) - ->setIssue($issue); + $request = (new UpdateIssueRequest())->setIssue($issue); $response = $gapicClient->updateIssue($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2923,17 +3010,19 @@ public function updateIssueExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $issue = new Issue(); - $request = (new UpdateIssueRequest()) - ->setIssue($issue); + $request = (new UpdateIssueRequest())->setIssue($issue); try { $gapicClient->updateIssue($request); // If the $gapicClient method call did not throw, fail the test @@ -2968,15 +3057,17 @@ public function updateIssueModelTest() $transport->addResponse($expectedResponse); // Mock request $issueModel = new IssueModel(); - $request = (new UpdateIssueModelRequest()) - ->setIssueModel($issueModel); + $request = (new UpdateIssueModelRequest())->setIssueModel($issueModel); $response = $gapicClient->updateIssueModel($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.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', + $actualFuncCall + ); $actualValue = $actualRequestObject->getIssueModel(); $this->assertProtobufEquals($issueModel, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -2993,17 +3084,19 @@ public function updateIssueModelExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $issueModel = new IssueModel(); - $request = (new UpdateIssueModelRequest()) - ->setIssueModel($issueModel); + $request = (new UpdateIssueModelRequest())->setIssueModel($issueModel); try { $gapicClient->updateIssueModel($request); // If the $gapicClient method call did not throw, fail the test @@ -3042,15 +3135,17 @@ public function updatePhraseMatcherTest() $phraseMatcher = new PhraseMatcher(); $phraseMatcherType = PhraseMatcherType::PHRASE_MATCHER_TYPE_UNSPECIFIED; $phraseMatcher->setType($phraseMatcherType); - $request = (new UpdatePhraseMatcherRequest()) - ->setPhraseMatcher($phraseMatcher); + $request = (new UpdatePhraseMatcherRequest())->setPhraseMatcher($phraseMatcher); $response = $gapicClient->updatePhraseMatcher($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.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', + $actualFuncCall + ); $actualValue = $actualRequestObject->getPhraseMatcher(); $this->assertProtobufEquals($phraseMatcher, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -3067,19 +3162,21 @@ public function updatePhraseMatcherExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $phraseMatcher = new PhraseMatcher(); $phraseMatcherType = PhraseMatcherType::PHRASE_MATCHER_TYPE_UNSPECIFIED; $phraseMatcher->setType($phraseMatcherType); - $request = (new UpdatePhraseMatcherRequest()) - ->setPhraseMatcher($phraseMatcher); + $request = (new UpdatePhraseMatcherRequest())->setPhraseMatcher($phraseMatcher); try { $gapicClient->updatePhraseMatcher($request); // If the $gapicClient method call did not throw, fail the test @@ -3111,16 +3208,17 @@ public function updateSettingsTest() // Mock request $settings = new Settings(); $updateMask = new FieldMask(); - $request = (new UpdateSettingsRequest()) - ->setSettings($settings) - ->setUpdateMask($updateMask); + $request = (new UpdateSettingsRequest())->setSettings($settings)->setUpdateMask($updateMask); $response = $gapicClient->updateSettings($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.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', + $actualFuncCall + ); $actualValue = $actualRequestObject->getSettings(); $this->assertProtobufEquals($settings, $actualValue); $actualValue = $actualRequestObject->getUpdateMask(); @@ -3139,19 +3237,20 @@ public function updateSettingsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $settings = new Settings(); $updateMask = new FieldMask(); - $request = (new UpdateSettingsRequest()) - ->setSettings($settings) - ->setUpdateMask($updateMask); + $request = (new UpdateSettingsRequest())->setSettings($settings)->setUpdateMask($updateMask); try { $gapicClient->updateSettings($request); // If the $gapicClient method call did not throw, fail the test @@ -3184,8 +3283,7 @@ public function updateViewTest() $transport->addResponse($expectedResponse); // Mock request $view = new View(); - $request = (new UpdateViewRequest()) - ->setView($view); + $request = (new UpdateViewRequest())->setView($view); $response = $gapicClient->updateView($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -3209,17 +3307,19 @@ public function updateViewExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $view = new View(); - $request = (new UpdateViewRequest()) - ->setView($view); + $request = (new UpdateViewRequest())->setView($view); try { $gapicClient->updateView($request); // If the $gapicClient method call did not throw, fail the test @@ -3275,9 +3375,7 @@ public function uploadConversationTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $conversation = new Conversation(); - $request = (new UploadConversationRequest()) - ->setParent($formattedParent) - ->setConversation($conversation); + $request = (new UploadConversationRequest())->setParent($formattedParent)->setConversation($conversation); $response = $gapicClient->uploadConversation($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3287,7 +3385,10 @@ public function uploadConversationTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UploadConversation', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UploadConversation', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getConversation(); @@ -3335,19 +3436,20 @@ public function uploadConversationExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); $conversation = new Conversation(); - $request = (new UploadConversationRequest()) - ->setParent($formattedParent) - ->setConversation($conversation); + $request = (new UploadConversationRequest())->setParent($formattedParent)->setConversation($conversation); $response = $gapicClient->uploadConversation($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3420,7 +3522,10 @@ public function bulkAnalyzeConversationsAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getFilter(); diff --git a/ContactCenterInsights/tests/Unit/V1/ContactCenterInsightsClientTest.php b/ContactCenterInsights/tests/Unit/V1/ContactCenterInsightsClientTest.php deleted file mode 100644 index 582ed4b519fe..000000000000 --- a/ContactCenterInsights/tests/Unit/V1/ContactCenterInsightsClientTest.php +++ /dev/null @@ -1,3159 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ContactCenterInsightsClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ContactCenterInsightsClient($options); - } - - /** @test */ - public function bulkAnalyzeConversationsTest() - { - $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/bulkAnalyzeConversationsTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $successfulAnalysisCount = 1153322545; - $failedAnalysisCount = 1044285998; - $expectedResponse = new BulkAnalyzeConversationsResponse(); - $expectedResponse->setSuccessfulAnalysisCount($successfulAnalysisCount); - $expectedResponse->setFailedAnalysisCount($failedAnalysisCount); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/bulkAnalyzeConversationsTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $filter = 'filter-1274492040'; - $analysisPercentage = 9980822; - $response = $gapicClient->bulkAnalyzeConversations($formattedParent, $filter, $analysisPercentage); - $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.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getFilter(); - $this->assertProtobufEquals($filter, $actualValue); - $actualValue = $actualApiRequestObject->getAnalysisPercentage(); - $this->assertProtobufEquals($analysisPercentage, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/bulkAnalyzeConversationsTest'); - $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 bulkAnalyzeConversationsExceptionTest() - { - $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/bulkAnalyzeConversationsTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $filter = 'filter-1274492040'; - $analysisPercentage = 9980822; - $response = $gapicClient->bulkAnalyzeConversations($formattedParent, $filter, $analysisPercentage); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/bulkAnalyzeConversationsTest'); - 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 bulkDeleteConversationsTest() - { - $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/bulkDeleteConversationsTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new BulkDeleteConversationsResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/bulkDeleteConversationsTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->bulkDeleteConversations($formattedParent); - $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.contactcenterinsights.v1.ContactCenterInsights/BulkDeleteConversations', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/bulkDeleteConversationsTest'); - $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 bulkDeleteConversationsExceptionTest() - { - $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/bulkDeleteConversationsTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->bulkDeleteConversations($formattedParent); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/bulkDeleteConversationsTest'); - 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 calculateIssueModelStatsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new CalculateIssueModelStatsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedIssueModel = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->calculateIssueModelStats($formattedIssueModel); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', $actualFuncCall); - $actualValue = $actualRequestObject->getIssueModel(); - $this->assertProtobufEquals($formattedIssueModel, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function calculateIssueModelStatsExceptionTest() - { - $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 - $formattedIssueModel = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - try { - $gapicClient->calculateIssueModelStats($formattedIssueModel); - // 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 calculateStatsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $averageTurnCount = 1693477329; - $conversationCount = 1994187347; - $expectedResponse = new CalculateStatsResponse(); - $expectedResponse->setAverageTurnCount($averageTurnCount); - $expectedResponse->setConversationCount($conversationCount); - $transport->addResponse($expectedResponse); - // Mock request - $formattedLocation = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->calculateStats($formattedLocation); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', $actualFuncCall); - $actualValue = $actualRequestObject->getLocation(); - $this->assertProtobufEquals($formattedLocation, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function calculateStatsExceptionTest() - { - $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 - $formattedLocation = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->calculateStats($formattedLocation); - // 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 createAnalysisTest() - { - $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/createAnalysisTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $expectedResponse = new Analysis(); - $expectedResponse->setName($name); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createAnalysisTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $analysis = new Analysis(); - $response = $gapicClient->createAnalysis($formattedParent, $analysis); - $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.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getAnalysis(); - $this->assertProtobufEquals($analysis, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAnalysisTest'); - $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 createAnalysisExceptionTest() - { - $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/createAnalysisTest'); - $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->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $analysis = new Analysis(); - $response = $gapicClient->createAnalysis($formattedParent, $analysis); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAnalysisTest'); - 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 createConversationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $languageCode = 'languageCode-412800396'; - $agentId = 'agentId1469158549'; - $turnCount = 428155597; - $obfuscatedUserId = 'obfuscatedUserId-227848300'; - $expectedResponse = new Conversation(); - $expectedResponse->setName($name); - $expectedResponse->setLanguageCode($languageCode); - $expectedResponse->setAgentId($agentId); - $expectedResponse->setTurnCount($turnCount); - $expectedResponse->setObfuscatedUserId($obfuscatedUserId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $conversation = new Conversation(); - $response = $gapicClient->createConversation($formattedParent, $conversation); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getConversation(); - $this->assertProtobufEquals($conversation, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createConversationExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - $conversation = new Conversation(); - try { - $gapicClient->createConversation($formattedParent, $conversation); - // 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 createIssueModelTest() - { - $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/createIssueModelTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $issueCount = 1779144233; - $languageCode = 'languageCode-412800396'; - $expectedResponse = new IssueModel(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIssueCount($issueCount); - $expectedResponse->setLanguageCode($languageCode); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createIssueModelTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $issueModel = new IssueModel(); - $response = $gapicClient->createIssueModel($formattedParent, $issueModel); - $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.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getIssueModel(); - $this->assertProtobufEquals($issueModel, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createIssueModelTest'); - $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 createIssueModelExceptionTest() - { - $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/createIssueModelTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $issueModel = new IssueModel(); - $response = $gapicClient->createIssueModel($formattedParent, $issueModel); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createIssueModelTest'); - 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 createPhraseMatcherTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $revisionId = 'revisionId513861631'; - $versionTag = 'versionTag689430451'; - $displayName = 'displayName1615086568'; - $active = true; - $expectedResponse = new PhraseMatcher(); - $expectedResponse->setName($name); - $expectedResponse->setRevisionId($revisionId); - $expectedResponse->setVersionTag($versionTag); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setActive($active); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $phraseMatcher = new PhraseMatcher(); - $phraseMatcherType = PhraseMatcherType::PHRASE_MATCHER_TYPE_UNSPECIFIED; - $phraseMatcher->setType($phraseMatcherType); - $response = $gapicClient->createPhraseMatcher($formattedParent, $phraseMatcher); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getPhraseMatcher(); - $this->assertProtobufEquals($phraseMatcher, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createPhraseMatcherExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - $phraseMatcher = new PhraseMatcher(); - $phraseMatcherType = PhraseMatcherType::PHRASE_MATCHER_TYPE_UNSPECIFIED; - $phraseMatcher->setType($phraseMatcherType); - try { - $gapicClient->createPhraseMatcher($formattedParent, $phraseMatcher); - // 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 createViewTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $value = 'value111972721'; - $expectedResponse = new View(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setValue($value); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $view = new View(); - $response = $gapicClient->createView($formattedParent, $view); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getView(); - $this->assertProtobufEquals($view, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createViewExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - $view = new View(); - try { - $gapicClient->createView($formattedParent, $view); - // 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 deleteAnalysisTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - $gapicClient->deleteAnalysis($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteAnalysisExceptionTest() - { - $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->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - try { - $gapicClient->deleteAnalysis($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 deleteConversationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $gapicClient->deleteConversation($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteConversationExceptionTest() - { - $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->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - try { - $gapicClient->deleteConversation($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 deleteIssueTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - $gapicClient->deleteIssue($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssue', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteIssueExceptionTest() - { - $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->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - try { - $gapicClient->deleteIssue($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 deleteIssueModelTest() - { - $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/deleteIssueModelTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteIssueModelTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->deleteIssueModel($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.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteIssueModelTest'); - $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 deleteIssueModelExceptionTest() - { - $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/deleteIssueModelTest'); - $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->deleteIssueModel($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteIssueModelTest'); - 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 deletePhraseMatcherTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - $gapicClient->deletePhraseMatcher($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deletePhraseMatcherExceptionTest() - { - $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->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - try { - $gapicClient->deletePhraseMatcher($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 deleteViewTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - $gapicClient->deleteView($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteViewExceptionTest() - { - $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->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - try { - $gapicClient->deleteView($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 deployIssueModelTest() - { - $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/deployIssueModelTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new DeployIssueModelResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deployIssueModelTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->deployIssueModel($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.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deployIssueModelTest'); - $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 deployIssueModelExceptionTest() - { - $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/deployIssueModelTest'); - $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->deployIssueModel($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deployIssueModelTest'); - 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 exportInsightsDataTest() - { - $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/exportInsightsDataTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new ExportInsightsDataResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/exportInsightsDataTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->exportInsightsData($formattedParent); - $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.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/exportInsightsDataTest'); - $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 exportInsightsDataExceptionTest() - { - $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/exportInsightsDataTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->exportInsightsData($formattedParent); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/exportInsightsDataTest'); - 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 getAnalysisTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $expectedResponse = new Analysis(); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - $response = $gapicClient->getAnalysis($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.contactcenterinsights.v1.ContactCenterInsights/GetAnalysis', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getAnalysisExceptionTest() - { - $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->analysisName('[PROJECT]', '[LOCATION]', '[CONVERSATION]', '[ANALYSIS]'); - try { - $gapicClient->getAnalysis($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 getConversationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $languageCode = 'languageCode-412800396'; - $agentId = 'agentId1469158549'; - $turnCount = 428155597; - $obfuscatedUserId = 'obfuscatedUserId-227848300'; - $expectedResponse = new Conversation(); - $expectedResponse->setName($name2); - $expectedResponse->setLanguageCode($languageCode); - $expectedResponse->setAgentId($agentId); - $expectedResponse->setTurnCount($turnCount); - $expectedResponse->setObfuscatedUserId($obfuscatedUserId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $response = $gapicClient->getConversation($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.contactcenterinsights.v1.ContactCenterInsights/GetConversation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getConversationExceptionTest() - { - $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->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - try { - $gapicClient->getConversation($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 getIssueTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Issue(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - $response = $gapicClient->getIssue($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.contactcenterinsights.v1.ContactCenterInsights/GetIssue', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIssueExceptionTest() - { - $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->issueName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]', '[ISSUE]'); - try { - $gapicClient->getIssue($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 getIssueModelTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $issueCount = 1779144233; - $languageCode = 'languageCode-412800396'; - $expectedResponse = new IssueModel(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIssueCount($issueCount); - $expectedResponse->setLanguageCode($languageCode); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->getIssueModel($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.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIssueModelExceptionTest() - { - $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - try { - $gapicClient->getIssueModel($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 getPhraseMatcherTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $revisionId = 'revisionId513861631'; - $versionTag = 'versionTag689430451'; - $displayName = 'displayName1615086568'; - $active = true; - $expectedResponse = new PhraseMatcher(); - $expectedResponse->setName($name2); - $expectedResponse->setRevisionId($revisionId); - $expectedResponse->setVersionTag($versionTag); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setActive($active); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - $response = $gapicClient->getPhraseMatcher($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.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getPhraseMatcherExceptionTest() - { - $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->phraseMatcherName('[PROJECT]', '[LOCATION]', '[PHRASE_MATCHER]'); - try { - $gapicClient->getPhraseMatcher($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 getSettingsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $languageCode = 'languageCode-412800396'; - $expectedResponse = new Settings(); - $expectedResponse->setName($name2); - $expectedResponse->setLanguageCode($languageCode); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->settingsName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->getSettings($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.contactcenterinsights.v1.ContactCenterInsights/GetSettings', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getSettingsExceptionTest() - { - $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->settingsName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->getSettings($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 getViewTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $value = 'value111972721'; - $expectedResponse = new View(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setValue($value); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - $response = $gapicClient->getView($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getViewExceptionTest() - { - $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->viewName('[PROJECT]', '[LOCATION]', '[VIEW]'); - try { - $gapicClient->getView($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 ingestConversationsTest() - { - $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/ingestConversationsTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new IngestConversationsResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/ingestConversationsTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->ingestConversations($formattedParent); - $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.contactcenterinsights.v1.ContactCenterInsights/IngestConversations', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/ingestConversationsTest'); - $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 ingestConversationsExceptionTest() - { - $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/ingestConversationsTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->ingestConversations($formattedParent); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/ingestConversationsTest'); - 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 listAnalysesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $analysesElement = new Analysis(); - $analyses = [ - $analysesElement, - ]; - $expectedResponse = new ListAnalysesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAnalyses($analyses); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - $response = $gapicClient->listAnalyses($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAnalyses()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalyses', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listAnalysesExceptionTest() - { - $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->conversationName('[PROJECT]', '[LOCATION]', '[CONVERSATION]'); - try { - $gapicClient->listAnalyses($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 listConversationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $conversationsElement = new Conversation(); - $conversations = [ - $conversationsElement, - ]; - $expectedResponse = new ListConversationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setConversations($conversations); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listConversations($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getConversations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listConversationsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listConversations($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 listIssueModelsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ListIssueModelsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listIssueModels($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listIssueModelsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listIssueModels($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 listIssuesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ListIssuesResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->listIssues($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssues', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listIssuesExceptionTest() - { - $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - try { - $gapicClient->listIssues($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 listPhraseMatchersTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $phraseMatchersElement = new PhraseMatcher(); - $phraseMatchers = [ - $phraseMatchersElement, - ]; - $expectedResponse = new ListPhraseMatchersResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setPhraseMatchers($phraseMatchers); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listPhraseMatchers($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getPhraseMatchers()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listPhraseMatchersExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listPhraseMatchers($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 listViewsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $viewsElement = new View(); - $views = [ - $viewsElement, - ]; - $expectedResponse = new ListViewsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setViews($views); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listViews($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getViews()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listViewsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listViews($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 undeployIssueModelTest() - { - $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/undeployIssueModelTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new UndeployIssueModelResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/undeployIssueModelTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->undeployIssueModel($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.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/undeployIssueModelTest'); - $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 undeployIssueModelExceptionTest() - { - $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/undeployIssueModelTest'); - $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->issueModelName('[PROJECT]', '[LOCATION]', '[ISSUE_MODEL]'); - $response = $gapicClient->undeployIssueModel($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/undeployIssueModelTest'); - 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 updateConversationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $languageCode = 'languageCode-412800396'; - $agentId = 'agentId1469158549'; - $turnCount = 428155597; - $obfuscatedUserId = 'obfuscatedUserId-227848300'; - $expectedResponse = new Conversation(); - $expectedResponse->setName($name); - $expectedResponse->setLanguageCode($languageCode); - $expectedResponse->setAgentId($agentId); - $expectedResponse->setTurnCount($turnCount); - $expectedResponse->setObfuscatedUserId($obfuscatedUserId); - $transport->addResponse($expectedResponse); - // Mock request - $conversation = new Conversation(); - $response = $gapicClient->updateConversation($conversation); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', $actualFuncCall); - $actualValue = $actualRequestObject->getConversation(); - $this->assertProtobufEquals($conversation, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateConversationExceptionTest() - { - $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 - $conversation = new Conversation(); - try { - $gapicClient->updateConversation($conversation); - // 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 updateIssueTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Issue(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $issue = new Issue(); - $response = $gapicClient->updateIssue($issue); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue', $actualFuncCall); - $actualValue = $actualRequestObject->getIssue(); - $this->assertProtobufEquals($issue, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateIssueExceptionTest() - { - $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 - $issue = new Issue(); - try { - $gapicClient->updateIssue($issue); - // 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 updateIssueModelTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $issueCount = 1779144233; - $languageCode = 'languageCode-412800396'; - $expectedResponse = new IssueModel(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIssueCount($issueCount); - $expectedResponse->setLanguageCode($languageCode); - $transport->addResponse($expectedResponse); - // Mock request - $issueModel = new IssueModel(); - $response = $gapicClient->updateIssueModel($issueModel); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', $actualFuncCall); - $actualValue = $actualRequestObject->getIssueModel(); - $this->assertProtobufEquals($issueModel, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateIssueModelExceptionTest() - { - $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 - $issueModel = new IssueModel(); - try { - $gapicClient->updateIssueModel($issueModel); - // 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 updatePhraseMatcherTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $revisionId = 'revisionId513861631'; - $versionTag = 'versionTag689430451'; - $displayName = 'displayName1615086568'; - $active = true; - $expectedResponse = new PhraseMatcher(); - $expectedResponse->setName($name); - $expectedResponse->setRevisionId($revisionId); - $expectedResponse->setVersionTag($versionTag); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setActive($active); - $transport->addResponse($expectedResponse); - // Mock request - $phraseMatcher = new PhraseMatcher(); - $phraseMatcherType = PhraseMatcherType::PHRASE_MATCHER_TYPE_UNSPECIFIED; - $phraseMatcher->setType($phraseMatcherType); - $response = $gapicClient->updatePhraseMatcher($phraseMatcher); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', $actualFuncCall); - $actualValue = $actualRequestObject->getPhraseMatcher(); - $this->assertProtobufEquals($phraseMatcher, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updatePhraseMatcherExceptionTest() - { - $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 - $phraseMatcher = new PhraseMatcher(); - $phraseMatcherType = PhraseMatcherType::PHRASE_MATCHER_TYPE_UNSPECIFIED; - $phraseMatcher->setType($phraseMatcherType); - try { - $gapicClient->updatePhraseMatcher($phraseMatcher); - // 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 updateSettingsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $languageCode = 'languageCode-412800396'; - $expectedResponse = new Settings(); - $expectedResponse->setName($name); - $expectedResponse->setLanguageCode($languageCode); - $transport->addResponse($expectedResponse); - // Mock request - $settings = new Settings(); - $updateMask = new FieldMask(); - $response = $gapicClient->updateSettings($settings, $updateMask); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', $actualFuncCall); - $actualValue = $actualRequestObject->getSettings(); - $this->assertProtobufEquals($settings, $actualValue); - $actualValue = $actualRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateSettingsExceptionTest() - { - $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 - $settings = new Settings(); - $updateMask = new FieldMask(); - try { - $gapicClient->updateSettings($settings, $updateMask); - // 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 updateViewTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $value = 'value111972721'; - $expectedResponse = new View(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setValue($value); - $transport->addResponse($expectedResponse); - // Mock request - $view = new View(); - $response = $gapicClient->updateView($view); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView', $actualFuncCall); - $actualValue = $actualRequestObject->getView(); - $this->assertProtobufEquals($view, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateViewExceptionTest() - { - $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 - $view = new View(); - try { - $gapicClient->updateView($view); - // 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 uploadConversationTest() - { - $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/uploadConversationTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $languageCode = 'languageCode-412800396'; - $agentId = 'agentId1469158549'; - $turnCount = 428155597; - $obfuscatedUserId = 'obfuscatedUserId-227848300'; - $expectedResponse = new Conversation(); - $expectedResponse->setName($name); - $expectedResponse->setLanguageCode($languageCode); - $expectedResponse->setAgentId($agentId); - $expectedResponse->setTurnCount($turnCount); - $expectedResponse->setObfuscatedUserId($obfuscatedUserId); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/uploadConversationTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $conversation = new Conversation(); - $response = $gapicClient->uploadConversation($formattedParent, $conversation); - $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.contactcenterinsights.v1.ContactCenterInsights/UploadConversation', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getConversation(); - $this->assertProtobufEquals($conversation, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/uploadConversationTest'); - $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 uploadConversationExceptionTest() - { - $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/uploadConversationTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $conversation = new Conversation(); - $response = $gapicClient->uploadConversation($formattedParent, $conversation); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/uploadConversationTest'); - 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()); - } -} diff --git a/DataCatalog/.OwlBot.yaml b/DataCatalog/.OwlBot.yaml index 919643089d6f..ef3ef13d5157 100644 --- a/DataCatalog/.OwlBot.yaml +++ b/DataCatalog/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/datacatalog/v1/.*-php/(.*) - dest: /owl-bot-staging/DataCatalog/v1/$1 + - source: /google/cloud/datacatalog/(v1)/.*-php/(.*) + dest: /owl-bot-staging/DataCatalog/$1/$2 api-name: DataCatalog diff --git a/DataCatalog/owlbot.py b/DataCatalog/owlbot.py index 18bd72c67b11..f2f82bdb4fd4 100644 --- a/DataCatalog/owlbot.py +++ b/DataCatalog/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2020 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,35 +32,25 @@ php.owlbot_main(src=src, dest=dest) - -# Change the wording for the deprecation warning. -s.replace( - 'src/*/*_*.php', - r'will be removed in the next major release', - 'will be removed in a future release') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links +# remove class_alias code s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) + "src/V*/**/*.php", + r"^// Adding a class alias for backwards compatibility with the previous class name.$" + + "\n" + + r"^class_alias\(.*\);$" + + "\n", + '') + +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/DataCatalog/src/V1/BigQueryConnectionSpec.php b/DataCatalog/src/V1/BigQueryConnectionSpec.php index 1531e6f3d001..4e2d0f006d00 100644 --- a/DataCatalog/src/V1/BigQueryConnectionSpec.php +++ b/DataCatalog/src/V1/BigQueryConnectionSpec.php @@ -20,14 +20,14 @@ class BigQueryConnectionSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.BigQueryConnectionSpec.ConnectionType connection_type = 1; */ - private $connection_type = 0; + protected $connection_type = 0; /** * True if there are credentials attached to the BigQuery connection; false * otherwise. * * Generated from protobuf field bool has_credential = 3; */ - private $has_credential = false; + protected $has_credential = false; protected $connection_spec; /** diff --git a/DataCatalog/src/V1/BigQueryConnectionSpec/ConnectionType.php b/DataCatalog/src/V1/BigQueryConnectionSpec/ConnectionType.php index 7d8e9296d0aa..6659330fdb85 100644 --- a/DataCatalog/src/V1/BigQueryConnectionSpec/ConnectionType.php +++ b/DataCatalog/src/V1/BigQueryConnectionSpec/ConnectionType.php @@ -52,6 +52,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ConnectionType::class, \Google\Cloud\DataCatalog\V1\BigQueryConnectionSpec_ConnectionType::class); diff --git a/DataCatalog/src/V1/BigQueryConnectionSpec_ConnectionType.php b/DataCatalog/src/V1/BigQueryConnectionSpec_ConnectionType.php deleted file mode 100644 index 98134e6a7c05..000000000000 --- a/DataCatalog/src/V1/BigQueryConnectionSpec_ConnectionType.php +++ /dev/null @@ -1,16 +0,0 @@ -string dataset = 1 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $dataset = ''; + protected $dataset = ''; /** * Output only. The table name prefix of the shards. * The name of any given shard is `[table_prefix]YYYYMMDD`. @@ -34,19 +34,19 @@ class BigQueryDateShardedSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_prefix = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $table_prefix = ''; + protected $table_prefix = ''; /** * Output only. Total number of shards. * * Generated from protobuf field int64 shard_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $shard_count = 0; + protected $shard_count = 0; /** * Output only. BigQuery resource name of the latest shard. * * Generated from protobuf field string latest_shard_resource = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $latest_shard_resource = ''; + protected $latest_shard_resource = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/BigQueryTableSpec.php b/DataCatalog/src/V1/BigQueryTableSpec.php index f63192032835..0cb87b4b854f 100644 --- a/DataCatalog/src/V1/BigQueryTableSpec.php +++ b/DataCatalog/src/V1/BigQueryTableSpec.php @@ -20,7 +20,7 @@ class BigQueryTableSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.TableSourceType table_source_type = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $table_source_type = 0; + protected $table_source_type = 0; protected $type_spec; /** diff --git a/DataCatalog/src/V1/BusinessContext.php b/DataCatalog/src/V1/BusinessContext.php index 1f0df96260ae..21c5c7db22dc 100644 --- a/DataCatalog/src/V1/BusinessContext.php +++ b/DataCatalog/src/V1/BusinessContext.php @@ -20,13 +20,13 @@ class BusinessContext extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.EntryOverview entry_overview = 1; */ - private $entry_overview = null; + protected $entry_overview = null; /** * Contact people for the entry. * * Generated from protobuf field .google.cloud.datacatalog.v1.Contacts contacts = 2; */ - private $contacts = null; + protected $contacts = null; /** * Constructor. diff --git a/DataCatalog/src/V1/Client/DataCatalogClient.php b/DataCatalog/src/V1/Client/DataCatalogClient.php index 1d95a803a4f0..acf15e4aa73d 100644 --- a/DataCatalog/src/V1/Client/DataCatalogClient.php +++ b/DataCatalog/src/V1/Client/DataCatalogClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a entry * resource. @@ -282,8 +301,13 @@ public static function locationName(string $project, string $location): string * * @return string The formatted tag resource. */ - public static function tagName(string $project, string $location, string $entryGroup, string $entry, string $tag): string - { + public static function tagName( + string $project, + string $location, + string $entryGroup, + string $entry, + string $tag + ): string { return self::getPathTemplate('tag')->render([ 'project' => $project, 'location' => $location, @@ -323,8 +347,12 @@ public static function tagTemplateName(string $project, string $location, string * * @return string The formatted tag_template_field resource. */ - public static function tagTemplateFieldName(string $project, string $location, string $tagTemplate, string $field): string - { + public static function tagTemplateFieldName( + string $project, + string $location, + string $tagTemplate, + string $field + ): string { return self::getPathTemplate('tagTemplateField')->render([ 'project' => $project, 'location' => $location, @@ -345,8 +373,13 @@ public static function tagTemplateFieldName(string $project, string $location, s * * @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 - { + public static function tagTemplateFieldEnumValueName( + string $project, + string $location, + string $tagTemplate, + string $tagTemplateFieldId, + string $enumValueDisplayName + ): string { return self::getPathTemplate('tagTemplateFieldEnumValue')->render([ 'project' => $project, 'location' => $location, @@ -498,7 +531,7 @@ public function createEntry(CreateEntryRequest $request, array $callOptions = [] * 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. + * Identity and Access Management](/data-catalog/docs/concepts/iam) policies. * These policies specify users who can create, edit, and view entries * within entry groups. * @@ -639,8 +672,10 @@ public function createTagTemplate(CreateTagTemplateRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function createTagTemplateField(CreateTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField - { + public function createTagTemplateField( + CreateTagTemplateFieldRequest $request, + array $callOptions = [] + ): TagTemplateField { return $this->startApiCall('CreateTagTemplateField', $request, $callOptions)->wait(); } @@ -1189,8 +1224,10 @@ public function reconcileTags(ReconcileTagsRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function renameTagTemplateField(RenameTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField - { + public function renameTagTemplateField( + RenameTagTemplateFieldRequest $request, + array $callOptions = [] + ): TagTemplateField { return $this->startApiCall('RenameTagTemplateField', $request, $callOptions)->wait(); } @@ -1218,8 +1255,10 @@ public function renameTagTemplateField(RenameTagTemplateFieldRequest $request, a * * @throws ApiException Thrown if the API call fails. */ - public function renameTagTemplateFieldEnumValue(RenameTagTemplateFieldEnumValueRequest $request, array $callOptions = []): TagTemplateField - { + public function renameTagTemplateFieldEnumValue( + RenameTagTemplateFieldEnumValueRequest $request, + array $callOptions = [] + ): TagTemplateField { return $this->startApiCall('RenameTagTemplateFieldEnumValue', $request, $callOptions)->wait(); } @@ -1366,8 +1405,10 @@ public function starEntry(StarEntryRequest $request, array $callOptions = []): S * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } @@ -1548,8 +1589,10 @@ public function updateTagTemplate(UpdateTagTemplateRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function updateTagTemplateField(UpdateTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField - { + 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 8f9aca6414b7..fc90ee91f8bf 100644 --- a/DataCatalog/src/V1/Client/PolicyTagManagerClient.php +++ b/DataCatalog/src/V1/Client/PolicyTagManagerClient.php @@ -1,6 +1,6 @@ startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/DataCatalog/src/V1/Client/PolicyTagManagerSerializationClient.php b/DataCatalog/src/V1/Client/PolicyTagManagerSerializationClient.php index e4377418c332..7b8022ce51ab 100644 --- a/DataCatalog/src/V1/Client/PolicyTagManagerSerializationClient.php +++ b/DataCatalog/src/V1/Client/PolicyTagManagerSerializationClient.php @@ -1,6 +1,6 @@ [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/policy_tag_manager_serialization_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/policy_tag_manager_serialization_rest_client_config.php', ], ], ]; @@ -265,8 +264,10 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function exportTaxonomies(ExportTaxonomiesRequest $request, array $callOptions = []): ExportTaxonomiesResponse - { + public function exportTaxonomies( + ExportTaxonomiesRequest $request, + array $callOptions = [] + ): ExportTaxonomiesResponse { return $this->startApiCall('ExportTaxonomies', $request, $callOptions)->wait(); } @@ -299,8 +300,10 @@ public function exportTaxonomies(ExportTaxonomiesRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function importTaxonomies(ImportTaxonomiesRequest $request, array $callOptions = []): ImportTaxonomiesResponse - { + public function importTaxonomies( + ImportTaxonomiesRequest $request, + array $callOptions = [] + ): ImportTaxonomiesResponse { return $this->startApiCall('ImportTaxonomies', $request, $callOptions)->wait(); } diff --git a/DataCatalog/src/V1/CloudBigtableInstanceSpec/CloudBigtableClusterSpec.php b/DataCatalog/src/V1/CloudBigtableInstanceSpec/CloudBigtableClusterSpec.php index 823b43aa1e30..d2885690a5af 100644 --- a/DataCatalog/src/V1/CloudBigtableInstanceSpec/CloudBigtableClusterSpec.php +++ b/DataCatalog/src/V1/CloudBigtableInstanceSpec/CloudBigtableClusterSpec.php @@ -20,25 +20,25 @@ class CloudBigtableClusterSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * Location of the cluster, typically a Cloud zone. * * Generated from protobuf field string location = 2; */ - private $location = ''; + protected $location = ''; /** * Type of the resource. For a cluster this would be "CLUSTER". * * Generated from protobuf field string type = 3; */ - private $type = ''; + protected $type = ''; /** * A link back to the parent resource, in this case Instance. * * Generated from protobuf field string linked_resource = 4; */ - private $linked_resource = ''; + protected $linked_resource = ''; /** * Constructor. @@ -167,6 +167,4 @@ public function setLinkedResource($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(CloudBigtableClusterSpec::class, \Google\Cloud\DataCatalog\V1\CloudBigtableInstanceSpec_CloudBigtableClusterSpec::class); diff --git a/DataCatalog/src/V1/CloudBigtableSystemSpec.php b/DataCatalog/src/V1/CloudBigtableSystemSpec.php index 9c646298209a..4e0008126b26 100644 --- a/DataCatalog/src/V1/CloudBigtableSystemSpec.php +++ b/DataCatalog/src/V1/CloudBigtableSystemSpec.php @@ -23,7 +23,7 @@ class CloudBigtableSystemSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string instance_display_name = 1; */ - private $instance_display_name = ''; + protected $instance_display_name = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec.php b/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec.php index 434ec5f358e3..5069ad521666 100644 --- a/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec.php +++ b/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec.php @@ -20,19 +20,19 @@ class CloudSqlBigQueryConnectionSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string instance_id = 1; */ - private $instance_id = ''; + protected $instance_id = ''; /** * Database name. * * Generated from protobuf field string database = 2; */ - private $database = ''; + protected $database = ''; /** * Type of the Cloud SQL database. * * Generated from protobuf field .google.cloud.datacatalog.v1.CloudSqlBigQueryConnectionSpec.DatabaseType type = 3; */ - private $type = 0; + protected $type = 0; /** * Constructor. diff --git a/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec/DatabaseType.php b/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec/DatabaseType.php index 97f9d2e09bcd..0c45d6f60f7b 100644 --- a/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec/DatabaseType.php +++ b/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec/DatabaseType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(DatabaseType::class, \Google\Cloud\DataCatalog\V1\CloudSqlBigQueryConnectionSpec_DatabaseType::class); diff --git a/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec_DatabaseType.php b/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec_DatabaseType.php deleted file mode 100644 index d804298d2046..000000000000 --- a/DataCatalog/src/V1/CloudSqlBigQueryConnectionSpec_DatabaseType.php +++ /dev/null @@ -1,16 +0,0 @@ -string column = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $column = ''; + protected $column = ''; /** * Required. Type of the column. * Must be a UTF-8 string with the maximum size of 128 bytes. * * Generated from protobuf field string type = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = ''; + protected $type = ''; /** * Optional. Description of the column. Default value is an empty string. * The description must be a UTF-8 string with the maximum size of 2000 @@ -38,7 +38,7 @@ class ColumnSchema extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $description = ''; + protected $description = ''; /** * Optional. A column's mode indicates whether values in this column are * required, nullable, or repeated. @@ -47,25 +47,25 @@ class ColumnSchema extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string mode = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $mode = ''; + protected $mode = ''; /** * Optional. Default value for the column. * * Generated from protobuf field string default_value = 8 [(.google.api.field_behavior) = OPTIONAL]; */ - private $default_value = ''; + protected $default_value = ''; /** * Optional. Ordinal position * * Generated from protobuf field int32 ordinal_position = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - private $ordinal_position = 0; + protected $ordinal_position = 0; /** * Optional. Most important inclusion of this column. * * Generated from protobuf field .google.cloud.datacatalog.v1.ColumnSchema.IndexingType highest_indexing_type = 10 [(.google.api.field_behavior) = OPTIONAL]; */ - private $highest_indexing_type = 0; + protected $highest_indexing_type = 0; /** * Optional. Schema of sub-columns. A column can have zero or more * sub-columns. @@ -83,14 +83,14 @@ class ColumnSchema extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.ColumnSchema.FieldElementType range_element_type = 19 [(.google.api.field_behavior) = OPTIONAL]; */ - private $range_element_type = null; + protected $range_element_type = null; /** * Optional. Garbage collection policy for the column or column family. * Applies to systems like Cloud Bigtable. * * Generated from protobuf field string gc_rule = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $gc_rule = ''; + protected $gc_rule = ''; protected $system_spec; /** diff --git a/DataCatalog/src/V1/ColumnSchema/FieldElementType.php b/DataCatalog/src/V1/ColumnSchema/FieldElementType.php index 68e85910666f..571c05d84bed 100644 --- a/DataCatalog/src/V1/ColumnSchema/FieldElementType.php +++ b/DataCatalog/src/V1/ColumnSchema/FieldElementType.php @@ -21,7 +21,7 @@ class FieldElementType extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string type = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = ''; + protected $type = ''; /** * Constructor. @@ -69,6 +69,4 @@ public function setType($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(FieldElementType::class, \Google\Cloud\DataCatalog\V1\ColumnSchema_FieldElementType::class); diff --git a/DataCatalog/src/V1/ColumnSchema/IndexingType.php b/DataCatalog/src/V1/ColumnSchema/IndexingType.php index 88e5298ab423..b37747266b60 100644 --- a/DataCatalog/src/V1/ColumnSchema/IndexingType.php +++ b/DataCatalog/src/V1/ColumnSchema/IndexingType.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(IndexingType::class, \Google\Cloud\DataCatalog\V1\ColumnSchema_IndexingType::class); diff --git a/DataCatalog/src/V1/ColumnSchema/LookerColumnSpec.php b/DataCatalog/src/V1/ColumnSchema/LookerColumnSpec.php index 7a14019ca956..e63ddb3b9e32 100644 --- a/DataCatalog/src/V1/ColumnSchema/LookerColumnSpec.php +++ b/DataCatalog/src/V1/ColumnSchema/LookerColumnSpec.php @@ -20,7 +20,7 @@ class LookerColumnSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.ColumnSchema.LookerColumnSpec.LookerColumnType type = 1; */ - private $type = 0; + protected $type = 0; /** * Constructor. @@ -65,6 +65,4 @@ public function setType($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(LookerColumnSpec::class, \Google\Cloud\DataCatalog\V1\ColumnSchema_LookerColumnSpec::class); diff --git a/DataCatalog/src/V1/ColumnSchema/LookerColumnSpec/LookerColumnType.php b/DataCatalog/src/V1/ColumnSchema/LookerColumnSpec/LookerColumnType.php index b2db79f640d0..5c97930c4dc3 100644 --- a/DataCatalog/src/V1/ColumnSchema/LookerColumnSpec/LookerColumnType.php +++ b/DataCatalog/src/V1/ColumnSchema/LookerColumnSpec/LookerColumnType.php @@ -80,6 +80,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(LookerColumnType::class, \Google\Cloud\DataCatalog\V1\ColumnSchema_LookerColumnSpec_LookerColumnType::class); diff --git a/DataCatalog/src/V1/ColumnSchema_IndexingType.php b/DataCatalog/src/V1/ColumnSchema_IndexingType.php deleted file mode 100644 index 695af8a34226..000000000000 --- a/DataCatalog/src/V1/ColumnSchema_IndexingType.php +++ /dev/null @@ -1,16 +0,0 @@ -optional int64 view_count = 1; */ - private $view_count = null; + protected $view_count = null; /** * Constructor. diff --git a/DataCatalog/src/V1/Contacts/Person.php b/DataCatalog/src/V1/Contacts/Person.php index 53c4642d0040..801e6b15b17a 100644 --- a/DataCatalog/src/V1/Contacts/Person.php +++ b/DataCatalog/src/V1/Contacts/Person.php @@ -20,14 +20,14 @@ class Person extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string designation = 1; */ - private $designation = ''; + protected $designation = ''; /** * Email of the person in the format of `john.doe@xyz`, * ``, or `John Doe`. * * Generated from protobuf field string email = 2; */ - private $email = ''; + protected $email = ''; /** * Constructor. @@ -103,6 +103,4 @@ public function setEmail($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Person::class, \Google\Cloud\DataCatalog\V1\Contacts_Person::class); diff --git a/DataCatalog/src/V1/Contacts_Person.php b/DataCatalog/src/V1/Contacts_Person.php deleted file mode 100644 index ed0c12f05d48..000000000000 --- a/DataCatalog/src/V1/Contacts_Person.php +++ /dev/null @@ -1,16 +0,0 @@ -string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID of the entry group to create. * The ID must contain only letters (a-z, A-Z), numbers (0-9), @@ -33,13 +33,13 @@ class CreateEntryGroupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string entry_group_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $entry_group_id = ''; + protected $entry_group_id = ''; /** * The entry group to create. Defaults to empty. * * Generated from protobuf field .google.cloud.datacatalog.v1.EntryGroup entry_group = 2; */ - private $entry_group = null; + protected $entry_group = null; /** * @param string $parent Required. The names of the project and location that the new entry group diff --git a/DataCatalog/src/V1/CreateEntryRequest.php b/DataCatalog/src/V1/CreateEntryRequest.php index 8c39384e16d0..fd4686b7581c 100644 --- a/DataCatalog/src/V1/CreateEntryRequest.php +++ b/DataCatalog/src/V1/CreateEntryRequest.php @@ -23,7 +23,7 @@ class CreateEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID of the entry to create. * The ID must contain only letters (a-z, A-Z), numbers (0-9), @@ -32,13 +32,13 @@ class CreateEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string entry_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $entry_id = ''; + protected $entry_id = ''; /** * Required. The entry to create. * * Generated from protobuf field .google.cloud.datacatalog.v1.Entry entry = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $entry = null; + protected $entry = null; /** * @param string $parent Required. The name of the entry group this entry belongs to. diff --git a/DataCatalog/src/V1/CreatePolicyTagRequest.php b/DataCatalog/src/V1/CreatePolicyTagRequest.php index bed7cf5178ef..064c852d0a2b 100644 --- a/DataCatalog/src/V1/CreatePolicyTagRequest.php +++ b/DataCatalog/src/V1/CreatePolicyTagRequest.php @@ -21,13 +21,13 @@ class CreatePolicyTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The policy tag to create. * * Generated from protobuf field .google.cloud.datacatalog.v1.PolicyTag policy_tag = 2; */ - private $policy_tag = null; + protected $policy_tag = null; /** * @param string $parent Required. Resource name of the taxonomy that the policy tag will belong to. Please see diff --git a/DataCatalog/src/V1/CreateTagRequest.php b/DataCatalog/src/V1/CreateTagRequest.php index 331cf9bcf76a..a226f5e17c49 100644 --- a/DataCatalog/src/V1/CreateTagRequest.php +++ b/DataCatalog/src/V1/CreateTagRequest.php @@ -25,13 +25,13 @@ class CreateTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The tag to create. * * Generated from protobuf field .google.cloud.datacatalog.v1.Tag tag = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $tag = null; + protected $tag = null; /** * @param string $parent Required. The name of the resource to attach this tag to. diff --git a/DataCatalog/src/V1/CreateTagTemplateFieldRequest.php b/DataCatalog/src/V1/CreateTagTemplateFieldRequest.php index 8ce52d4d6303..e9b59f4f670e 100644 --- a/DataCatalog/src/V1/CreateTagTemplateFieldRequest.php +++ b/DataCatalog/src/V1/CreateTagTemplateFieldRequest.php @@ -22,7 +22,7 @@ class CreateTagTemplateFieldRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID of the tag template field to create. * Note: Adding a required field to an existing template is *not* allowed. @@ -33,13 +33,13 @@ class CreateTagTemplateFieldRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string tag_template_field_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $tag_template_field_id = ''; + protected $tag_template_field_id = ''; /** * Required. The tag template field to create. * * Generated from protobuf field .google.cloud.datacatalog.v1.TagTemplateField tag_template_field = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $tag_template_field = null; + protected $tag_template_field = null; /** * @param string $parent Required. The name of the project and the template location diff --git a/DataCatalog/src/V1/CreateTagTemplateRequest.php b/DataCatalog/src/V1/CreateTagTemplateRequest.php index 9331566215db..59ff04cc98e8 100644 --- a/DataCatalog/src/V1/CreateTagTemplateRequest.php +++ b/DataCatalog/src/V1/CreateTagTemplateRequest.php @@ -22,7 +22,7 @@ class CreateTagTemplateRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID of the tag template to create. * The ID must contain only lowercase letters (a-z), numbers (0-9), @@ -31,13 +31,13 @@ class CreateTagTemplateRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string tag_template_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $tag_template_id = ''; + protected $tag_template_id = ''; /** * Required. The tag template to create. * * Generated from protobuf field .google.cloud.datacatalog.v1.TagTemplate tag_template = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $tag_template = null; + protected $tag_template = null; /** * @param string $parent Required. The name of the project and the template location diff --git a/DataCatalog/src/V1/CreateTaxonomyRequest.php b/DataCatalog/src/V1/CreateTaxonomyRequest.php index 83f4012bc038..915bbd53a633 100644 --- a/DataCatalog/src/V1/CreateTaxonomyRequest.php +++ b/DataCatalog/src/V1/CreateTaxonomyRequest.php @@ -21,13 +21,13 @@ class CreateTaxonomyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The taxonomy to create. * * Generated from protobuf field .google.cloud.datacatalog.v1.Taxonomy taxonomy = 2; */ - private $taxonomy = null; + protected $taxonomy = null; /** * @param string $parent Required. Resource name of the project that the taxonomy will belong to. Please see diff --git a/DataCatalog/src/V1/CrossRegionalSource.php b/DataCatalog/src/V1/CrossRegionalSource.php index 979cc7eea960..fd871a9080bf 100644 --- a/DataCatalog/src/V1/CrossRegionalSource.php +++ b/DataCatalog/src/V1/CrossRegionalSource.php @@ -21,7 +21,7 @@ class CrossRegionalSource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string taxonomy = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $taxonomy = ''; + protected $taxonomy = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/DataCatalogClient.php b/DataCatalog/src/V1/DataCatalogClient.php deleted file mode 100644 index 7d6b767450f8..000000000000 --- a/DataCatalog/src/V1/DataCatalogClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/SearchCatalog', - $argument, - ['\Google\Cloud\DataCatalog\V1\SearchCatalogResponse', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\CreateEntryGroupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateEntryGroup(\Google\Cloud\DataCatalog\V1\CreateEntryGroupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/CreateEntryGroup', - $argument, - ['\Google\Cloud\DataCatalog\V1\EntryGroup', 'decode'], - $metadata, $options); - } - - /** - * Gets an entry group. - * @param \Google\Cloud\DataCatalog\V1\GetEntryGroupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetEntryGroup(\Google\Cloud\DataCatalog\V1\GetEntryGroupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/GetEntryGroup', - $argument, - ['\Google\Cloud\DataCatalog\V1\EntryGroup', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\UpdateEntryGroupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateEntryGroup(\Google\Cloud\DataCatalog\V1\UpdateEntryGroupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/UpdateEntryGroup', - $argument, - ['\Google\Cloud\DataCatalog\V1\EntryGroup', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\DeleteEntryGroupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteEntryGroup(\Google\Cloud\DataCatalog\V1\DeleteEntryGroupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/DeleteEntryGroup', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Lists entry groups. - * @param \Google\Cloud\DataCatalog\V1\ListEntryGroupsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListEntryGroups(\Google\Cloud\DataCatalog\V1\ListEntryGroupsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/ListEntryGroups', - $argument, - ['\Google\Cloud\DataCatalog\V1\ListEntryGroupsResponse', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\DataCatalog\V1\CreateEntryRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateEntry(\Google\Cloud\DataCatalog\V1\CreateEntryRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/CreateEntry', - $argument, - ['\Google\Cloud\DataCatalog\V1\Entry', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\UpdateEntryRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateEntry(\Google\Cloud\DataCatalog\V1\UpdateEntryRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/UpdateEntry', - $argument, - ['\Google\Cloud\DataCatalog\V1\Entry', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\DeleteEntryRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteEntry(\Google\Cloud\DataCatalog\V1\DeleteEntryRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/DeleteEntry', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Gets an entry. - * @param \Google\Cloud\DataCatalog\V1\GetEntryRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetEntry(\Google\Cloud\DataCatalog\V1\GetEntryRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/GetEntry', - $argument, - ['\Google\Cloud\DataCatalog\V1\Entry', 'decode'], - $metadata, $options); - } - - /** - * Gets an entry by its target resource name. - * - * The resource name comes from the source Google Cloud Platform service. - * @param \Google\Cloud\DataCatalog\V1\LookupEntryRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function LookupEntry(\Google\Cloud\DataCatalog\V1\LookupEntryRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/LookupEntry', - $argument, - ['\Google\Cloud\DataCatalog\V1\Entry', 'decode'], - $metadata, $options); - } - - /** - * 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]. - * @param \Google\Cloud\DataCatalog\V1\ListEntriesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListEntries(\Google\Cloud\DataCatalog\V1\ListEntriesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/ListEntries', - $argument, - ['\Google\Cloud\DataCatalog\V1\ListEntriesResponse', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\DataCatalog\V1\ModifyEntryOverviewRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ModifyEntryOverview(\Google\Cloud\DataCatalog\V1\ModifyEntryOverviewRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/ModifyEntryOverview', - $argument, - ['\Google\Cloud\DataCatalog\V1\EntryOverview', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\DataCatalog\V1\ModifyEntryContactsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ModifyEntryContacts(\Google\Cloud\DataCatalog\V1\ModifyEntryContactsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/ModifyEntryContacts', - $argument, - ['\Google\Cloud\DataCatalog\V1\Contacts', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\CreateTagTemplateRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateTagTemplate(\Google\Cloud\DataCatalog\V1\CreateTagTemplateRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/CreateTagTemplate', - $argument, - ['\Google\Cloud\DataCatalog\V1\TagTemplate', 'decode'], - $metadata, $options); - } - - /** - * Gets a tag template. - * @param \Google\Cloud\DataCatalog\V1\GetTagTemplateRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetTagTemplate(\Google\Cloud\DataCatalog\V1\GetTagTemplateRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/GetTagTemplate', - $argument, - ['\Google\Cloud\DataCatalog\V1\TagTemplate', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\UpdateTagTemplateRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateTagTemplate(\Google\Cloud\DataCatalog\V1\UpdateTagTemplateRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/UpdateTagTemplate', - $argument, - ['\Google\Cloud\DataCatalog\V1\TagTemplate', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\DeleteTagTemplateRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteTagTemplate(\Google\Cloud\DataCatalog\V1\DeleteTagTemplateRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/DeleteTagTemplate', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\CreateTagTemplateFieldRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateTagTemplateField(\Google\Cloud\DataCatalog\V1\CreateTagTemplateFieldRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/CreateTagTemplateField', - $argument, - ['\Google\Cloud\DataCatalog\V1\TagTemplateField', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\UpdateTagTemplateFieldRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateTagTemplateField(\Google\Cloud\DataCatalog\V1\UpdateTagTemplateFieldRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/UpdateTagTemplateField', - $argument, - ['\Google\Cloud\DataCatalog\V1\TagTemplateField', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\RenameTagTemplateFieldRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function RenameTagTemplateField(\Google\Cloud\DataCatalog\V1\RenameTagTemplateFieldRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/RenameTagTemplateField', - $argument, - ['\Google\Cloud\DataCatalog\V1\TagTemplateField', 'decode'], - $metadata, $options); - } - - /** - * Renames an enum value in a tag template. - * - * Within a single enum field, enum values must be unique. - * @param \Google\Cloud\DataCatalog\V1\RenameTagTemplateFieldEnumValueRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function RenameTagTemplateFieldEnumValue(\Google\Cloud\DataCatalog\V1\RenameTagTemplateFieldEnumValueRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/RenameTagTemplateFieldEnumValue', - $argument, - ['\Google\Cloud\DataCatalog\V1\TagTemplateField', 'decode'], - $metadata, $options); - } - - /** - * 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). - * @param \Google\Cloud\DataCatalog\V1\DeleteTagTemplateFieldRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteTagTemplateField(\Google\Cloud\DataCatalog\V1\DeleteTagTemplateFieldRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/DeleteTagTemplateField', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\DataCatalog\V1\CreateTagRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateTag(\Google\Cloud\DataCatalog\V1\CreateTagRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/CreateTag', - $argument, - ['\Google\Cloud\DataCatalog\V1\Tag', 'decode'], - $metadata, $options); - } - - /** - * Updates an existing tag. - * @param \Google\Cloud\DataCatalog\V1\UpdateTagRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateTag(\Google\Cloud\DataCatalog\V1\UpdateTagRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/UpdateTag', - $argument, - ['\Google\Cloud\DataCatalog\V1\Tag', 'decode'], - $metadata, $options); - } - - /** - * Deletes a tag. - * @param \Google\Cloud\DataCatalog\V1\DeleteTagRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteTag(\Google\Cloud\DataCatalog\V1\DeleteTagRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/DeleteTag', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Lists tags assigned to an [Entry][google.cloud.datacatalog.v1.Entry]. - * The [columns][google.cloud.datacatalog.v1.Tag.column] in the response are - * lowercased. - * @param \Google\Cloud\DataCatalog\V1\ListTagsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListTags(\Google\Cloud\DataCatalog\V1\ListTagsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/ListTags', - $argument, - ['\Google\Cloud\DataCatalog\V1\ListTagsResponse', 'decode'], - $metadata, $options); - } - - /** - * `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. - * @param \Google\Cloud\DataCatalog\V1\ReconcileTagsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ReconcileTags(\Google\Cloud\DataCatalog\V1\ReconcileTagsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/ReconcileTags', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Marks an [Entry][google.cloud.datacatalog.v1.Entry] as starred by - * the current user. Starring information is private to each user. - * @param \Google\Cloud\DataCatalog\V1\StarEntryRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function StarEntry(\Google\Cloud\DataCatalog\V1\StarEntryRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/StarEntry', - $argument, - ['\Google\Cloud\DataCatalog\V1\StarEntryResponse', 'decode'], - $metadata, $options); - } - - /** - * Marks an [Entry][google.cloud.datacatalog.v1.Entry] as NOT starred by - * the current user. Starring information is private to each user. - * @param \Google\Cloud\DataCatalog\V1\UnstarEntryRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UnstarEntry(\Google\Cloud\DataCatalog\V1\UnstarEntryRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/UnstarEntry', - $argument, - ['\Google\Cloud\DataCatalog\V1\UnstarEntryResponse', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\Iam\V1\SetIamPolicyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function SetIamPolicy(\Google\Cloud\Iam\V1\SetIamPolicyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/SetIamPolicy', - $argument, - ['\Google\Cloud\Iam\V1\Policy', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\Iam\V1\GetIamPolicyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetIamPolicy(\Google\Cloud\Iam\V1\GetIamPolicyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/GetIamPolicy', - $argument, - ['\Google\Cloud\Iam\V1\Policy', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function TestIamPermissions(\Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/TestIamPermissions', - $argument, - ['\Google\Cloud\Iam\V1\TestIamPermissionsResponse', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\DataCatalog\V1\ImportEntriesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ImportEntries(\Google\Cloud\DataCatalog\V1\ImportEntriesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.DataCatalog/ImportEntries', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - -} diff --git a/DataCatalog/src/V1/DataSource.php b/DataCatalog/src/V1/DataSource.php index bef35067be3a..09404782fe65 100644 --- a/DataCatalog/src/V1/DataSource.php +++ b/DataCatalog/src/V1/DataSource.php @@ -20,20 +20,20 @@ class DataSource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.DataSource.Service service = 1; */ - private $service = 0; + protected $service = 0; /** * Full name of a resource as defined by the service. For example: * `//bigquery.googleapis.com/projects/{PROJECT_ID}/locations/{LOCATION}/datasets/{DATASET_ID}/tables/{TABLE_ID}` * * Generated from protobuf field string resource = 2; */ - private $resource = ''; + protected $resource = ''; /** * Output only. Data Catalog entry name, if applicable. * * Generated from protobuf field string source_entry = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $source_entry = ''; + protected $source_entry = ''; protected $properties; /** diff --git a/DataCatalog/src/V1/DataSource/Service.php b/DataCatalog/src/V1/DataSource/Service.php index 57568d1de5b2..946851d72a8e 100644 --- a/DataCatalog/src/V1/DataSource/Service.php +++ b/DataCatalog/src/V1/DataSource/Service.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Service::class, \Google\Cloud\DataCatalog\V1\DataSource_Service::class); diff --git a/DataCatalog/src/V1/DataSourceConnectionSpec.php b/DataCatalog/src/V1/DataSourceConnectionSpec.php index b335d942981c..79706866f1ef 100644 --- a/DataCatalog/src/V1/DataSourceConnectionSpec.php +++ b/DataCatalog/src/V1/DataSourceConnectionSpec.php @@ -23,7 +23,7 @@ class DataSourceConnectionSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.BigQueryConnectionSpec bigquery_connection_spec = 1; */ - private $bigquery_connection_spec = null; + protected $bigquery_connection_spec = null; /** * Constructor. diff --git a/DataCatalog/src/V1/DataSource_Service.php b/DataCatalog/src/V1/DataSource_Service.php deleted file mode 100644 index 5a00e9e61f08..000000000000 --- a/DataCatalog/src/V1/DataSource_Service.php +++ /dev/null @@ -1,16 +0,0 @@ -.google.cloud.datacatalog.v1.DatabaseTableSpec.TableType type = 1; */ - private $type = 0; + protected $type = 0; /** * Output only. Fields specific to a Dataplex table and present only in the * Dataplex table entries. * * Generated from protobuf field .google.cloud.datacatalog.v1.DataplexTableSpec dataplex_table = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $dataplex_table = null; + protected $dataplex_table = null; /** * Spec what aplies to tables that are actually views. * Not set for "real" tables. * * Generated from protobuf field .google.cloud.datacatalog.v1.DatabaseTableSpec.DatabaseViewSpec database_view_spec = 3; */ - private $database_view_spec = null; + protected $database_view_spec = null; /** * Constructor. diff --git a/DataCatalog/src/V1/DatabaseTableSpec/DatabaseViewSpec.php b/DataCatalog/src/V1/DatabaseTableSpec/DatabaseViewSpec.php index cebdd3da1be4..8b3107adf372 100644 --- a/DataCatalog/src/V1/DatabaseTableSpec/DatabaseViewSpec.php +++ b/DataCatalog/src/V1/DatabaseTableSpec/DatabaseViewSpec.php @@ -20,7 +20,7 @@ class DatabaseViewSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.DatabaseTableSpec.DatabaseViewSpec.ViewType view_type = 1; */ - private $view_type = 0; + protected $view_type = 0; protected $source_definition; /** @@ -140,6 +140,4 @@ public function getSourceDefinition() } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(DatabaseViewSpec::class, \Google\Cloud\DataCatalog\V1\DatabaseTableSpec_DatabaseViewSpec::class); diff --git a/DataCatalog/src/V1/DatabaseTableSpec/DatabaseViewSpec/ViewType.php b/DataCatalog/src/V1/DatabaseTableSpec/DatabaseViewSpec/ViewType.php index 6e0092c6b218..b541c5523160 100644 --- a/DataCatalog/src/V1/DatabaseTableSpec/DatabaseViewSpec/ViewType.php +++ b/DataCatalog/src/V1/DatabaseTableSpec/DatabaseViewSpec/ViewType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ViewType::class, \Google\Cloud\DataCatalog\V1\DatabaseTableSpec_DatabaseViewSpec_ViewType::class); diff --git a/DataCatalog/src/V1/DatabaseTableSpec/TableType.php b/DataCatalog/src/V1/DatabaseTableSpec/TableType.php index c25cc7a54b26..2e78838d774e 100644 --- a/DataCatalog/src/V1/DatabaseTableSpec/TableType.php +++ b/DataCatalog/src/V1/DatabaseTableSpec/TableType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(TableType::class, \Google\Cloud\DataCatalog\V1\DatabaseTableSpec_TableType::class); diff --git a/DataCatalog/src/V1/DatabaseTableSpec_DatabaseViewSpec.php b/DataCatalog/src/V1/DatabaseTableSpec_DatabaseViewSpec.php deleted file mode 100644 index c43167a2aee3..000000000000 --- a/DataCatalog/src/V1/DatabaseTableSpec_DatabaseViewSpec.php +++ /dev/null @@ -1,16 +0,0 @@ -.google.cloud.datacatalog.v1.IntegratedSystem system = 1; */ - private $system = 0; + protected $system = 0; /** * Fully qualified name (FQN) of the external table. * * Generated from protobuf field string fully_qualified_name = 28; */ - private $fully_qualified_name = ''; + protected $fully_qualified_name = ''; /** * Google Cloud resource name of the external table. * * Generated from protobuf field string google_cloud_resource = 3; */ - private $google_cloud_resource = ''; + protected $google_cloud_resource = ''; /** * Name of the Data Catalog entry representing the external table. * * Generated from protobuf field string data_catalog_entry = 4; */ - private $data_catalog_entry = ''; + protected $data_catalog_entry = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/DataplexFilesetSpec.php b/DataCatalog/src/V1/DataplexFilesetSpec.php index 8aca6bf627fd..2d446c2e89ed 100644 --- a/DataCatalog/src/V1/DataplexFilesetSpec.php +++ b/DataCatalog/src/V1/DataplexFilesetSpec.php @@ -20,7 +20,7 @@ class DataplexFilesetSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.DataplexSpec dataplex_spec = 1; */ - private $dataplex_spec = null; + protected $dataplex_spec = null; /** * Constructor. diff --git a/DataCatalog/src/V1/DataplexSpec.php b/DataCatalog/src/V1/DataplexSpec.php index bd203db3454d..1cd799f4c9ca 100644 --- a/DataCatalog/src/V1/DataplexSpec.php +++ b/DataCatalog/src/V1/DataplexSpec.php @@ -22,19 +22,19 @@ class DataplexSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string asset = 1; */ - private $asset = ''; + protected $asset = ''; /** * Format of the data. * * Generated from protobuf field .google.cloud.datacatalog.v1.PhysicalSchema data_format = 2; */ - private $data_format = null; + protected $data_format = null; /** * Compression format of the data, e.g., zip, gzip etc. * * Generated from protobuf field string compression_format = 3; */ - private $compression_format = ''; + protected $compression_format = ''; /** * Project ID of the underlying Cloud Storage or BigQuery data. Note that * this may not be the same project as the correspondingly Dataplex lake / @@ -42,7 +42,7 @@ class DataplexSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string project_id = 4; */ - private $project_id = ''; + protected $project_id = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/DataplexTableSpec.php b/DataCatalog/src/V1/DataplexTableSpec.php index 7c7521eb66f7..307535cce500 100644 --- a/DataCatalog/src/V1/DataplexTableSpec.php +++ b/DataCatalog/src/V1/DataplexTableSpec.php @@ -28,13 +28,13 @@ class DataplexTableSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.DataplexSpec dataplex_spec = 2; */ - private $dataplex_spec = null; + protected $dataplex_spec = null; /** * Indicates if the table schema is managed by the user or not. * * Generated from protobuf field bool user_managed = 3; */ - private $user_managed = false; + protected $user_managed = false; /** * Constructor. diff --git a/DataCatalog/src/V1/DeleteEntryGroupRequest.php b/DataCatalog/src/V1/DeleteEntryGroupRequest.php index fef1e62cee6c..18b895c7bc8b 100644 --- a/DataCatalog/src/V1/DeleteEntryGroupRequest.php +++ b/DataCatalog/src/V1/DeleteEntryGroupRequest.php @@ -21,13 +21,13 @@ class DeleteEntryGroupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. If true, deletes all entries in the entry group. * * Generated from protobuf field bool force = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $force = false; + protected $force = false; /** * @param string $name Required. The name of the entry group to delete. Please see diff --git a/DataCatalog/src/V1/DeleteEntryRequest.php b/DataCatalog/src/V1/DeleteEntryRequest.php index e9242935998a..42fa737bce1e 100644 --- a/DataCatalog/src/V1/DeleteEntryRequest.php +++ b/DataCatalog/src/V1/DeleteEntryRequest.php @@ -21,7 +21,7 @@ class DeleteEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the entry to delete. Please see diff --git a/DataCatalog/src/V1/DeletePolicyTagRequest.php b/DataCatalog/src/V1/DeletePolicyTagRequest.php index 411f92b855d2..bf6f2daa89c2 100644 --- a/DataCatalog/src/V1/DeletePolicyTagRequest.php +++ b/DataCatalog/src/V1/DeletePolicyTagRequest.php @@ -22,7 +22,7 @@ class DeletePolicyTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Resource name of the policy tag to delete. diff --git a/DataCatalog/src/V1/DeleteTagRequest.php b/DataCatalog/src/V1/DeleteTagRequest.php index 7291fbb4f403..b2313041c5e7 100644 --- a/DataCatalog/src/V1/DeleteTagRequest.php +++ b/DataCatalog/src/V1/DeleteTagRequest.php @@ -21,7 +21,7 @@ class DeleteTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the tag to delete. Please see diff --git a/DataCatalog/src/V1/DeleteTagTemplateFieldRequest.php b/DataCatalog/src/V1/DeleteTagTemplateFieldRequest.php index 6ab780d76213..e50e145c3d78 100644 --- a/DataCatalog/src/V1/DeleteTagTemplateFieldRequest.php +++ b/DataCatalog/src/V1/DeleteTagTemplateFieldRequest.php @@ -21,14 +21,14 @@ class DeleteTagTemplateFieldRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. If true, deletes this field from any tags that use it. * Currently, `true` is the only supported value. * * Generated from protobuf field bool force = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $force = false; + protected $force = false; /** * @param string $name Required. The name of the tag template field to delete. Please see diff --git a/DataCatalog/src/V1/DeleteTagTemplateRequest.php b/DataCatalog/src/V1/DeleteTagTemplateRequest.php index 1e98020253c6..68b359b7f6fc 100644 --- a/DataCatalog/src/V1/DeleteTagTemplateRequest.php +++ b/DataCatalog/src/V1/DeleteTagTemplateRequest.php @@ -21,14 +21,14 @@ class DeleteTagTemplateRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. If true, deletes all tags that use this template. * Currently, `true` is the only supported value. * * Generated from protobuf field bool force = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $force = false; + protected $force = false; /** * @param string $name Required. The name of the tag template to delete. Please see diff --git a/DataCatalog/src/V1/DeleteTaxonomyRequest.php b/DataCatalog/src/V1/DeleteTaxonomyRequest.php index 981b532f3efc..f0bcf2735ebc 100644 --- a/DataCatalog/src/V1/DeleteTaxonomyRequest.php +++ b/DataCatalog/src/V1/DeleteTaxonomyRequest.php @@ -22,7 +22,7 @@ class DeleteTaxonomyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Resource name of the taxonomy to delete. diff --git a/DataCatalog/src/V1/Entry.php b/DataCatalog/src/V1/Entry.php index c2449e0b729d..6418d70cedb2 100644 --- a/DataCatalog/src/V1/Entry.php +++ b/DataCatalog/src/V1/Entry.php @@ -30,7 +30,7 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * The resource this metadata entry refers to. * For Google Cloud Platform resources, `linked_resource` is the @@ -48,7 +48,7 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string linked_resource = 9; */ - private $linked_resource = ''; + protected $linked_resource = ''; /** * [Fully Qualified Name * (FQN)](https://cloud.google.com//data-catalog/docs/fully-qualified-names) @@ -58,7 +58,7 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string fully_qualified_name = 29; */ - private $fully_qualified_name = ''; + protected $fully_qualified_name = ''; /** * Display name of an entry. * The maximum size is 500 bytes when encoded in UTF-8. @@ -66,7 +66,7 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 3; */ - private $display_name = ''; + protected $display_name = ''; /** * Entry description that can consist of several sentences or paragraphs * that describe entry contents. @@ -78,19 +78,19 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 4; */ - private $description = ''; + protected $description = ''; /** * Business Context of the entry. Not supported for BigQuery datasets * * Generated from protobuf field .google.cloud.datacatalog.v1.BusinessContext business_context = 37; */ - private $business_context = null; + protected $business_context = null; /** * Schema of the entry. An entry might not have any schema attached to it. * * Generated from protobuf field .google.cloud.datacatalog.v1.Schema schema = 5; */ - private $schema = null; + protected $schema = null; /** * Timestamps from the underlying resource, not from the Data Catalog * entry. @@ -100,13 +100,13 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.SystemTimestamps source_system_timestamps = 7; */ - private $source_system_timestamps = null; + protected $source_system_timestamps = null; /** * Resource usage statistics. * * Generated from protobuf field .google.cloud.datacatalog.v1.UsageSignal usage_signal = 13; */ - private $usage_signal = null; + protected $usage_signal = null; /** * Cloud labels attached to the entry. * In Data Catalog, you can create and modify labels attached only to custom @@ -121,14 +121,14 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.DataSource data_source = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $data_source = null; + protected $data_source = null; /** * Output only. Additional information related to the entry. Private to the * current user. * * Generated from protobuf field .google.cloud.datacatalog.v1.PersonalDetails personal_details = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $personal_details = null; + protected $personal_details = null; protected $entry_type; protected $system; protected $system_spec; diff --git a/DataCatalog/src/V1/EntryGroup.php b/DataCatalog/src/V1/EntryGroup.php index 4523688f10bf..0b5f74f3273d 100644 --- a/DataCatalog/src/V1/EntryGroup.php +++ b/DataCatalog/src/V1/EntryGroup.php @@ -24,14 +24,14 @@ class EntryGroup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * A short name to identify the entry group, for example, * "analytics data - jan 2011". Default value is an empty string. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Entry group description. Can consist of several sentences or * paragraphs that describe the entry group contents. @@ -39,13 +39,13 @@ class EntryGroup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 3; */ - private $description = ''; + protected $description = ''; /** * Output only. Timestamps of the entry group. Default value is empty. * * Generated from protobuf field .google.cloud.datacatalog.v1.SystemTimestamps data_catalog_timestamps = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $data_catalog_timestamps = null; + protected $data_catalog_timestamps = null; /** * Constructor. diff --git a/DataCatalog/src/V1/EntryOverview.php b/DataCatalog/src/V1/EntryOverview.php index 6bf1a2fd9a88..b4ff526f9098 100644 --- a/DataCatalog/src/V1/EntryOverview.php +++ b/DataCatalog/src/V1/EntryOverview.php @@ -25,7 +25,7 @@ class EntryOverview extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string overview = 1; */ - private $overview = ''; + protected $overview = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/EntryType.php b/DataCatalog/src/V1/EntryType.php index 6e3f7b41f6df..77a152984899 100644 --- a/DataCatalog/src/V1/EntryType.php +++ b/DataCatalog/src/V1/EntryType.php @@ -16,8 +16,8 @@ * the [`Entry`](#resource:-entry) field `user_specified_type`. For more * information, see * [Surface files from Cloud Storage with fileset - * entries](https://cloud.google.com/data-catalog/docs/how-to/filesets) or [Create custom entries for - * your data sources](https://cloud.google.com/data-catalog/docs/how-to/custom-entries). + * entries](/data-catalog/docs/how-to/filesets) or [Create custom entries for + * your data sources](/data-catalog/docs/how-to/custom-entries). * * Protobuf type google.cloud.datacatalog.v1.EntryType */ @@ -39,7 +39,7 @@ class EntryType /** * The type of models. * For more information, see [Supported models in BigQuery - * ML](https://cloud.google.com/bigquery/docs/bqml-introduction#supported_models). + * ML](/bigquery/docs/bqml-introduction#supported_models). * * Generated from protobuf enum MODEL = 5; */ diff --git a/DataCatalog/src/V1/ExportTaxonomiesRequest.php b/DataCatalog/src/V1/ExportTaxonomiesRequest.php index 6e9d950c6f9e..1bc6ad77ffb2 100644 --- a/DataCatalog/src/V1/ExportTaxonomiesRequest.php +++ b/DataCatalog/src/V1/ExportTaxonomiesRequest.php @@ -22,7 +22,7 @@ class ExportTaxonomiesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. Resource names of the taxonomies to export. * diff --git a/DataCatalog/src/V1/FieldType/EnumType.php b/DataCatalog/src/V1/FieldType/EnumType.php index 1c20119a3004..b7fb222f5da0 100644 --- a/DataCatalog/src/V1/FieldType/EnumType.php +++ b/DataCatalog/src/V1/FieldType/EnumType.php @@ -87,6 +87,4 @@ public function setAllowedValues($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(EnumType::class, \Google\Cloud\DataCatalog\V1\FieldType_EnumType::class); diff --git a/DataCatalog/src/V1/FieldType/EnumType/EnumValue.php b/DataCatalog/src/V1/FieldType/EnumType/EnumValue.php index a94ffb849e44..64f3f3b31ba2 100644 --- a/DataCatalog/src/V1/FieldType/EnumType/EnumValue.php +++ b/DataCatalog/src/V1/FieldType/EnumType/EnumValue.php @@ -22,7 +22,7 @@ class EnumValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. @@ -79,6 +79,4 @@ public function setDisplayName($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(EnumValue::class, \Google\Cloud\DataCatalog\V1\FieldType_EnumType_EnumValue::class); diff --git a/DataCatalog/src/V1/FieldType/PrimitiveType.php b/DataCatalog/src/V1/FieldType/PrimitiveType.php index 66a488a3619c..366690b8eb95 100644 --- a/DataCatalog/src/V1/FieldType/PrimitiveType.php +++ b/DataCatalog/src/V1/FieldType/PrimitiveType.php @@ -78,6 +78,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(PrimitiveType::class, \Google\Cloud\DataCatalog\V1\FieldType_PrimitiveType::class); diff --git a/DataCatalog/src/V1/FieldType_EnumType.php b/DataCatalog/src/V1/FieldType_EnumType.php deleted file mode 100644 index fa2e85752f81..000000000000 --- a/DataCatalog/src/V1/FieldType_EnumType.php +++ /dev/null @@ -1,16 +0,0 @@ -.google.cloud.datacatalog.v1.DataplexFilesetSpec dataplex_fileset = 1; */ - private $dataplex_fileset = null; + protected $dataplex_fileset = null; /** * Constructor. diff --git a/DataCatalog/src/V1/Gapic/DataCatalogGapicClient.php b/DataCatalog/src/V1/Gapic/DataCatalogGapicClient.php deleted file mode 100644 index 29d5760a070e..000000000000 --- a/DataCatalog/src/V1/Gapic/DataCatalogGapicClient.php +++ /dev/null @@ -1,2632 +0,0 @@ -entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - * $entryId = 'entry_id'; - * $entry = new Entry(); - * $response = $dataCatalogClient->createEntry($formattedParent, $entryId, $entry); - * } finally { - * $dataCatalogClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\DataCatalog\V1\Client\DataCatalogClient}. - */ -class DataCatalogGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.datacatalog.v1.DataCatalog'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'datacatalog.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'datacatalog.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $entryNameTemplate; - - private static $entryGroupNameTemplate; - - private static $locationNameTemplate; - - private static $tagNameTemplate; - - private static $tagTemplateNameTemplate; - - private static $tagTemplateFieldNameTemplate; - - private static $tagTemplateFieldEnumValueNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getEntryNameTemplate() - { - if (self::$entryNameTemplate == null) { - self::$entryNameTemplate = new PathTemplate('projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}'); - } - - return self::$entryNameTemplate; - } - - private static function getEntryGroupNameTemplate() - { - if (self::$entryGroupNameTemplate == null) { - self::$entryGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/entryGroups/{entry_group}'); - } - - return self::$entryGroupNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getTagNameTemplate() - { - if (self::$tagNameTemplate == null) { - self::$tagNameTemplate = new PathTemplate('projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}/tags/{tag}'); - } - - return self::$tagNameTemplate; - } - - private static function getTagTemplateNameTemplate() - { - if (self::$tagTemplateNameTemplate == null) { - self::$tagTemplateNameTemplate = new PathTemplate('projects/{project}/locations/{location}/tagTemplates/{tag_template}'); - } - - return self::$tagTemplateNameTemplate; - } - - private static function getTagTemplateFieldNameTemplate() - { - if (self::$tagTemplateFieldNameTemplate == null) { - self::$tagTemplateFieldNameTemplate = new PathTemplate('projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{field}'); - } - - return self::$tagTemplateFieldNameTemplate; - } - - private static function getTagTemplateFieldEnumValueNameTemplate() - { - if (self::$tagTemplateFieldEnumValueNameTemplate == null) { - self::$tagTemplateFieldEnumValueNameTemplate = new PathTemplate('projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{tag_template_field_id}/enumValues/{enum_value_display_name}'); - } - - return self::$tagTemplateFieldEnumValueNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'entry' => self::getEntryNameTemplate(), - 'entryGroup' => self::getEntryGroupNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'tag' => self::getTagNameTemplate(), - 'tagTemplate' => self::getTagTemplateNameTemplate(), - 'tagTemplateField' => self::getTagTemplateFieldNameTemplate(), - 'tagTemplateFieldEnumValue' => self::getTagTemplateFieldEnumValueNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location, $entryGroup, $entry) - { - return self::getEntryNameTemplate()->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($project, $location, $entryGroup) - { - return self::getEntryGroupNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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($project, $location, $entryGroup, $entry, $tag) - { - return self::getTagNameTemplate()->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($project, $location, $tagTemplate) - { - return self::getTagTemplateNameTemplate()->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($project, $location, $tagTemplate, $field) - { - return self::getTagTemplateFieldNameTemplate()->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($project, $location, $tagTemplate, $tagTemplateFieldId, $enumValueDisplayName) - { - return self::getTagTemplateFieldEnumValueNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * 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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - * $entryId = 'entry_id'; - * $entry = new Entry(); - * $response = $dataCatalogClient->createEntry($formattedParent, $entryId, $entry); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the entry group this entry belongs to. - * - * Note: The entry itself and its child resources might not be stored in - * the location specified in its name. - * @param string $entryId Required. The ID of the entry to create. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), - * and underscores (_). - * The maximum size is 64 bytes when encoded in UTF-8. - * @param Entry $entry Required. The entry to create. - * @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\DataCatalog\V1\Entry - * - * @throws ApiException if the remote call fails - */ - public function createEntry($parent, $entryId, $entry, array $optionalArgs = []) - { - $request = new CreateEntryRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setEntryId($entryId); - $request->setEntry($entry); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateEntry', Entry::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->locationName('[PROJECT]', '[LOCATION]'); - * $entryGroupId = 'entry_group_id'; - * $response = $dataCatalogClient->createEntryGroup($formattedParent, $entryGroupId); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. The names of the project and location that the new entry group - * belongs to. - * - * Note: The entry group itself and its child resources might not be - * stored in the location specified in its name. - * @param string $entryGroupId Required. The ID of the entry group to create. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), - * underscores (_), and must start with a letter or underscore. - * The maximum size is 64 bytes when encoded in UTF-8. - * @param array $optionalArgs { - * Optional. - * - * @type EntryGroup $entryGroup - * The entry group to create. Defaults to empty. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\EntryGroup - * - * @throws ApiException if the remote call fails - */ - public function createEntryGroup($parent, $entryGroupId, array $optionalArgs = []) - { - $request = new CreateEntryGroupRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setEntryGroupId($entryGroupId); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['entryGroup'])) { - $request->setEntryGroup($optionalArgs['entryGroup']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateEntryGroup', EntryGroup::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $tag = new Tag(); - * $response = $dataCatalogClient->createTag($formattedParent, $tag); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the resource to attach this tag to. - * - * Tags can be attached to entries or entry groups. An entry can have up to - * 1000 attached tags. - * - * Note: The tag and its child resources might not be stored in - * the location specified in its name. - * @param Tag $tag Required. The tag to create. - * @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\DataCatalog\V1\Tag - * - * @throws ApiException if the remote call fails - */ - public function createTag($parent, $tag, array $optionalArgs = []) - { - $request = new CreateTagRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTag($tag); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateTag', Tag::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->locationName('[PROJECT]', '[LOCATION]'); - * $tagTemplateId = 'tag_template_id'; - * $tagTemplate = new TagTemplate(); - * $response = $dataCatalogClient->createTagTemplate($formattedParent, $tagTemplateId, $tagTemplate); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the project and the template location - * [region](https://cloud.google.com/data-catalog/docs/concepts/regions). - * @param string $tagTemplateId Required. The ID of the tag template to create. - * - * The ID must contain only lowercase letters (a-z), numbers (0-9), - * or underscores (_), and must start with a letter or underscore. - * The maximum size is 64 bytes when encoded in UTF-8. - * @param TagTemplate $tagTemplate Required. The tag template to create. - * @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\DataCatalog\V1\TagTemplate - * - * @throws ApiException if the remote call fails - */ - public function createTagTemplate($parent, $tagTemplateId, $tagTemplate, array $optionalArgs = []) - { - $request = new CreateTagTemplateRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTagTemplateId($tagTemplateId); - $request->setTagTemplate($tagTemplate); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateTagTemplate', TagTemplate::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - * $tagTemplateFieldId = 'tag_template_field_id'; - * $tagTemplateField = new TagTemplateField(); - * $response = $dataCatalogClient->createTagTemplateField($formattedParent, $tagTemplateFieldId, $tagTemplateField); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the project and the template location - * [region](https://cloud.google.com/data-catalog/docs/concepts/regions). - * @param string $tagTemplateFieldId Required. The ID of the tag template field to create. - * - * Note: Adding a required field to an existing template is *not* allowed. - * - * Field IDs can contain letters (both uppercase and lowercase), numbers - * (0-9), underscores (_) and dashes (-). Field IDs must be at least 1 - * character long and at most 128 characters long. Field IDs must also be - * unique within their template. - * @param TagTemplateField $tagTemplateField Required. The tag template field to create. - * @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\DataCatalog\V1\TagTemplateField - * - * @throws ApiException if the remote call fails - */ - public function createTagTemplateField($parent, $tagTemplateFieldId, $tagTemplateField, array $optionalArgs = []) - { - $request = new CreateTagTemplateFieldRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTagTemplateFieldId($tagTemplateFieldId); - $request->setTagTemplateField($tagTemplateField); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateTagTemplateField', TagTemplateField::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $dataCatalogClient->deleteEntry($formattedName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the entry to delete. - * @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 deleteEntry($name, array $optionalArgs = []) - { - $request = new DeleteEntryRequest(); - $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('DeleteEntry', GPBEmpty::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - * $dataCatalogClient->deleteEntryGroup($formattedName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the entry group to delete. - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * Optional. If true, deletes all entries in the entry group. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 deleteEntryGroup($name, array $optionalArgs = []) - { - $request = new DeleteEntryGroupRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteEntryGroup', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes a tag. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $dataCatalogClient->deleteTag($formattedName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the tag to delete. - * @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 deleteTag($name, array $optionalArgs = []) - { - $request = new DeleteTagRequest(); - $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('DeleteTag', GPBEmpty::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - * $force = false; - * $dataCatalogClient->deleteTagTemplate($formattedName, $force); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the tag template to delete. - * @param bool $force Required. If true, deletes all tags that use this template. - * - * Currently, `true` is the only supported value. - * @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 deleteTagTemplate($name, $force, array $optionalArgs = []) - { - $request = new DeleteTagTemplateRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setForce($force); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteTagTemplate', GPBEmpty::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - * $force = false; - * $dataCatalogClient->deleteTagTemplateField($formattedName, $force); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the tag template field to delete. - * @param bool $force Required. If true, deletes this field from any tags that use it. - * - * Currently, `true` is the only supported value. - * @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 deleteTagTemplateField($name, $force, array $optionalArgs = []) - { - $request = new DeleteTagTemplateFieldRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setForce($force); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteTagTemplateField', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets an entry. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $response = $dataCatalogClient->getEntry($formattedName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the entry to get. - * @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\DataCatalog\V1\Entry - * - * @throws ApiException if the remote call fails - */ - public function getEntry($name, array $optionalArgs = []) - { - $request = new GetEntryRequest(); - $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('GetEntry', Entry::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets an entry group. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - * $response = $dataCatalogClient->getEntryGroup($formattedName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the entry group to get. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $readMask - * The fields to return. If empty or omitted, all fields are returned. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\EntryGroup - * - * @throws ApiException if the remote call fails - */ - public function getEntryGroup($name, array $optionalArgs = []) - { - $request = new GetEntryGroupRequest(); - $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('GetEntryGroup', EntryGroup::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $resource = 'resource'; - * $response = $dataCatalogClient->getIamPolicy($resource); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets a tag template. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - * $response = $dataCatalogClient->getTagTemplate($formattedName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the tag template to get. - * @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\DataCatalog\V1\TagTemplate - * - * @throws ApiException if the remote call fails - */ - public function getTagTemplate($name, array $optionalArgs = []) - { - $request = new GetTagTemplateRequest(); - $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('GetTagTemplate', TagTemplate::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - * $operationResponse = $dataCatalogClient->importEntries($formattedParent); - * $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 = $dataCatalogClient->importEntries($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataCatalogClient->resumeOperation($operationName, 'importEntries'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. Target entry group for ingested entries. - * @param array $optionalArgs { - * Optional. - * - * @type string $gcsBucketPath - * Path to a Cloud Storage bucket that contains a dump ready for ingestion. - * @type string $jobId - * Optional. (Optional) Dataplex task job id, if specified will be used as - * part of ImportEntries LRO ID - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 importEntries($parent, array $optionalArgs = []) - { - $request = new ImportEntriesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['gcsBucketPath'])) { - $request->setGcsBucketPath($optionalArgs['gcsBucketPath']); - } - - if (isset($optionalArgs['jobId'])) { - $request->setJobId($optionalArgs['jobId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ImportEntries', $optionalArgs, $request, $this->getOperationsClient())->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]. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - * // Iterate over pages of elements - * $pagedResponse = $dataCatalogClient->listEntries($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataCatalogClient->listEntries($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the entry group that contains the entries to list. - * - * Can be provided in URL format. - * @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 FieldMask $readMask - * The fields to return for each entry. If empty or omitted, all - * fields are returned. - * - * For example, to return a list of entries with only the `name` field, - * set `read_mask` to only one path with the `name` value. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listEntries($parent, array $optionalArgs = []) - { - $request = new ListEntriesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - 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->getPagedListResponse('ListEntries', $optionalArgs, ListEntriesResponse::class, $request); - } - - /** - * Lists entry groups. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $dataCatalogClient->listEntryGroups($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataCatalogClient->listEntryGroups($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the location that contains the entry groups to list. - * - * Can be provided as a URL. - * @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 listEntryGroups($parent, array $optionalArgs = []) - { - $request = new ListEntryGroupsRequest(); - $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('ListEntryGroups', $optionalArgs, ListEntryGroupsResponse::class, $request); - } - - /** - * Lists tags assigned to an [Entry][google.cloud.datacatalog.v1.Entry]. - * The [columns][google.cloud.datacatalog.v1.Tag.column] in the response are - * lowercased. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * // Iterate over pages of elements - * $pagedResponse = $dataCatalogClient->listTags($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataCatalogClient->listTags($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the Data Catalog resource to list the tags of. - * - * The resource can be an [Entry][google.cloud.datacatalog.v1.Entry] - * or an [EntryGroup][google.cloud.datacatalog.v1.EntryGroup] - * (without `/entries/{entries}` at the end). - * @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 listTags($parent, array $optionalArgs = []) - { - $request = new ListTagsRequest(); - $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('ListTags', $optionalArgs, ListTagsResponse::class, $request); - } - - /** - * Gets an entry by its target resource name. - * - * The resource name comes from the source Google Cloud Platform service. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $response = $dataCatalogClient->lookupEntry(); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $linkedResource - * The full name of the Google Cloud Platform resource the Data Catalog - * entry represents. For more information, see [Full Resource Name] - * (https://cloud.google.com/apis/design/resource_names#full_resource_name). - * - * Full names are case-sensitive. For example: - * - * * `//bigquery.googleapis.com/projects/{PROJECT_ID}/datasets/{DATASET_ID}/tables/{TABLE_ID}` - * * `//pubsub.googleapis.com/projects/{PROJECT_ID}/topics/{TOPIC_ID}` - * @type string $sqlResource - * The SQL name of the entry. SQL names are case-sensitive. - * - * Examples: - * - * * `pubsub.topic.{PROJECT_ID}.{TOPIC_ID}` - * * `pubsub.topic.{PROJECT_ID}.`\``{TOPIC.ID.SEPARATED.WITH.DOTS}`\` - * * `bigquery.table.{PROJECT_ID}.{DATASET_ID}.{TABLE_ID}` - * * `bigquery.dataset.{PROJECT_ID}.{DATASET_ID}` - * * `datacatalog.entry.{PROJECT_ID}.{LOCATION_ID}.{ENTRY_GROUP_ID}.{ENTRY_ID}` - * - * Identifiers (`*_ID`) should comply with the - * [Lexical structure in Standard SQL] - * (https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical). - * @type string $fullyQualifiedName - * [Fully Qualified Name - * (FQN)](https://cloud.google.com//data-catalog/docs/fully-qualified-names) - * of the resource. - * - * FQNs take two forms: - * - * * For non-regionalized resources: - * - * `{SYSTEM}:{PROJECT}.{PATH_TO_RESOURCE_SEPARATED_WITH_DOTS}` - * - * * For regionalized resources: - * - * `{SYSTEM}:{PROJECT}.{LOCATION_ID}.{PATH_TO_RESOURCE_SEPARATED_WITH_DOTS}` - * - * Example for a DPMS table: - * - * `dataproc_metastore:{PROJECT_ID}.{LOCATION_ID}.{INSTANCE_ID}.{DATABASE_ID}.{TABLE_ID}` - * @type string $project - * Project where the lookup should be performed. Required to lookup - * entry that is not a part of `DPMS` or `DATAPLEX` `integrated_system` - * using its `fully_qualified_name`. Ignored in other cases. - * @type string $location - * Location where the lookup should be performed. Required to lookup - * entry that is not a part of `DPMS` or `DATAPLEX` `integrated_system` - * using its `fully_qualified_name`. Ignored in other cases. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\Entry - * - * @throws ApiException if the remote call fails - */ - public function lookupEntry(array $optionalArgs = []) - { - $request = new LookupEntryRequest(); - if (isset($optionalArgs['linkedResource'])) { - $request->setLinkedResource($optionalArgs['linkedResource']); - } - - if (isset($optionalArgs['sqlResource'])) { - $request->setSqlResource($optionalArgs['sqlResource']); - } - - if (isset($optionalArgs['fullyQualifiedName'])) { - $request->setFullyQualifiedName($optionalArgs['fullyQualifiedName']); - } - - if (isset($optionalArgs['project'])) { - $request->setProject($optionalArgs['project']); - } - - if (isset($optionalArgs['location'])) { - $request->setLocation($optionalArgs['location']); - } - - return $this->startCall('LookupEntry', Entry::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $contacts = new Contacts(); - * $response = $dataCatalogClient->modifyEntryContacts($formattedName, $contacts); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The full resource name of the entry. - * @param Contacts $contacts Required. The new value for the Contacts. - * @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\DataCatalog\V1\Contacts - * - * @throws ApiException if the remote call fails - */ - public function modifyEntryContacts($name, $contacts, array $optionalArgs = []) - { - $request = new ModifyEntryContactsRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setContacts($contacts); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ModifyEntryContacts', Contacts::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $entryOverview = new EntryOverview(); - * $response = $dataCatalogClient->modifyEntryOverview($formattedName, $entryOverview); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The full resource name of the entry. - * @param EntryOverview $entryOverview Required. The new value for the Entry Overview. - * @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\DataCatalog\V1\EntryOverview - * - * @throws ApiException if the remote call fails - */ - public function modifyEntryOverview($name, $entryOverview, array $optionalArgs = []) - { - $request = new ModifyEntryOverviewRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setEntryOverview($entryOverview); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ModifyEntryOverview', EntryOverview::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedParent = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $formattedTagTemplate = $dataCatalogClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - * $operationResponse = $dataCatalogClient->reconcileTags($formattedParent, $formattedTagTemplate); - * $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 = $dataCatalogClient->reconcileTags($formattedParent, $formattedTagTemplate); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataCatalogClient->resumeOperation($operationName, 'reconcileTags'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $parent Required. Name of [Entry][google.cloud.datacatalog.v1.Entry] to be tagged. - * @param string $tagTemplate Required. The name of the tag template, which is used for reconciliation. - * @param array $optionalArgs { - * Optional. - * - * @type bool $forceDeleteMissing - * If set to `true`, deletes entry tags related to a tag template - * not listed in the tags source from an entry. If set to `false`, - * unlisted tags are retained. - * @type Tag[] $tags - * A list of tags to apply to an entry. A tag can specify a - * tag template, which must be the template specified in the - * `ReconcileTagsRequest`. - * The sole entry and each of its columns must be mentioned at most once. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 reconcileTags($parent, $tagTemplate, array $optionalArgs = []) - { - $request = new ReconcileTagsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTagTemplate($tagTemplate); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['forceDeleteMissing'])) { - $request->setForceDeleteMissing($optionalArgs['forceDeleteMissing']); - } - - if (isset($optionalArgs['tags'])) { - $request->setTags($optionalArgs['tags']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ReconcileTags', $optionalArgs, $request, $this->getOperationsClient())->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - * $newTagTemplateFieldId = 'new_tag_template_field_id'; - * $response = $dataCatalogClient->renameTagTemplateField($formattedName, $newTagTemplateFieldId); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the tag template field. - * @param string $newTagTemplateFieldId Required. The new ID of this tag template field. For example, - * `my_new_field`. - * @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\DataCatalog\V1\TagTemplateField - * - * @throws ApiException if the remote call fails - */ - public function renameTagTemplateField($name, $newTagTemplateFieldId, array $optionalArgs = []) - { - $request = new RenameTagTemplateFieldRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setNewTagTemplateFieldId($newTagTemplateFieldId); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('RenameTagTemplateField', TagTemplateField::class, $optionalArgs, $request)->wait(); - } - - /** - * Renames an enum value in a tag template. - * - * Within a single enum field, enum values must be unique. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->tagTemplateFieldEnumValueName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[TAG_TEMPLATE_FIELD_ID]', '[ENUM_VALUE_DISPLAY_NAME]'); - * $newEnumValueDisplayName = 'new_enum_value_display_name'; - * $response = $dataCatalogClient->renameTagTemplateFieldEnumValue($formattedName, $newEnumValueDisplayName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the enum field value. - * @param string $newEnumValueDisplayName Required. The new display name of the enum value. For example, - * `my_new_enum_value`. - * @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\DataCatalog\V1\TagTemplateField - * - * @throws ApiException if the remote call fails - */ - public function renameTagTemplateFieldEnumValue($name, $newEnumValueDisplayName, array $optionalArgs = []) - { - $request = new RenameTagTemplateFieldEnumValueRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setNewEnumValueDisplayName($newEnumValueDisplayName); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('RenameTagTemplateFieldEnumValue', TagTemplateField::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $scope = new Scope(); - * $query = 'query'; - * // Iterate over pages of elements - * $pagedResponse = $dataCatalogClient->searchCatalog($scope, $query); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataCatalogClient->searchCatalog($scope, $query); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param Scope $scope Required. The scope of this search request. - * - * The `scope` is invalid if `include_org_ids`, `include_project_ids` are - * empty AND `include_gcp_public_datasets` is set to `false`. In this case, - * the request returns an error. - * @param string $query Optional. The query string with a minimum of 3 characters and specific - * syntax. For more information, see [Data Catalog search - * syntax](https://cloud.google.com/data-catalog/docs/how-to/search-reference). - * - * An empty query string returns all data assets (in the specified scope) - * that you have access to. - * - * A query string can be a simple `xyz` or qualified by predicates: - * - * * `name:x` - * * `column:y` - * * `description:z` - * @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 string $orderBy - * Specifies the order of results. - * - * Currently supported case-sensitive values are: - * - * * `relevance` that can only be descending - * * `last_modified_timestamp [asc|desc]` with descending (`desc`) as default - * * `default` that can only be descending - * - * 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. - * If you are experiencing recall issues and you don't have to fetch the - * results in any specific order, consider setting this parameter to - * `default`. - * - * If this parameter is omitted, it defaults to the descending `relevance`. - * @type bool $adminSearch - * Optional. If set, use searchAll permission granted on organizations from - * `include_org_ids` and projects from `include_project_ids` instead of the - * fine grained per resource permissions when filtering the search results. - * The only allowed `order_by` criteria for admin_search mode is `default`. - * Using this flags guarantees a full recall of the search results. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 searchCatalog($scope, $query, array $optionalArgs = []) - { - $request = new SearchCatalogRequest(); - $request->setScope($scope); - $request->setQuery($query); - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - - if (isset($optionalArgs['adminSearch'])) { - $request->setAdminSearch($optionalArgs['adminSearch']); - } - - return $this->getPagedListResponse('SearchCatalog', $optionalArgs, SearchCatalogResponse::class, $request); - } - - /** - * 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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $dataCatalogClient->setIamPolicy($resource, $policy); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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('SetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); - } - - /** - * Marks an [Entry][google.cloud.datacatalog.v1.Entry] as starred by - * the current user. Starring information is private to each user. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $response = $dataCatalogClient->starEntry($formattedName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the entry to mark as starred. - * @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\DataCatalog\V1\StarEntryResponse - * - * @throws ApiException if the remote call fails - */ - public function starEntry($name, array $optionalArgs = []) - { - $request = new StarEntryRequest(); - $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('StarEntry', StarEntryResponse::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $dataCatalogClient->testIamPermissions($resource, $permissions); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions($resource, $permissions, array $optionalArgs = []) - { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Marks an [Entry][google.cloud.datacatalog.v1.Entry] as NOT starred by - * the current user. Starring information is private to each user. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - * $response = $dataCatalogClient->unstarEntry($formattedName); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the entry to mark as **not** starred. - * @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\DataCatalog\V1\UnstarEntryResponse - * - * @throws ApiException if the remote call fails - */ - public function unstarEntry($name, array $optionalArgs = []) - { - $request = new UnstarEntryRequest(); - $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('UnstarEntry', UnstarEntryResponse::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $entry = new Entry(); - * $response = $dataCatalogClient->updateEntry($entry); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param Entry $entry Required. Updates for the entry. The `name` field must be set. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Names of fields whose values to overwrite on an entry. - * - * If this parameter is absent or empty, all modifiable fields - * are overwritten. If such fields are non-required and omitted in the - * request body, their values are emptied. - * - * You can modify only the fields listed below. - * - * For entries with type `DATA_STREAM`: - * - * * `schema` - * - * For entries with type `FILESET`: - * - * * `schema` - * * `display_name` - * * `description` - * * `gcs_fileset_spec` - * * `gcs_fileset_spec.file_patterns` - * - * For entries with `user_specified_type`: - * - * * `schema` - * * `display_name` - * * `description` - * * `user_specified_type` - * * `user_specified_system` - * * `linked_resource` - * * `source_system_timestamps` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\Entry - * - * @throws ApiException if the remote call fails - */ - public function updateEntry($entry, array $optionalArgs = []) - { - $request = new UpdateEntryRequest(); - $requestParamHeaders = []; - $request->setEntry($entry); - $requestParamHeaders['entry.name'] = $entry->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('UpdateEntry', Entry::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $entryGroup = new EntryGroup(); - * $response = $dataCatalogClient->updateEntryGroup($entryGroup); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param EntryGroup $entryGroup Required. Updates for the entry group. The `name` field must be set. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Names of fields whose values to overwrite on an entry group. - * - * If this parameter is absent or empty, all modifiable fields - * are overwritten. If such fields are non-required and omitted in the - * request body, their values are emptied. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\EntryGroup - * - * @throws ApiException if the remote call fails - */ - public function updateEntryGroup($entryGroup, array $optionalArgs = []) - { - $request = new UpdateEntryGroupRequest(); - $requestParamHeaders = []; - $request->setEntryGroup($entryGroup); - $requestParamHeaders['entry_group.name'] = $entryGroup->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('UpdateEntryGroup', EntryGroup::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates an existing tag. - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $tag = new Tag(); - * $response = $dataCatalogClient->updateTag($tag); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param Tag $tag Required. The updated tag. The "name" field must be set. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Names of fields whose values to overwrite on a tag. Currently, a tag has - * the only modifiable field with the name `fields`. - * - * In general, if this parameter is absent or empty, all modifiable fields - * are overwritten. If such fields are non-required and omitted in the - * request body, their values are emptied. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\Tag - * - * @throws ApiException if the remote call fails - */ - public function updateTag($tag, array $optionalArgs = []) - { - $request = new UpdateTagRequest(); - $requestParamHeaders = []; - $request->setTag($tag); - $requestParamHeaders['tag.name'] = $tag->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('UpdateTag', Tag::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $tagTemplate = new TagTemplate(); - * $response = $dataCatalogClient->updateTagTemplate($tagTemplate); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param TagTemplate $tagTemplate Required. The template to update. The `name` field must be set. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Names of fields whose values to overwrite on a tag template. Currently, - * only `display_name` and `is_publicly_readable` can be overwritten. - * - * If this parameter is absent or empty, all modifiable fields - * are overwritten. If such fields are non-required and omitted in the - * request body, their values are emptied. - * - * Note: Updating the `is_publicly_readable` field may require up to 12 - * hours to take effect in search results. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\TagTemplate - * - * @throws ApiException if the remote call fails - */ - public function updateTagTemplate($tagTemplate, array $optionalArgs = []) - { - $request = new UpdateTagTemplateRequest(); - $requestParamHeaders = []; - $request->setTagTemplate($tagTemplate); - $requestParamHeaders['tag_template.name'] = $tagTemplate->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('UpdateTagTemplate', TagTemplate::class, $optionalArgs, $request)->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). - * - * Sample code: - * ``` - * $dataCatalogClient = new DataCatalogClient(); - * try { - * $formattedName = $dataCatalogClient->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - * $tagTemplateField = new TagTemplateField(); - * $response = $dataCatalogClient->updateTagTemplateField($formattedName, $tagTemplateField); - * } finally { - * $dataCatalogClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the tag template field. - * @param TagTemplateField $tagTemplateField Required. The template to update. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Optional. Names of fields whose values to overwrite on an individual field - * of a tag template. The following fields are modifiable: - * - * * `display_name` - * * `type.enum_type` - * * `is_required` - * - * If this parameter is absent or empty, all modifiable fields - * are overwritten. If such fields are non-required and omitted in the request - * body, their values are emptied with one exception: when updating an enum - * type, the provided values are merged with the existing values. Therefore, - * enum values can only be added, existing enum values cannot be deleted or - * renamed. - * - * Additionally, updating a template field from optional to required is - * *not* allowed. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\TagTemplateField - * - * @throws ApiException if the remote call fails - */ - public function updateTagTemplateField($name, $tagTemplateField, array $optionalArgs = []) - { - $request = new UpdateTagTemplateFieldRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTagTemplateField($tagTemplateField); - $requestParamHeaders['name'] = $name; - 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('UpdateTagTemplateField', TagTemplateField::class, $optionalArgs, $request)->wait(); - } -} diff --git a/DataCatalog/src/V1/Gapic/PolicyTagManagerGapicClient.php b/DataCatalog/src/V1/Gapic/PolicyTagManagerGapicClient.php deleted file mode 100644 index 0d586f71098a..000000000000 --- a/DataCatalog/src/V1/Gapic/PolicyTagManagerGapicClient.php +++ /dev/null @@ -1,997 +0,0 @@ -taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - * $response = $policyTagManagerClient->createPolicyTag($formattedParent); - * } finally { - * $policyTagManagerClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\DataCatalog\V1\Client\PolicyTagManagerClient}. - */ -class PolicyTagManagerGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.datacatalog.v1.PolicyTagManager'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'datacatalog.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'datacatalog.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $locationNameTemplate; - - private static $policyTagNameTemplate; - - private static $taxonomyNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getPolicyTagNameTemplate() - { - if (self::$policyTagNameTemplate == null) { - self::$policyTagNameTemplate = new PathTemplate('projects/{project}/locations/{location}/taxonomies/{taxonomy}/policyTags/{policy_tag}'); - } - - return self::$policyTagNameTemplate; - } - - private static function getTaxonomyNameTemplate() - { - if (self::$taxonomyNameTemplate == null) { - self::$taxonomyNameTemplate = new PathTemplate('projects/{project}/locations/{location}/taxonomies/{taxonomy}'); - } - - return self::$taxonomyNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'location' => self::getLocationNameTemplate(), - 'policyTag' => self::getPolicyTagNameTemplate(), - 'taxonomy' => self::getTaxonomyNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location) - { - return self::getLocationNameTemplate()->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($project, $location, $taxonomy, $policyTag) - { - return self::getPolicyTagNameTemplate()->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($project, $location, $taxonomy) - { - return self::getTaxonomyNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * Creates a policy tag in a taxonomy. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $formattedParent = $policyTagManagerClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - * $response = $policyTagManagerClient->createPolicyTag($formattedParent); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. Resource name of the taxonomy that the policy tag will belong to. - * @param array $optionalArgs { - * Optional. - * - * @type PolicyTag $policyTag - * The policy tag to create. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\PolicyTag - * - * @throws ApiException if the remote call fails - */ - public function createPolicyTag($parent, array $optionalArgs = []) - { - $request = new CreatePolicyTagRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['policyTag'])) { - $request->setPolicyTag($optionalArgs['policyTag']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreatePolicyTag', PolicyTag::class, $optionalArgs, $request)->wait(); - } - - /** - * Creates a taxonomy in a specified project. - * - * The taxonomy is initially empty, that is, it doesn't contain policy tags. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $formattedParent = $policyTagManagerClient->locationName('[PROJECT]', '[LOCATION]'); - * $response = $policyTagManagerClient->createTaxonomy($formattedParent); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. Resource name of the project that the taxonomy will belong to. - * @param array $optionalArgs { - * Optional. - * - * @type Taxonomy $taxonomy - * The taxonomy to create. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\Taxonomy - * - * @throws ApiException if the remote call fails - */ - public function createTaxonomy($parent, array $optionalArgs = []) - { - $request = new CreateTaxonomyRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['taxonomy'])) { - $request->setTaxonomy($optionalArgs['taxonomy']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateTaxonomy', Taxonomy::class, $optionalArgs, $request)->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 - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $formattedName = $policyTagManagerClient->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - * $policyTagManagerClient->deletePolicyTag($formattedName); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the policy tag to delete. - * - * Note: All of its descendant policy tags are also deleted. - * @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 deletePolicyTag($name, array $optionalArgs = []) - { - $request = new DeletePolicyTagRequest(); - $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('DeletePolicyTag', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes a taxonomy, including all policy tags in this - * taxonomy, their associated policies, and the policy tags references from - * BigQuery columns. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $formattedName = $policyTagManagerClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - * $policyTagManagerClient->deleteTaxonomy($formattedName); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the taxonomy to delete. - * - * Note: All policy tags in this taxonomy are also deleted. - * @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 deleteTaxonomy($name, array $optionalArgs = []) - { - $request = new DeleteTaxonomyRequest(); - $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('DeleteTaxonomy', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the IAM policy for a policy tag or a taxonomy. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $resource = 'resource'; - * $response = $policyTagManagerClient->getIamPolicy($resource); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets a policy tag. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $formattedName = $policyTagManagerClient->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - * $response = $policyTagManagerClient->getPolicyTag($formattedName); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the policy tag. - * @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\DataCatalog\V1\PolicyTag - * - * @throws ApiException if the remote call fails - */ - public function getPolicyTag($name, array $optionalArgs = []) - { - $request = new GetPolicyTagRequest(); - $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('GetPolicyTag', PolicyTag::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets a taxonomy. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $formattedName = $policyTagManagerClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - * $response = $policyTagManagerClient->getTaxonomy($formattedName); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the taxonomy to get. - * @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\DataCatalog\V1\Taxonomy - * - * @throws ApiException if the remote call fails - */ - public function getTaxonomy($name, array $optionalArgs = []) - { - $request = new GetTaxonomyRequest(); - $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('GetTaxonomy', Taxonomy::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists all policy tags in a taxonomy. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $formattedParent = $policyTagManagerClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - * // Iterate over pages of elements - * $pagedResponse = $policyTagManagerClient->listPolicyTags($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $policyTagManagerClient->listPolicyTags($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. Resource name of the taxonomy to list the policy tags of. - * @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 listPolicyTags($parent, array $optionalArgs = []) - { - $request = new ListPolicyTagsRequest(); - $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('ListPolicyTags', $optionalArgs, ListPolicyTagsResponse::class, $request); - } - - /** - * Lists all taxonomies in a project in a particular location that you - * have a permission to view. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $formattedParent = $policyTagManagerClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $policyTagManagerClient->listTaxonomies($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $policyTagManagerClient->listTaxonomies($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. Resource name of the project to list the taxonomies of. - * @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 string $filter - * Supported field for filter is 'service' and value is 'dataplex'. - * Eg: service=dataplex. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listTaxonomies($parent, array $optionalArgs = []) - { - $request = new ListTaxonomiesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListTaxonomies', $optionalArgs, ListTaxonomiesResponse::class, $request); - } - - /** - * Sets the IAM policy for a policy tag or a taxonomy. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $policyTagManagerClient->setIamPolicy($resource, $policy); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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('SetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns your permissions on a specified policy tag or - * taxonomy. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $policyTagManagerClient->testIamPermissions($resource, $permissions); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions($resource, $permissions, array $optionalArgs = []) - { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates a policy tag, including its display - * name, description, and parent policy tag. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $response = $policyTagManagerClient->updatePolicyTag(); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type PolicyTag $policyTag - * The policy tag to update. You can update only its description, display - * name, and parent policy tag fields. - * @type FieldMask $updateMask - * Specifies the fields to update. - * - * You can update only display name, description, and parent policy tag. - * If not set, defaults to all updatable fields. - * For more information, see [FieldMask] - * (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\PolicyTag - * - * @throws ApiException if the remote call fails - */ - public function updatePolicyTag(array $optionalArgs = []) - { - $request = new UpdatePolicyTagRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['policyTag'])) { - $request->setPolicyTag($optionalArgs['policyTag']); - } - - 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('UpdatePolicyTag', PolicyTag::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates a taxonomy, including its display name, - * description, and activated policy types. - * - * Sample code: - * ``` - * $policyTagManagerClient = new PolicyTagManagerClient(); - * try { - * $response = $policyTagManagerClient->updateTaxonomy(); - * } finally { - * $policyTagManagerClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type Taxonomy $taxonomy - * The taxonomy to update. You can update only its description, display name, - * and activated policy types. - * @type FieldMask $updateMask - * Specifies fields to update. If not set, defaults to all fields you can - * update. - * - * For more information, see [FieldMask] - * (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\Taxonomy - * - * @throws ApiException if the remote call fails - */ - public function updateTaxonomy(array $optionalArgs = []) - { - $request = new UpdateTaxonomyRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['taxonomy'])) { - $request->setTaxonomy($optionalArgs['taxonomy']); - } - - 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('UpdateTaxonomy', Taxonomy::class, $optionalArgs, $request)->wait(); - } -} diff --git a/DataCatalog/src/V1/Gapic/PolicyTagManagerSerializationGapicClient.php b/DataCatalog/src/V1/Gapic/PolicyTagManagerSerializationGapicClient.php deleted file mode 100644 index a5aac46ddebe..000000000000 --- a/DataCatalog/src/V1/Gapic/PolicyTagManagerSerializationGapicClient.php +++ /dev/null @@ -1,465 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $formattedTaxonomies = [ - * $policyTagManagerSerializationClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'), - * ]; - * $response = $policyTagManagerSerializationClient->exportTaxonomies($formattedParent, $formattedTaxonomies); - * } finally { - * $policyTagManagerSerializationClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\DataCatalog\V1\Client\PolicyTagManagerSerializationClient}. - */ -class PolicyTagManagerSerializationGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.datacatalog.v1.PolicyTagManagerSerialization'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'datacatalog.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'datacatalog.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $locationNameTemplate; - - private static $taxonomyNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getTaxonomyNameTemplate() - { - if (self::$taxonomyNameTemplate == null) { - self::$taxonomyNameTemplate = new PathTemplate('projects/{project}/locations/{location}/taxonomies/{taxonomy}'); - } - - return self::$taxonomyNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'location' => self::getLocationNameTemplate(), - 'taxonomy' => self::getTaxonomyNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location) - { - return self::getLocationNameTemplate()->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($project, $location, $taxonomy) - { - return self::getTaxonomyNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * 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. - * - * Sample code: - * ``` - * $policyTagManagerSerializationClient = new PolicyTagManagerSerializationClient(); - * try { - * $formattedParent = $policyTagManagerSerializationClient->locationName('[PROJECT]', '[LOCATION]'); - * $formattedTaxonomies = [ - * $policyTagManagerSerializationClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'), - * ]; - * $response = $policyTagManagerSerializationClient->exportTaxonomies($formattedParent, $formattedTaxonomies); - * } finally { - * $policyTagManagerSerializationClient->close(); - * } - * ``` - * - * @param string $parent Required. Resource name of the project that the exported taxonomies belong - * to. - * @param string[] $taxonomies Required. Resource names of the taxonomies to export. - * @param array $optionalArgs { - * Optional. - * - * @type bool $serializedTaxonomies - * Serialized export taxonomies that contain all the policy - * tags as nested protocol buffers. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\ExportTaxonomiesResponse - * - * @throws ApiException if the remote call fails - */ - public function exportTaxonomies($parent, $taxonomies, array $optionalArgs = []) - { - $request = new ExportTaxonomiesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTaxonomies($taxonomies); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['serializedTaxonomies'])) { - $request->setSerializedTaxonomies($optionalArgs['serializedTaxonomies']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ExportTaxonomies', ExportTaxonomiesResponse::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $policyTagManagerSerializationClient = new PolicyTagManagerSerializationClient(); - * try { - * $formattedParent = $policyTagManagerSerializationClient->locationName('[PROJECT]', '[LOCATION]'); - * $response = $policyTagManagerSerializationClient->importTaxonomies($formattedParent); - * } finally { - * $policyTagManagerSerializationClient->close(); - * } - * ``` - * - * @param string $parent Required. Resource name of project that the imported taxonomies will belong - * to. - * @param array $optionalArgs { - * Optional. - * - * @type InlineSource $inlineSource - * Inline source taxonomy to import. - * @type CrossRegionalSource $crossRegionalSource - * Cross-regional source taxonomy to import. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\DataCatalog\V1\ImportTaxonomiesResponse - * - * @throws ApiException if the remote call fails - */ - public function importTaxonomies($parent, array $optionalArgs = []) - { - $request = new ImportTaxonomiesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['inlineSource'])) { - $request->setInlineSource($optionalArgs['inlineSource']); - } - - if (isset($optionalArgs['crossRegionalSource'])) { - $request->setCrossRegionalSource($optionalArgs['crossRegionalSource']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ImportTaxonomies', ImportTaxonomiesResponse::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $policyTagManagerSerializationClient = new PolicyTagManagerSerializationClient(); - * try { - * $formattedName = $policyTagManagerSerializationClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - * $serializedTaxonomy = new SerializedTaxonomy(); - * $response = $policyTagManagerSerializationClient->replaceTaxonomy($formattedName, $serializedTaxonomy); - * } finally { - * $policyTagManagerSerializationClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the taxonomy to update. - * @param SerializedTaxonomy $serializedTaxonomy Required. Taxonomy to update along with its child policy tags. - * @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\DataCatalog\V1\Taxonomy - * - * @throws ApiException if the remote call fails - */ - public function replaceTaxonomy($name, $serializedTaxonomy, array $optionalArgs = []) - { - $request = new ReplaceTaxonomyRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setSerializedTaxonomy($serializedTaxonomy); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ReplaceTaxonomy', Taxonomy::class, $optionalArgs, $request)->wait(); - } -} diff --git a/DataCatalog/src/V1/GcsFileSpec.php b/DataCatalog/src/V1/GcsFileSpec.php index 00c6e1810c32..1d7a9dc320c3 100644 --- a/DataCatalog/src/V1/GcsFileSpec.php +++ b/DataCatalog/src/V1/GcsFileSpec.php @@ -20,20 +20,20 @@ class GcsFileSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string file_path = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $file_path = ''; + protected $file_path = ''; /** * Output only. Creation, modification, and expiration timestamps of a Cloud * Storage file. * * Generated from protobuf field .google.cloud.datacatalog.v1.SystemTimestamps gcs_timestamps = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $gcs_timestamps = null; + protected $gcs_timestamps = null; /** * Output only. File size in bytes. * * Generated from protobuf field int64 size_bytes = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $size_bytes = 0; + protected $size_bytes = 0; /** * Constructor. diff --git a/DataCatalog/src/V1/GetEntryGroupRequest.php b/DataCatalog/src/V1/GetEntryGroupRequest.php index c8458ffd6f29..76b61e38e9bd 100644 --- a/DataCatalog/src/V1/GetEntryGroupRequest.php +++ b/DataCatalog/src/V1/GetEntryGroupRequest.php @@ -21,13 +21,13 @@ class GetEntryGroupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * The fields to return. If empty or omitted, all fields are returned. * * Generated from protobuf field .google.protobuf.FieldMask read_mask = 2; */ - private $read_mask = null; + protected $read_mask = null; /** * @param string $name Required. The name of the entry group to get. Please see diff --git a/DataCatalog/src/V1/GetEntryRequest.php b/DataCatalog/src/V1/GetEntryRequest.php index b59b2d514a44..d75c330de5f0 100644 --- a/DataCatalog/src/V1/GetEntryRequest.php +++ b/DataCatalog/src/V1/GetEntryRequest.php @@ -21,7 +21,7 @@ class GetEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the entry to get. Please see diff --git a/DataCatalog/src/V1/GetPolicyTagRequest.php b/DataCatalog/src/V1/GetPolicyTagRequest.php index 33dae0524dfd..69deebd11459 100644 --- a/DataCatalog/src/V1/GetPolicyTagRequest.php +++ b/DataCatalog/src/V1/GetPolicyTagRequest.php @@ -21,7 +21,7 @@ class GetPolicyTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Resource name of the policy tag. Please see diff --git a/DataCatalog/src/V1/GetTagTemplateRequest.php b/DataCatalog/src/V1/GetTagTemplateRequest.php index 624220b79024..2abfb6facd24 100644 --- a/DataCatalog/src/V1/GetTagTemplateRequest.php +++ b/DataCatalog/src/V1/GetTagTemplateRequest.php @@ -21,7 +21,7 @@ class GetTagTemplateRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the tag template to get. Please see diff --git a/DataCatalog/src/V1/GetTaxonomyRequest.php b/DataCatalog/src/V1/GetTaxonomyRequest.php index 16d65e4e89cd..6efa888ac7b1 100644 --- a/DataCatalog/src/V1/GetTaxonomyRequest.php +++ b/DataCatalog/src/V1/GetTaxonomyRequest.php @@ -21,7 +21,7 @@ class GetTaxonomyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Resource name of the taxonomy to get. Please see diff --git a/DataCatalog/src/V1/ImportEntriesMetadata.php b/DataCatalog/src/V1/ImportEntriesMetadata.php index 1cc567bf3a56..d5afa31cf075 100644 --- a/DataCatalog/src/V1/ImportEntriesMetadata.php +++ b/DataCatalog/src/V1/ImportEntriesMetadata.php @@ -22,7 +22,7 @@ class ImportEntriesMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.ImportEntriesMetadata.ImportState state = 1; */ - private $state = 0; + protected $state = 0; /** * Partial errors that are encountered during the ImportEntries operation. * There is no guarantee that all the encountered errors are reported. diff --git a/DataCatalog/src/V1/ImportEntriesMetadata/ImportState.php b/DataCatalog/src/V1/ImportEntriesMetadata/ImportState.php index 00f1fae63c91..b52fe951d535 100644 --- a/DataCatalog/src/V1/ImportEntriesMetadata/ImportState.php +++ b/DataCatalog/src/V1/ImportEntriesMetadata/ImportState.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ImportState::class, \Google\Cloud\DataCatalog\V1\ImportEntriesMetadata_ImportState::class); diff --git a/DataCatalog/src/V1/ImportEntriesMetadata_ImportState.php b/DataCatalog/src/V1/ImportEntriesMetadata_ImportState.php deleted file mode 100644 index 152e3adb91c3..000000000000 --- a/DataCatalog/src/V1/ImportEntriesMetadata_ImportState.php +++ /dev/null @@ -1,16 +0,0 @@ -string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. (Optional) Dataplex task job id, if specified will be used as * part of ImportEntries LRO ID * * Generated from protobuf field string job_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $job_id = ''; + protected $job_id = ''; protected $source; /** diff --git a/DataCatalog/src/V1/ImportEntriesResponse.php b/DataCatalog/src/V1/ImportEntriesResponse.php index 60d607301331..01f193e90eef 100644 --- a/DataCatalog/src/V1/ImportEntriesResponse.php +++ b/DataCatalog/src/V1/ImportEntriesResponse.php @@ -23,13 +23,13 @@ class ImportEntriesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional int64 upserted_entries_count = 5; */ - private $upserted_entries_count = null; + protected $upserted_entries_count = null; /** * Number of entries deleted as a result of import operation. * * Generated from protobuf field optional int64 deleted_entries_count = 6; */ - private $deleted_entries_count = null; + protected $deleted_entries_count = null; /** * Constructor. diff --git a/DataCatalog/src/V1/ImportTaxonomiesRequest.php b/DataCatalog/src/V1/ImportTaxonomiesRequest.php index d2934a5416c3..f725b621eb8c 100644 --- a/DataCatalog/src/V1/ImportTaxonomiesRequest.php +++ b/DataCatalog/src/V1/ImportTaxonomiesRequest.php @@ -22,7 +22,7 @@ class ImportTaxonomiesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; protected $source; /** diff --git a/DataCatalog/src/V1/ListEntriesRequest.php b/DataCatalog/src/V1/ListEntriesRequest.php index 7f0c86b32b38..40e55423d130 100644 --- a/DataCatalog/src/V1/ListEntriesRequest.php +++ b/DataCatalog/src/V1/ListEntriesRequest.php @@ -22,21 +22,21 @@ class ListEntriesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return. Default is 10. Maximum limit is * 1000. Throws an invalid argument if `page_size` is more than 1000. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Pagination token that specifies the next page to return. If empty, the * first page is returned. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * The fields to return for each entry. If empty or omitted, all * fields are returned. @@ -45,7 +45,7 @@ class ListEntriesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask read_mask = 4; */ - private $read_mask = null; + protected $read_mask = null; /** * @param string $parent Required. The name of the entry group that contains the entries to list. diff --git a/DataCatalog/src/V1/ListEntriesResponse.php b/DataCatalog/src/V1/ListEntriesResponse.php index fdfe7aa155e7..095ade948b0a 100644 --- a/DataCatalog/src/V1/ListEntriesResponse.php +++ b/DataCatalog/src/V1/ListEntriesResponse.php @@ -28,7 +28,7 @@ class ListEntriesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/ListEntryGroupsRequest.php b/DataCatalog/src/V1/ListEntryGroupsRequest.php index 0840e48859d2..5aeb672daa93 100644 --- a/DataCatalog/src/V1/ListEntryGroupsRequest.php +++ b/DataCatalog/src/V1/ListEntryGroupsRequest.php @@ -22,7 +22,7 @@ class ListEntryGroupsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. The maximum number of items to return. * Default is 10. Maximum limit is 1000. @@ -30,14 +30,14 @@ class ListEntryGroupsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. Pagination token that specifies the next page to return. * If empty, returns the first page. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The name of the location that contains the entry groups to list. diff --git a/DataCatalog/src/V1/ListEntryGroupsResponse.php b/DataCatalog/src/V1/ListEntryGroupsResponse.php index 65365d1ca610..01ce90d13e57 100644 --- a/DataCatalog/src/V1/ListEntryGroupsResponse.php +++ b/DataCatalog/src/V1/ListEntryGroupsResponse.php @@ -28,7 +28,7 @@ class ListEntryGroupsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/ListPolicyTagsRequest.php b/DataCatalog/src/V1/ListPolicyTagsRequest.php index c336e115e5a6..0f1f7cbcfd82 100644 --- a/DataCatalog/src/V1/ListPolicyTagsRequest.php +++ b/DataCatalog/src/V1/ListPolicyTagsRequest.php @@ -21,7 +21,7 @@ class ListPolicyTagsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return. Must be a value between 1 and 1000 * inclusively. @@ -29,7 +29,7 @@ class ListPolicyTagsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The pagination token of the next results page. If not set, returns the * first page. @@ -37,7 +37,7 @@ class ListPolicyTagsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Resource name of the taxonomy to list the policy tags of. Please see diff --git a/DataCatalog/src/V1/ListPolicyTagsResponse.php b/DataCatalog/src/V1/ListPolicyTagsResponse.php index 06eb91e03af6..71ccac60ef68 100644 --- a/DataCatalog/src/V1/ListPolicyTagsResponse.php +++ b/DataCatalog/src/V1/ListPolicyTagsResponse.php @@ -28,7 +28,7 @@ class ListPolicyTagsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/ListTagsRequest.php b/DataCatalog/src/V1/ListTagsRequest.php index cbcaa220fb9b..764a3df3a9a6 100644 --- a/DataCatalog/src/V1/ListTagsRequest.php +++ b/DataCatalog/src/V1/ListTagsRequest.php @@ -24,20 +24,20 @@ class ListTagsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of tags to return. Default is 10. Maximum limit is 1000. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Pagination token that specifies the next page to return. If empty, the * first page is returned. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The name of the Data Catalog resource to list the tags of. diff --git a/DataCatalog/src/V1/ListTagsResponse.php b/DataCatalog/src/V1/ListTagsResponse.php index 0263be5f2691..5e61e71914c4 100644 --- a/DataCatalog/src/V1/ListTagsResponse.php +++ b/DataCatalog/src/V1/ListTagsResponse.php @@ -28,7 +28,7 @@ class ListTagsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/ListTaxonomiesRequest.php b/DataCatalog/src/V1/ListTaxonomiesRequest.php index b20033a00513..bc7f181f1a7b 100644 --- a/DataCatalog/src/V1/ListTaxonomiesRequest.php +++ b/DataCatalog/src/V1/ListTaxonomiesRequest.php @@ -21,14 +21,14 @@ class ListTaxonomiesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return. Must be a value between 1 and 1000 * inclusively. If not set, defaults to 50. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The pagination token of the next results page. If not set, * the first page is returned. @@ -36,14 +36,14 @@ class ListTaxonomiesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * Supported field for filter is 'service' and value is 'dataplex'. * Eg: service=dataplex. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. Resource name of the project to list the taxonomies of. Please see diff --git a/DataCatalog/src/V1/ListTaxonomiesResponse.php b/DataCatalog/src/V1/ListTaxonomiesResponse.php index ffb8b32460c7..43049d7f29b0 100644 --- a/DataCatalog/src/V1/ListTaxonomiesResponse.php +++ b/DataCatalog/src/V1/ListTaxonomiesResponse.php @@ -28,7 +28,7 @@ class ListTaxonomiesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/LookerSystemSpec.php b/DataCatalog/src/V1/LookerSystemSpec.php index 91ab80e66cf1..924a3e643eae 100644 --- a/DataCatalog/src/V1/LookerSystemSpec.php +++ b/DataCatalog/src/V1/LookerSystemSpec.php @@ -23,37 +23,37 @@ class LookerSystemSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent_instance_id = 1; */ - private $parent_instance_id = ''; + protected $parent_instance_id = ''; /** * Name of the parent Looker Instance. Empty if it does not exist. * * Generated from protobuf field string parent_instance_display_name = 2; */ - private $parent_instance_display_name = ''; + protected $parent_instance_display_name = ''; /** * ID of the parent Model. Empty if it does not exist. * * Generated from protobuf field string parent_model_id = 3; */ - private $parent_model_id = ''; + protected $parent_model_id = ''; /** * Name of the parent Model. Empty if it does not exist. * * Generated from protobuf field string parent_model_display_name = 4; */ - private $parent_model_display_name = ''; + protected $parent_model_display_name = ''; /** * ID of the parent View. Empty if it does not exist. * * Generated from protobuf field string parent_view_id = 5; */ - private $parent_view_id = ''; + protected $parent_view_id = ''; /** * Name of the parent View. Empty if it does not exist. * * Generated from protobuf field string parent_view_display_name = 6; */ - private $parent_view_display_name = ''; + protected $parent_view_display_name = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/LookupEntryRequest.php b/DataCatalog/src/V1/LookupEntryRequest.php index 659d18e8920b..45caf368d1f6 100644 --- a/DataCatalog/src/V1/LookupEntryRequest.php +++ b/DataCatalog/src/V1/LookupEntryRequest.php @@ -23,7 +23,7 @@ class LookupEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string project = 6; */ - private $project = ''; + protected $project = ''; /** * Location where the lookup should be performed. Required to lookup * entry that is not a part of `DPMS` or `DATAPLEX` `integrated_system` @@ -31,7 +31,7 @@ class LookupEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string location = 7; */ - private $location = ''; + protected $location = ''; protected $target_name; /** diff --git a/DataCatalog/src/V1/ModifyEntryContactsRequest.php b/DataCatalog/src/V1/ModifyEntryContactsRequest.php index 7ce5cd20e3b0..214f3fb6b0e9 100644 --- a/DataCatalog/src/V1/ModifyEntryContactsRequest.php +++ b/DataCatalog/src/V1/ModifyEntryContactsRequest.php @@ -21,13 +21,13 @@ class ModifyEntryContactsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The new value for the Contacts. * * Generated from protobuf field .google.cloud.datacatalog.v1.Contacts contacts = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $contacts = null; + protected $contacts = null; /** * Constructor. diff --git a/DataCatalog/src/V1/ModifyEntryOverviewRequest.php b/DataCatalog/src/V1/ModifyEntryOverviewRequest.php index a04a28069747..31f931ef546f 100644 --- a/DataCatalog/src/V1/ModifyEntryOverviewRequest.php +++ b/DataCatalog/src/V1/ModifyEntryOverviewRequest.php @@ -21,13 +21,13 @@ class ModifyEntryOverviewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The new value for the Entry Overview. * * Generated from protobuf field .google.cloud.datacatalog.v1.EntryOverview entry_overview = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $entry_overview = null; + protected $entry_overview = null; /** * Constructor. diff --git a/DataCatalog/src/V1/PersonalDetails.php b/DataCatalog/src/V1/PersonalDetails.php index f80142bca44a..15b11371fec6 100644 --- a/DataCatalog/src/V1/PersonalDetails.php +++ b/DataCatalog/src/V1/PersonalDetails.php @@ -20,13 +20,13 @@ class PersonalDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool starred = 1; */ - private $starred = false; + protected $starred = false; /** * Set if the entry is starred; unset otherwise. * * Generated from protobuf field .google.protobuf.Timestamp star_time = 2; */ - private $star_time = null; + protected $star_time = null; /** * Constructor. diff --git a/DataCatalog/src/V1/PhysicalSchema/AvroSchema.php b/DataCatalog/src/V1/PhysicalSchema/AvroSchema.php index 3b60c8fb8057..909abe21a174 100644 --- a/DataCatalog/src/V1/PhysicalSchema/AvroSchema.php +++ b/DataCatalog/src/V1/PhysicalSchema/AvroSchema.php @@ -20,7 +20,7 @@ class AvroSchema extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string text = 1; */ - private $text = ''; + protected $text = ''; /** * Constructor. @@ -65,6 +65,4 @@ public function setText($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(AvroSchema::class, \Google\Cloud\DataCatalog\V1\PhysicalSchema_AvroSchema::class); diff --git a/DataCatalog/src/V1/PhysicalSchema/CsvSchema.php b/DataCatalog/src/V1/PhysicalSchema/CsvSchema.php index 6df505123b75..86855a0c5c56 100644 --- a/DataCatalog/src/V1/PhysicalSchema/CsvSchema.php +++ b/DataCatalog/src/V1/PhysicalSchema/CsvSchema.php @@ -31,6 +31,4 @@ public function __construct($data = NULL) { } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(CsvSchema::class, \Google\Cloud\DataCatalog\V1\PhysicalSchema_CsvSchema::class); diff --git a/DataCatalog/src/V1/PhysicalSchema/OrcSchema.php b/DataCatalog/src/V1/PhysicalSchema/OrcSchema.php index 3537fd33c759..8018fceb9fb7 100644 --- a/DataCatalog/src/V1/PhysicalSchema/OrcSchema.php +++ b/DataCatalog/src/V1/PhysicalSchema/OrcSchema.php @@ -31,6 +31,4 @@ public function __construct($data = NULL) { } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(OrcSchema::class, \Google\Cloud\DataCatalog\V1\PhysicalSchema_OrcSchema::class); diff --git a/DataCatalog/src/V1/PhysicalSchema/ParquetSchema.php b/DataCatalog/src/V1/PhysicalSchema/ParquetSchema.php index 3a2aa3425642..31b0fea90a9d 100644 --- a/DataCatalog/src/V1/PhysicalSchema/ParquetSchema.php +++ b/DataCatalog/src/V1/PhysicalSchema/ParquetSchema.php @@ -31,6 +31,4 @@ public function __construct($data = NULL) { } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ParquetSchema::class, \Google\Cloud\DataCatalog\V1\PhysicalSchema_ParquetSchema::class); diff --git a/DataCatalog/src/V1/PhysicalSchema/ProtobufSchema.php b/DataCatalog/src/V1/PhysicalSchema/ProtobufSchema.php index 02763c5306d7..4df934cac20b 100644 --- a/DataCatalog/src/V1/PhysicalSchema/ProtobufSchema.php +++ b/DataCatalog/src/V1/PhysicalSchema/ProtobufSchema.php @@ -20,7 +20,7 @@ class ProtobufSchema extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string text = 1; */ - private $text = ''; + protected $text = ''; /** * Constructor. @@ -65,6 +65,4 @@ public function setText($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ProtobufSchema::class, \Google\Cloud\DataCatalog\V1\PhysicalSchema_ProtobufSchema::class); diff --git a/DataCatalog/src/V1/PhysicalSchema/ThriftSchema.php b/DataCatalog/src/V1/PhysicalSchema/ThriftSchema.php index bf61fd4d6ac1..4999299b470f 100644 --- a/DataCatalog/src/V1/PhysicalSchema/ThriftSchema.php +++ b/DataCatalog/src/V1/PhysicalSchema/ThriftSchema.php @@ -20,7 +20,7 @@ class ThriftSchema extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string text = 1; */ - private $text = ''; + protected $text = ''; /** * Constructor. @@ -65,6 +65,4 @@ public function setText($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ThriftSchema::class, \Google\Cloud\DataCatalog\V1\PhysicalSchema_ThriftSchema::class); diff --git a/DataCatalog/src/V1/PhysicalSchema_AvroSchema.php b/DataCatalog/src/V1/PhysicalSchema_AvroSchema.php deleted file mode 100644 index 4b566b88e42e..000000000000 --- a/DataCatalog/src/V1/PhysicalSchema_AvroSchema.php +++ /dev/null @@ -1,16 +0,0 @@ -string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; */ - private $name = ''; + protected $name = ''; /** * Required. User-defined name of this policy tag. * The name can't start or end with spaces and must be unique within the @@ -38,7 +38,7 @@ class PolicyTag extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $display_name = ''; + protected $display_name = ''; /** * Description of this policy tag. If not set, defaults to empty. * The description must contain only Unicode characters, @@ -47,7 +47,7 @@ class PolicyTag extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 3; */ - private $description = ''; + protected $description = ''; /** * Resource name of this policy tag's parent policy tag. If empty, this is a * top level tag. If not set, defaults to an empty string. @@ -57,7 +57,7 @@ class PolicyTag extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent_policy_tag = 4; */ - private $parent_policy_tag = ''; + protected $parent_policy_tag = ''; /** * Output only. Resource names of child policy tags of this policy tag. * diff --git a/DataCatalog/src/V1/PolicyTagManagerClient.php b/DataCatalog/src/V1/PolicyTagManagerClient.php deleted file mode 100644 index ee30246bc7ae..000000000000 --- a/DataCatalog/src/V1/PolicyTagManagerClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/CreateTaxonomy', - $argument, - ['\Google\Cloud\DataCatalog\V1\Taxonomy', 'decode'], - $metadata, $options); - } - - /** - * Deletes a taxonomy, including all policy tags in this - * taxonomy, their associated policies, and the policy tags references from - * BigQuery columns. - * @param \Google\Cloud\DataCatalog\V1\DeleteTaxonomyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteTaxonomy(\Google\Cloud\DataCatalog\V1\DeleteTaxonomyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/DeleteTaxonomy', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Updates a taxonomy, including its display name, - * description, and activated policy types. - * @param \Google\Cloud\DataCatalog\V1\UpdateTaxonomyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateTaxonomy(\Google\Cloud\DataCatalog\V1\UpdateTaxonomyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/UpdateTaxonomy', - $argument, - ['\Google\Cloud\DataCatalog\V1\Taxonomy', 'decode'], - $metadata, $options); - } - - /** - * Lists all taxonomies in a project in a particular location that you - * have a permission to view. - * @param \Google\Cloud\DataCatalog\V1\ListTaxonomiesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListTaxonomies(\Google\Cloud\DataCatalog\V1\ListTaxonomiesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/ListTaxonomies', - $argument, - ['\Google\Cloud\DataCatalog\V1\ListTaxonomiesResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets a taxonomy. - * @param \Google\Cloud\DataCatalog\V1\GetTaxonomyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetTaxonomy(\Google\Cloud\DataCatalog\V1\GetTaxonomyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/GetTaxonomy', - $argument, - ['\Google\Cloud\DataCatalog\V1\Taxonomy', 'decode'], - $metadata, $options); - } - - /** - * Creates a policy tag in a taxonomy. - * @param \Google\Cloud\DataCatalog\V1\CreatePolicyTagRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreatePolicyTag(\Google\Cloud\DataCatalog\V1\CreatePolicyTagRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/CreatePolicyTag', - $argument, - ['\Google\Cloud\DataCatalog\V1\PolicyTag', 'decode'], - $metadata, $options); - } - - /** - * 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 - * @param \Google\Cloud\DataCatalog\V1\DeletePolicyTagRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeletePolicyTag(\Google\Cloud\DataCatalog\V1\DeletePolicyTagRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/DeletePolicyTag', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Updates a policy tag, including its display - * name, description, and parent policy tag. - * @param \Google\Cloud\DataCatalog\V1\UpdatePolicyTagRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdatePolicyTag(\Google\Cloud\DataCatalog\V1\UpdatePolicyTagRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/UpdatePolicyTag', - $argument, - ['\Google\Cloud\DataCatalog\V1\PolicyTag', 'decode'], - $metadata, $options); - } - - /** - * Lists all policy tags in a taxonomy. - * @param \Google\Cloud\DataCatalog\V1\ListPolicyTagsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListPolicyTags(\Google\Cloud\DataCatalog\V1\ListPolicyTagsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/ListPolicyTags', - $argument, - ['\Google\Cloud\DataCatalog\V1\ListPolicyTagsResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets a policy tag. - * @param \Google\Cloud\DataCatalog\V1\GetPolicyTagRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetPolicyTag(\Google\Cloud\DataCatalog\V1\GetPolicyTagRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/GetPolicyTag', - $argument, - ['\Google\Cloud\DataCatalog\V1\PolicyTag', 'decode'], - $metadata, $options); - } - - /** - * Gets the IAM policy for a policy tag or a taxonomy. - * @param \Google\Cloud\Iam\V1\GetIamPolicyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetIamPolicy(\Google\Cloud\Iam\V1\GetIamPolicyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/GetIamPolicy', - $argument, - ['\Google\Cloud\Iam\V1\Policy', 'decode'], - $metadata, $options); - } - - /** - * Sets the IAM policy for a policy tag or a taxonomy. - * @param \Google\Cloud\Iam\V1\SetIamPolicyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function SetIamPolicy(\Google\Cloud\Iam\V1\SetIamPolicyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/SetIamPolicy', - $argument, - ['\Google\Cloud\Iam\V1\Policy', 'decode'], - $metadata, $options); - } - - /** - * Returns your permissions on a specified policy tag or - * taxonomy. - * @param \Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function TestIamPermissions(\Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManager/TestIamPermissions', - $argument, - ['\Google\Cloud\Iam\V1\TestIamPermissionsResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/DataCatalog/src/V1/PolicyTagManagerSerializationClient.php b/DataCatalog/src/V1/PolicyTagManagerSerializationClient.php deleted file mode 100644 index d0f9f42d2a26..000000000000 --- a/DataCatalog/src/V1/PolicyTagManagerSerializationClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ReplaceTaxonomy', - $argument, - ['\Google\Cloud\DataCatalog\V1\Taxonomy', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\DataCatalog\V1\ImportTaxonomiesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ImportTaxonomies(\Google\Cloud\DataCatalog\V1\ImportTaxonomiesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ImportTaxonomies', - $argument, - ['\Google\Cloud\DataCatalog\V1\ImportTaxonomiesResponse', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\DataCatalog\V1\ExportTaxonomiesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ExportTaxonomies(\Google\Cloud\DataCatalog\V1\ExportTaxonomiesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ExportTaxonomies', - $argument, - ['\Google\Cloud\DataCatalog\V1\ExportTaxonomiesResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/DataCatalog/src/V1/README.md b/DataCatalog/src/V1/README.md deleted file mode 100644 index dc54ef99cd7e..000000000000 --- a/DataCatalog/src/V1/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Google Cloud Data Catalog V1 generated client for PHP - -### Sample - -```php -require 'vendor/autoload.php'; - -use Google\Cloud\DataCatalog\V1\DataCatalogClient; - -$client = new DataCatalogClient(); -$location = DataCatalogClient::locationName('[MY_PROJECT_ID]', 'us-central1'); - -$entryGroup = $client->createEntryGroup($location, 'sample_entry_group'); - -printf('Created entry group: %s' . PHP_EOL, $entryGroup->getName()); -``` diff --git a/DataCatalog/src/V1/ReconcileTagsMetadata.php b/DataCatalog/src/V1/ReconcileTagsMetadata.php index 03be4a9ff37c..2a72e0e8e924 100644 --- a/DataCatalog/src/V1/ReconcileTagsMetadata.php +++ b/DataCatalog/src/V1/ReconcileTagsMetadata.php @@ -22,7 +22,7 @@ class ReconcileTagsMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.ReconcileTagsMetadata.ReconciliationState state = 1; */ - private $state = 0; + protected $state = 0; /** * Maps the name of each tagged column (or empty string for a * sole entry) to tagging operation [status][google.rpc.Status]. diff --git a/DataCatalog/src/V1/ReconcileTagsMetadata/ReconciliationState.php b/DataCatalog/src/V1/ReconcileTagsMetadata/ReconciliationState.php index 2f40d719bcfd..6623a0097094 100644 --- a/DataCatalog/src/V1/ReconcileTagsMetadata/ReconciliationState.php +++ b/DataCatalog/src/V1/ReconcileTagsMetadata/ReconciliationState.php @@ -66,6 +66,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ReconciliationState::class, \Google\Cloud\DataCatalog\V1\ReconcileTagsMetadata_ReconciliationState::class); diff --git a/DataCatalog/src/V1/ReconcileTagsMetadata_ReconciliationState.php b/DataCatalog/src/V1/ReconcileTagsMetadata_ReconciliationState.php deleted file mode 100644 index e8c53564091e..000000000000 --- a/DataCatalog/src/V1/ReconcileTagsMetadata_ReconciliationState.php +++ /dev/null @@ -1,16 +0,0 @@ -string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The name of the tag template, which is used for reconciliation. * * Generated from protobuf field string tag_template = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $tag_template = ''; + protected $tag_template = ''; /** * If set to `true`, deletes entry tags related to a tag template * not listed in the tags source from an entry. If set to `false`, @@ -35,7 +35,7 @@ class ReconcileTagsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool force_delete_missing = 3; */ - private $force_delete_missing = false; + protected $force_delete_missing = false; /** * A list of tags to apply to an entry. A tag can specify a * tag template, which must be the template specified in the diff --git a/DataCatalog/src/V1/ReconcileTagsResponse.php b/DataCatalog/src/V1/ReconcileTagsResponse.php index 30b9fc03357f..7847c76e8692 100644 --- a/DataCatalog/src/V1/ReconcileTagsResponse.php +++ b/DataCatalog/src/V1/ReconcileTagsResponse.php @@ -22,19 +22,19 @@ class ReconcileTagsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 created_tags_count = 1; */ - private $created_tags_count = 0; + protected $created_tags_count = 0; /** * Number of tags updated in the request. * * Generated from protobuf field int64 updated_tags_count = 2; */ - private $updated_tags_count = 0; + protected $updated_tags_count = 0; /** * Number of tags deleted in the request. * * Generated from protobuf field int64 deleted_tags_count = 3; */ - private $deleted_tags_count = 0; + protected $deleted_tags_count = 0; /** * Constructor. diff --git a/DataCatalog/src/V1/RenameTagTemplateFieldEnumValueRequest.php b/DataCatalog/src/V1/RenameTagTemplateFieldEnumValueRequest.php index 0adb3c70c1fd..2356d1f0e0a7 100644 --- a/DataCatalog/src/V1/RenameTagTemplateFieldEnumValueRequest.php +++ b/DataCatalog/src/V1/RenameTagTemplateFieldEnumValueRequest.php @@ -21,14 +21,14 @@ class RenameTagTemplateFieldEnumValueRequest extends \Google\Protobuf\Internal\M * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The new display name of the enum value. For example, * `my_new_enum_value`. * * Generated from protobuf field string new_enum_value_display_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_enum_value_display_name = ''; + protected $new_enum_value_display_name = ''; /** * @param string $name Required. The name of the enum field value. Please see diff --git a/DataCatalog/src/V1/RenameTagTemplateFieldRequest.php b/DataCatalog/src/V1/RenameTagTemplateFieldRequest.php index e9f4678eca0b..385fb3e2b59c 100644 --- a/DataCatalog/src/V1/RenameTagTemplateFieldRequest.php +++ b/DataCatalog/src/V1/RenameTagTemplateFieldRequest.php @@ -21,14 +21,14 @@ class RenameTagTemplateFieldRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The new ID of this tag template field. For example, * `my_new_field`. * * Generated from protobuf field string new_tag_template_field_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_tag_template_field_id = ''; + protected $new_tag_template_field_id = ''; /** * @param string $name Required. The name of the tag template field. Please see diff --git a/DataCatalog/src/V1/ReplaceTaxonomyRequest.php b/DataCatalog/src/V1/ReplaceTaxonomyRequest.php index 06ddfdd2fabd..67350fac7799 100644 --- a/DataCatalog/src/V1/ReplaceTaxonomyRequest.php +++ b/DataCatalog/src/V1/ReplaceTaxonomyRequest.php @@ -21,13 +21,13 @@ class ReplaceTaxonomyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. Taxonomy to update along with its child policy tags. * * Generated from protobuf field .google.cloud.datacatalog.v1.SerializedTaxonomy serialized_taxonomy = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $serialized_taxonomy = null; + protected $serialized_taxonomy = null; /** * Constructor. diff --git a/DataCatalog/src/V1/RoutineSpec.php b/DataCatalog/src/V1/RoutineSpec.php index 72252eaf2b32..8c71b088c8ba 100644 --- a/DataCatalog/src/V1/RoutineSpec.php +++ b/DataCatalog/src/V1/RoutineSpec.php @@ -21,7 +21,7 @@ class RoutineSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.RoutineSpec.RoutineType routine_type = 1; */ - private $routine_type = 0; + protected $routine_type = 0; /** * The language the routine is written in. The exact value depends on the * source system. For BigQuery routines, possible values are: @@ -30,7 +30,7 @@ class RoutineSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string language = 2; */ - private $language = ''; + protected $language = ''; /** * Arguments of the routine. * @@ -43,13 +43,13 @@ class RoutineSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string return_type = 4; */ - private $return_type = ''; + protected $return_type = ''; /** * The body of the routine. * * Generated from protobuf field string definition_body = 5; */ - private $definition_body = ''; + protected $definition_body = ''; protected $system_spec; /** diff --git a/DataCatalog/src/V1/RoutineSpec/Argument.php b/DataCatalog/src/V1/RoutineSpec/Argument.php index 9b5fc34ae02b..40d191ca5862 100644 --- a/DataCatalog/src/V1/RoutineSpec/Argument.php +++ b/DataCatalog/src/V1/RoutineSpec/Argument.php @@ -21,20 +21,20 @@ class Argument extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Specifies whether the argument is input or output. * * Generated from protobuf field .google.cloud.datacatalog.v1.RoutineSpec.Argument.Mode mode = 2; */ - private $mode = 0; + protected $mode = 0; /** * Type of the argument. The exact value depends on the source system and * the language. * * Generated from protobuf field string type = 3; */ - private $type = ''; + protected $type = ''; /** * Constructor. @@ -141,6 +141,4 @@ public function setType($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Argument::class, \Google\Cloud\DataCatalog\V1\RoutineSpec_Argument::class); diff --git a/DataCatalog/src/V1/RoutineSpec/Argument/Mode.php b/DataCatalog/src/V1/RoutineSpec/Argument/Mode.php index 894ff07fc297..e32f10485e21 100644 --- a/DataCatalog/src/V1/RoutineSpec/Argument/Mode.php +++ b/DataCatalog/src/V1/RoutineSpec/Argument/Mode.php @@ -66,6 +66,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Mode::class, \Google\Cloud\DataCatalog\V1\RoutineSpec_Argument_Mode::class); diff --git a/DataCatalog/src/V1/RoutineSpec/RoutineType.php b/DataCatalog/src/V1/RoutineSpec/RoutineType.php index 8778af7e281d..d157ebfbfb7c 100644 --- a/DataCatalog/src/V1/RoutineSpec/RoutineType.php +++ b/DataCatalog/src/V1/RoutineSpec/RoutineType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(RoutineType::class, \Google\Cloud\DataCatalog\V1\RoutineSpec_RoutineType::class); diff --git a/DataCatalog/src/V1/RoutineSpec_Argument.php b/DataCatalog/src/V1/RoutineSpec_Argument.php deleted file mode 100644 index 29e2b0133042..000000000000 --- a/DataCatalog/src/V1/RoutineSpec_Argument.php +++ /dev/null @@ -1,16 +0,0 @@ -.google.cloud.datacatalog.v1.SearchCatalogRequest.Scope scope = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $scope = null; + protected $scope = null; /** * Optional. The query string with a minimum of 3 characters and specific * syntax. For more information, see [Data Catalog search @@ -38,7 +38,7 @@ class SearchCatalogRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string query = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $query = ''; + protected $query = ''; /** * Upper bound on the number of results you can get in a single response. * Can't be negative or 0, defaults to 10 in this case. @@ -47,7 +47,7 @@ class SearchCatalogRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. Pagination token that, if specified, returns the next page of * search results. If empty, returns the first page. @@ -59,7 +59,7 @@ class SearchCatalogRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Specifies the order of results. * Currently supported case-sensitive values are: @@ -76,7 +76,7 @@ class SearchCatalogRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * Optional. If set, use searchAll permission granted on organizations from * `include_org_ids` and projects from `include_project_ids` instead of the @@ -86,7 +86,7 @@ class SearchCatalogRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool admin_search = 17 [(.google.api.field_behavior) = OPTIONAL]; */ - private $admin_search = false; + protected $admin_search = false; /** * @param \Google\Cloud\DataCatalog\V1\SearchCatalogRequest\Scope $scope Required. The scope of this search request. diff --git a/DataCatalog/src/V1/SearchCatalogRequest/Scope.php b/DataCatalog/src/V1/SearchCatalogRequest/Scope.php index c175e1e7bcd0..f56ff957d7d8 100644 --- a/DataCatalog/src/V1/SearchCatalogRequest/Scope.php +++ b/DataCatalog/src/V1/SearchCatalogRequest/Scope.php @@ -27,7 +27,7 @@ class Scope extends \Google\Protobuf\Internal\Message /** * The list of project IDs to search within. * For more information on the distinction between project names, IDs, and - * numbers, see [Projects](https://cloud.google.com/docs/overview/#projects). + * numbers, see [Projects](/docs/overview/#projects). * * Generated from protobuf field repeated string include_project_ids = 3; */ @@ -35,12 +35,12 @@ class Scope extends \Google\Protobuf\Internal\Message /** * If `true`, include Google Cloud public datasets in * search results. By default, they are excluded. - * See [Google Cloud Public Datasets](https://cloud.google.com/public-datasets) for more + * See [Google Cloud Public Datasets](/public-datasets) for more * information. * * Generated from protobuf field bool include_gcp_public_datasets = 7; */ - private $include_gcp_public_datasets = false; + protected $include_gcp_public_datasets = false; /** * Optional. The list of locations to search within. If empty, all locations * are searched. @@ -60,7 +60,7 @@ class Scope extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool starred_only = 18 [(.google.api.field_behavior) = OPTIONAL]; */ - private $starred_only = false; + protected $starred_only = false; /** * Optional. This field is deprecated. The search mechanism for public and * private tag templates is the same. @@ -84,11 +84,11 @@ class Scope extends \Google\Protobuf\Internal\Message * @type array|\Google\Protobuf\Internal\RepeatedField $include_project_ids * The list of project IDs to search within. * For more information on the distinction between project names, IDs, and - * numbers, see [Projects](https://cloud.google.com/docs/overview/#projects). + * numbers, see [Projects](/docs/overview/#projects). * @type bool $include_gcp_public_datasets * If `true`, include Google Cloud public datasets in * search results. By default, they are excluded. - * See [Google Cloud Public Datasets](https://cloud.google.com/public-datasets) for more + * See [Google Cloud Public Datasets](/public-datasets) for more * information. * @type array|\Google\Protobuf\Internal\RepeatedField $restricted_locations * Optional. The list of locations to search within. If empty, all locations @@ -147,7 +147,7 @@ public function setIncludeOrgIds($var) /** * The list of project IDs to search within. * For more information on the distinction between project names, IDs, and - * numbers, see [Projects](https://cloud.google.com/docs/overview/#projects). + * numbers, see [Projects](/docs/overview/#projects). * * Generated from protobuf field repeated string include_project_ids = 3; * @return \Google\Protobuf\Internal\RepeatedField @@ -160,7 +160,7 @@ public function getIncludeProjectIds() /** * The list of project IDs to search within. * For more information on the distinction between project names, IDs, and - * numbers, see [Projects](https://cloud.google.com/docs/overview/#projects). + * numbers, see [Projects](/docs/overview/#projects). * * Generated from protobuf field repeated string include_project_ids = 3; * @param array|\Google\Protobuf\Internal\RepeatedField $var @@ -177,7 +177,7 @@ public function setIncludeProjectIds($var) /** * If `true`, include Google Cloud public datasets in * search results. By default, they are excluded. - * See [Google Cloud Public Datasets](https://cloud.google.com/public-datasets) for more + * See [Google Cloud Public Datasets](/public-datasets) for more * information. * * Generated from protobuf field bool include_gcp_public_datasets = 7; @@ -191,7 +191,7 @@ public function getIncludeGcpPublicDatasets() /** * If `true`, include Google Cloud public datasets in * search results. By default, they are excluded. - * See [Google Cloud Public Datasets](https://cloud.google.com/public-datasets) for more + * See [Google Cloud Public Datasets](/public-datasets) for more * information. * * Generated from protobuf field bool include_gcp_public_datasets = 7; @@ -308,6 +308,4 @@ public function setIncludePublicTagTemplates($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Scope::class, \Google\Cloud\DataCatalog\V1\SearchCatalogRequest_Scope::class); diff --git a/DataCatalog/src/V1/SearchCatalogRequest_Scope.php b/DataCatalog/src/V1/SearchCatalogRequest_Scope.php deleted file mode 100644 index 38eb69f7d308..000000000000 --- a/DataCatalog/src/V1/SearchCatalogRequest_Scope.php +++ /dev/null @@ -1,16 +0,0 @@ -int32 total_size = 2; */ - private $total_size = 0; + protected $total_size = 0; /** * Pagination token that can be used in subsequent calls to retrieve the next * page of results. * * Generated from protobuf field string next_page_token = 3; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Unreachable locations. Search results don't include data from those * locations. diff --git a/DataCatalog/src/V1/SearchCatalogResult.php b/DataCatalog/src/V1/SearchCatalogResult.php index d39ae3d5702d..3e4c505fd6a7 100644 --- a/DataCatalog/src/V1/SearchCatalogResult.php +++ b/DataCatalog/src/V1/SearchCatalogResult.php @@ -23,7 +23,7 @@ class SearchCatalogResult extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.SearchResultType search_result_type = 1; */ - private $search_result_type = 0; + protected $search_result_type = 0; /** * Sub-type of the search result. * A dot-delimited full type of the resource. The same type you @@ -32,7 +32,7 @@ class SearchCatalogResult extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string search_result_subtype = 2; */ - private $search_result_subtype = ''; + protected $search_result_subtype = ''; /** * The relative name of the resource in URL format. * Examples: @@ -41,7 +41,7 @@ class SearchCatalogResult extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string relative_resource_name = 3; */ - private $relative_resource_name = ''; + protected $relative_resource_name = ''; /** * The full name of the Google Cloud resource the entry belongs to. * For more information, see [Full Resource Name] @@ -51,13 +51,13 @@ class SearchCatalogResult extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string linked_resource = 4; */ - private $linked_resource = ''; + protected $linked_resource = ''; /** * The last modification timestamp of the entry in the source system. * * Generated from protobuf field .google.protobuf.Timestamp modify_time = 7; */ - private $modify_time = null; + protected $modify_time = null; /** * Fully qualified name (FQN) of the resource. * FQNs take two forms: @@ -70,20 +70,20 @@ class SearchCatalogResult extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string fully_qualified_name = 10; */ - private $fully_qualified_name = ''; + protected $fully_qualified_name = ''; /** * The display name of the result. * * Generated from protobuf field string display_name = 12; */ - private $display_name = ''; + protected $display_name = ''; /** * Entry description that can consist of several sentences or paragraphs that * describe entry contents. * * Generated from protobuf field string description = 13; */ - private $description = ''; + protected $description = ''; protected $system; /** diff --git a/DataCatalog/src/V1/SerializedPolicyTag.php b/DataCatalog/src/V1/SerializedPolicyTag.php index 7b60266a058c..aeeefe02d21f 100644 --- a/DataCatalog/src/V1/SerializedPolicyTag.php +++ b/DataCatalog/src/V1/SerializedPolicyTag.php @@ -22,14 +22,14 @@ class SerializedPolicyTag extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string policy_tag = 1; */ - private $policy_tag = ''; + protected $policy_tag = ''; /** * Required. Display name of the policy tag. At most 200 bytes when encoded * in UTF-8. * * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $display_name = ''; + protected $display_name = ''; /** * Description of the serialized policy tag. At most * 2000 bytes when encoded in UTF-8. If not set, defaults to an @@ -37,7 +37,7 @@ class SerializedPolicyTag extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 3; */ - private $description = ''; + protected $description = ''; /** * Children of the policy tag, if any. * diff --git a/DataCatalog/src/V1/SerializedTaxonomy.php b/DataCatalog/src/V1/SerializedTaxonomy.php index fca15559a39f..f8186a5ec8bb 100644 --- a/DataCatalog/src/V1/SerializedTaxonomy.php +++ b/DataCatalog/src/V1/SerializedTaxonomy.php @@ -23,14 +23,14 @@ class SerializedTaxonomy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $display_name = ''; + protected $display_name = ''; /** * Description of the serialized taxonomy. At most 2000 bytes when * encoded in UTF-8. If not set, defaults to an empty description. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * Top level policy tags associated with the taxonomy, if any. * diff --git a/DataCatalog/src/V1/SqlDatabaseSystemSpec.php b/DataCatalog/src/V1/SqlDatabaseSystemSpec.php index 90be347ab812..86661c30183d 100644 --- a/DataCatalog/src/V1/SqlDatabaseSystemSpec.php +++ b/DataCatalog/src/V1/SqlDatabaseSystemSpec.php @@ -29,13 +29,13 @@ class SqlDatabaseSystemSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string sql_engine = 1; */ - private $sql_engine = ''; + protected $sql_engine = ''; /** * Version of the database engine. * * Generated from protobuf field string database_version = 2; */ - private $database_version = ''; + protected $database_version = ''; /** * Host of the SQL database * enum InstanceHost { @@ -49,7 +49,7 @@ class SqlDatabaseSystemSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string instance_host = 3; */ - private $instance_host = ''; + protected $instance_host = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/StarEntryRequest.php b/DataCatalog/src/V1/StarEntryRequest.php index 5ef224958cfb..53f0422fc6a5 100644 --- a/DataCatalog/src/V1/StarEntryRequest.php +++ b/DataCatalog/src/V1/StarEntryRequest.php @@ -21,7 +21,7 @@ class StarEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the entry to mark as starred. Please see diff --git a/DataCatalog/src/V1/StorageProperties.php b/DataCatalog/src/V1/StorageProperties.php index 47048de671d2..f750dbc3b49a 100644 --- a/DataCatalog/src/V1/StorageProperties.php +++ b/DataCatalog/src/V1/StorageProperties.php @@ -43,7 +43,7 @@ class StorageProperties extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string file_type = 2; */ - private $file_type = ''; + protected $file_type = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/SystemTimestamps.php b/DataCatalog/src/V1/SystemTimestamps.php index c5f6200b440f..bdc1c3c65b38 100644 --- a/DataCatalog/src/V1/SystemTimestamps.php +++ b/DataCatalog/src/V1/SystemTimestamps.php @@ -20,7 +20,7 @@ class SystemTimestamps extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; */ - private $create_time = null; + protected $create_time = null; /** * Timestamp of the last modification of the resource or its metadata within * a given system. @@ -31,14 +31,14 @@ class SystemTimestamps extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp update_time = 2; */ - private $update_time = null; + protected $update_time = null; /** * Output only. Expiration timestamp of the resource within the given system. * Currently only applicable to BigQuery resources. * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $expire_time = null; + protected $expire_time = null; /** * Constructor. diff --git a/DataCatalog/src/V1/TableSpec.php b/DataCatalog/src/V1/TableSpec.php index f4718dd62397..79f7f99856fc 100644 --- a/DataCatalog/src/V1/TableSpec.php +++ b/DataCatalog/src/V1/TableSpec.php @@ -24,7 +24,7 @@ class TableSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string grouped_entry = 1 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $grouped_entry = ''; + protected $grouped_entry = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/Tag.php b/DataCatalog/src/V1/Tag.php index 6fdde37aea36..54e7f6197639 100644 --- a/DataCatalog/src/V1/Tag.php +++ b/DataCatalog/src/V1/Tag.php @@ -27,7 +27,7 @@ class Tag extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Required. The resource name of the tag template this tag uses. Example: * `projects/{PROJECT_ID}/locations/{LOCATION}/tagTemplates/{TAG_TEMPLATE_ID}` @@ -35,13 +35,13 @@ class Tag extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string template = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $template = ''; + protected $template = ''; /** * Output only. The display name of the tag template. * * Generated from protobuf field string template_display_name = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $template_display_name = ''; + protected $template_display_name = ''; /** * Required. Maps the ID of a tag field to its value and additional * information about that field. diff --git a/DataCatalog/src/V1/TagField.php b/DataCatalog/src/V1/TagField.php index 51c956dd5cd4..560ede287e87 100644 --- a/DataCatalog/src/V1/TagField.php +++ b/DataCatalog/src/V1/TagField.php @@ -21,7 +21,7 @@ class TagField extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. The order of this field with respect to other fields in this * tag. Can be set by @@ -32,7 +32,7 @@ class TagField extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 order = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $order = 0; + protected $order = 0; protected $kind; /** diff --git a/DataCatalog/src/V1/TagField/EnumValue.php b/DataCatalog/src/V1/TagField/EnumValue.php index c34e03531b15..a52d6de9bdea 100644 --- a/DataCatalog/src/V1/TagField/EnumValue.php +++ b/DataCatalog/src/V1/TagField/EnumValue.php @@ -20,7 +20,7 @@ class EnumValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. @@ -65,6 +65,4 @@ public function setDisplayName($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(EnumValue::class, \Google\Cloud\DataCatalog\V1\TagField_EnumValue::class); diff --git a/DataCatalog/src/V1/TagField_EnumValue.php b/DataCatalog/src/V1/TagField_EnumValue.php deleted file mode 100644 index 8af1ed0c53cf..000000000000 --- a/DataCatalog/src/V1/TagField_EnumValue.php +++ /dev/null @@ -1,16 +0,0 @@ -string name = 1; */ - private $name = ''; + protected $name = ''; /** * Display name for this template. Defaults to an empty string. * The name must contain only Unicode letters, numbers (0-9), underscores (_), @@ -38,7 +38,7 @@ class TagTemplate extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Indicates whether tags created with this template are public. Public tags * do not require tag template access to appear in @@ -48,7 +48,7 @@ class TagTemplate extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool is_publicly_readable = 5; */ - private $is_publicly_readable = false; + protected $is_publicly_readable = false; /** * Required. Map of tag template field IDs to the settings for the field. * This map is an exhaustive list of the allowed fields. The map must contain diff --git a/DataCatalog/src/V1/TagTemplateField.php b/DataCatalog/src/V1/TagTemplateField.php index d446925af05f..679ab457c1d9 100644 --- a/DataCatalog/src/V1/TagTemplateField.php +++ b/DataCatalog/src/V1/TagTemplateField.php @@ -27,7 +27,7 @@ class TagTemplateField extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * The display name for this field. Defaults to an empty string. * The name must contain only Unicode letters, numbers (0-9), underscores (_), @@ -36,25 +36,25 @@ class TagTemplateField extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * Required. The type of value this tag field can contain. * * Generated from protobuf field .google.cloud.datacatalog.v1.FieldType type = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = null; + protected $type = null; /** * If true, this field is required. Defaults to false. * * Generated from protobuf field bool is_required = 3; */ - private $is_required = false; + protected $is_required = false; /** * The description for this field. Defaults to an empty string. * * Generated from protobuf field string description = 4; */ - private $description = ''; + protected $description = ''; /** * The order of this field with respect to other fields in this tag * template. @@ -64,7 +64,7 @@ class TagTemplateField extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 order = 5; */ - private $order = 0; + protected $order = 0; /** * Constructor. diff --git a/DataCatalog/src/V1/Taxonomy.php b/DataCatalog/src/V1/Taxonomy.php index bd408224286c..e7933040d619 100644 --- a/DataCatalog/src/V1/Taxonomy.php +++ b/DataCatalog/src/V1/Taxonomy.php @@ -40,7 +40,7 @@ class Taxonomy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; */ - private $name = ''; + protected $name = ''; /** * Required. User-defined name of this taxonomy. * The name can't start or end with spaces, must contain only Unicode letters, @@ -50,7 +50,7 @@ class Taxonomy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $display_name = ''; + protected $display_name = ''; /** * Optional. Description of this taxonomy. If not set, defaults to empty. * The description must contain only Unicode characters, tabs, newlines, @@ -59,19 +59,19 @@ class Taxonomy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $description = ''; + protected $description = ''; /** * Output only. Number of policy tags in this taxonomy. * * Generated from protobuf field int32 policy_tag_count = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $policy_tag_count = 0; + protected $policy_tag_count = 0; /** * Output only. Creation and modification timestamps of this taxonomy. * * Generated from protobuf field .google.cloud.datacatalog.v1.SystemTimestamps taxonomy_timestamps = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $taxonomy_timestamps = null; + protected $taxonomy_timestamps = null; /** * Optional. A list of policy types that are activated for this taxonomy. If * not set, defaults to an empty list. @@ -86,7 +86,7 @@ class Taxonomy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.Taxonomy.Service service = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $service = null; + protected $service = null; /** * Constructor. diff --git a/DataCatalog/src/V1/Taxonomy/PolicyType.php b/DataCatalog/src/V1/Taxonomy/PolicyType.php index 45ad29d6aeac..d1728b84df84 100644 --- a/DataCatalog/src/V1/Taxonomy/PolicyType.php +++ b/DataCatalog/src/V1/Taxonomy/PolicyType.php @@ -53,6 +53,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(PolicyType::class, \Google\Cloud\DataCatalog\V1\Taxonomy_PolicyType::class); diff --git a/DataCatalog/src/V1/Taxonomy/Service.php b/DataCatalog/src/V1/Taxonomy/Service.php index e7855594d3df..02970417dccc 100644 --- a/DataCatalog/src/V1/Taxonomy/Service.php +++ b/DataCatalog/src/V1/Taxonomy/Service.php @@ -20,13 +20,13 @@ class Service extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.ManagingSystem name = 1; */ - private $name = 0; + protected $name = 0; /** * The service agent for the service. * * Generated from protobuf field string identity = 2; */ - private $identity = ''; + protected $identity = ''; /** * Constructor. @@ -99,6 +99,4 @@ public function setIdentity($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Service::class, \Google\Cloud\DataCatalog\V1\Taxonomy_Service::class); diff --git a/DataCatalog/src/V1/Taxonomy_PolicyType.php b/DataCatalog/src/V1/Taxonomy_PolicyType.php deleted file mode 100644 index 7890fedaae76..000000000000 --- a/DataCatalog/src/V1/Taxonomy_PolicyType.php +++ /dev/null @@ -1,16 +0,0 @@ -string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the entry to mark as **not** starred. Please see diff --git a/DataCatalog/src/V1/UpdateEntryGroupRequest.php b/DataCatalog/src/V1/UpdateEntryGroupRequest.php index 16ba14f34188..153557fc00c0 100644 --- a/DataCatalog/src/V1/UpdateEntryGroupRequest.php +++ b/DataCatalog/src/V1/UpdateEntryGroupRequest.php @@ -21,7 +21,7 @@ class UpdateEntryGroupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.EntryGroup entry_group = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $entry_group = null; + protected $entry_group = null; /** * Names of fields whose values to overwrite on an entry group. * If this parameter is absent or empty, all modifiable fields @@ -30,7 +30,7 @@ class UpdateEntryGroupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\DataCatalog\V1\EntryGroup $entryGroup Required. Updates for the entry group. The `name` field must be set. diff --git a/DataCatalog/src/V1/UpdateEntryRequest.php b/DataCatalog/src/V1/UpdateEntryRequest.php index 0d8074744064..c70ab4025380 100644 --- a/DataCatalog/src/V1/UpdateEntryRequest.php +++ b/DataCatalog/src/V1/UpdateEntryRequest.php @@ -21,7 +21,7 @@ class UpdateEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.Entry entry = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $entry = null; + protected $entry = null; /** * Names of fields whose values to overwrite on an entry. * If this parameter is absent or empty, all modifiable fields @@ -47,7 +47,7 @@ class UpdateEntryRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\DataCatalog\V1\Entry $entry Required. Updates for the entry. The `name` field must be set. diff --git a/DataCatalog/src/V1/UpdatePolicyTagRequest.php b/DataCatalog/src/V1/UpdatePolicyTagRequest.php index 27fbfcc864e3..a51c4f876e53 100644 --- a/DataCatalog/src/V1/UpdatePolicyTagRequest.php +++ b/DataCatalog/src/V1/UpdatePolicyTagRequest.php @@ -22,7 +22,7 @@ class UpdatePolicyTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.PolicyTag policy_tag = 1; */ - private $policy_tag = null; + protected $policy_tag = null; /** * Specifies the fields to update. * You can update only display name, description, and parent policy tag. @@ -32,7 +32,7 @@ class UpdatePolicyTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\DataCatalog\V1\PolicyTag $policyTag The policy tag to update. You can update only its description, display diff --git a/DataCatalog/src/V1/UpdateTagRequest.php b/DataCatalog/src/V1/UpdateTagRequest.php index 9082871c0c7c..3be100dbab9f 100644 --- a/DataCatalog/src/V1/UpdateTagRequest.php +++ b/DataCatalog/src/V1/UpdateTagRequest.php @@ -21,7 +21,7 @@ class UpdateTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.Tag tag = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $tag = null; + protected $tag = null; /** * Names of fields whose values to overwrite on a tag. Currently, a tag has * the only modifiable field with the name `fields`. @@ -31,7 +31,7 @@ class UpdateTagRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\DataCatalog\V1\Tag $tag Required. The updated tag. The "name" field must be set. diff --git a/DataCatalog/src/V1/UpdateTagTemplateFieldRequest.php b/DataCatalog/src/V1/UpdateTagTemplateFieldRequest.php index d3a1ba712767..2886ab41f940 100644 --- a/DataCatalog/src/V1/UpdateTagTemplateFieldRequest.php +++ b/DataCatalog/src/V1/UpdateTagTemplateFieldRequest.php @@ -21,13 +21,13 @@ class UpdateTagTemplateFieldRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The template to update. * * Generated from protobuf field .google.cloud.datacatalog.v1.TagTemplateField tag_template_field = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $tag_template_field = null; + protected $tag_template_field = null; /** * Optional. Names of fields whose values to overwrite on an individual field * of a tag template. The following fields are modifiable: @@ -45,7 +45,7 @@ class UpdateTagTemplateFieldRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $update_mask = null; + protected $update_mask = null; /** * @param string $name Required. The name of the tag template field. Please see diff --git a/DataCatalog/src/V1/UpdateTagTemplateRequest.php b/DataCatalog/src/V1/UpdateTagTemplateRequest.php index 9d4df844a8a0..8fe3da4bcd3b 100644 --- a/DataCatalog/src/V1/UpdateTagTemplateRequest.php +++ b/DataCatalog/src/V1/UpdateTagTemplateRequest.php @@ -21,7 +21,7 @@ class UpdateTagTemplateRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.TagTemplate tag_template = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $tag_template = null; + protected $tag_template = null; /** * Names of fields whose values to overwrite on a tag template. Currently, * only `display_name` and `is_publicly_readable` can be overwritten. @@ -33,7 +33,7 @@ class UpdateTagTemplateRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\DataCatalog\V1\TagTemplate $tagTemplate Required. The template to update. The `name` field must be set. diff --git a/DataCatalog/src/V1/UpdateTaxonomyRequest.php b/DataCatalog/src/V1/UpdateTaxonomyRequest.php index 59def9783fd5..ce0a2830e873 100644 --- a/DataCatalog/src/V1/UpdateTaxonomyRequest.php +++ b/DataCatalog/src/V1/UpdateTaxonomyRequest.php @@ -22,7 +22,7 @@ class UpdateTaxonomyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.Taxonomy taxonomy = 1; */ - private $taxonomy = null; + protected $taxonomy = null; /** * Specifies fields to update. If not set, defaults to all fields you can * update. @@ -31,7 +31,7 @@ class UpdateTaxonomyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\DataCatalog\V1\Taxonomy $taxonomy The taxonomy to update. You can update only its description, display name, diff --git a/DataCatalog/src/V1/UsageSignal.php b/DataCatalog/src/V1/UsageSignal.php index a8a07c279312..55f5ad1161dd 100644 --- a/DataCatalog/src/V1/UsageSignal.php +++ b/DataCatalog/src/V1/UsageSignal.php @@ -22,7 +22,7 @@ class UsageSignal extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp update_time = 1; */ - private $update_time = null; + protected $update_time = null; /** * Output only. BigQuery usage statistics over each of the predefined time * ranges. @@ -43,7 +43,7 @@ class UsageSignal extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional int64 favorite_count = 4; */ - private $favorite_count = null; + protected $favorite_count = null; /** * Constructor. diff --git a/DataCatalog/src/V1/UsageStats.php b/DataCatalog/src/V1/UsageStats.php index 5a4c4782ba48..c98875850054 100644 --- a/DataCatalog/src/V1/UsageStats.php +++ b/DataCatalog/src/V1/UsageStats.php @@ -27,25 +27,25 @@ class UsageStats extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float total_completions = 1; */ - private $total_completions = 0.0; + protected $total_completions = 0.0; /** * The number of failed attempts to use the underlying entry. * * Generated from protobuf field float total_failures = 2; */ - private $total_failures = 0.0; + protected $total_failures = 0.0; /** * The number of cancelled attempts to use the underlying entry. * * Generated from protobuf field float total_cancellations = 3; */ - private $total_cancellations = 0.0; + protected $total_cancellations = 0.0; /** * Total time spent only on successful uses, in milliseconds. * * Generated from protobuf field float total_execution_time_for_completions_millis = 4; */ - private $total_execution_time_for_completions_millis = 0.0; + protected $total_execution_time_for_completions_millis = 0.0; /** * Constructor. diff --git a/DataCatalog/src/V1/VertexDatasetSpec.php b/DataCatalog/src/V1/VertexDatasetSpec.php index 195e4d454b88..e81f1f14226e 100644 --- a/DataCatalog/src/V1/VertexDatasetSpec.php +++ b/DataCatalog/src/V1/VertexDatasetSpec.php @@ -21,13 +21,13 @@ class VertexDatasetSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 data_item_count = 1; */ - private $data_item_count = 0; + protected $data_item_count = 0; /** * Type of the dataset. * * Generated from protobuf field .google.cloud.datacatalog.v1.VertexDatasetSpec.DataType data_type = 2; */ - private $data_type = 0; + protected $data_type = 0; /** * Constructor. diff --git a/DataCatalog/src/V1/VertexDatasetSpec/DataType.php b/DataCatalog/src/V1/VertexDatasetSpec/DataType.php index a5372cf15e3b..9fea122ae162 100644 --- a/DataCatalog/src/V1/VertexDatasetSpec/DataType.php +++ b/DataCatalog/src/V1/VertexDatasetSpec/DataType.php @@ -133,6 +133,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(DataType::class, \Google\Cloud\DataCatalog\V1\VertexDatasetSpec_DataType::class); diff --git a/DataCatalog/src/V1/VertexModelSourceInfo.php b/DataCatalog/src/V1/VertexModelSourceInfo.php index db2931341998..276df35d3029 100644 --- a/DataCatalog/src/V1/VertexModelSourceInfo.php +++ b/DataCatalog/src/V1/VertexModelSourceInfo.php @@ -20,7 +20,7 @@ class VertexModelSourceInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.datacatalog.v1.VertexModelSourceInfo.ModelSourceType source_type = 1; */ - private $source_type = 0; + protected $source_type = 0; /** * If this Model is copy of another Model. If true then * [source_type][google.cloud.datacatalog.v1.VertexModelSourceInfo.source_type] @@ -28,7 +28,7 @@ class VertexModelSourceInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool copy = 2; */ - private $copy = false; + protected $copy = false; /** * Constructor. diff --git a/DataCatalog/src/V1/VertexModelSourceInfo/ModelSourceType.php b/DataCatalog/src/V1/VertexModelSourceInfo/ModelSourceType.php index 7b0e1d42765c..0ce91412da8a 100644 --- a/DataCatalog/src/V1/VertexModelSourceInfo/ModelSourceType.php +++ b/DataCatalog/src/V1/VertexModelSourceInfo/ModelSourceType.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ModelSourceType::class, \Google\Cloud\DataCatalog\V1\VertexModelSourceInfo_ModelSourceType::class); diff --git a/DataCatalog/src/V1/VertexModelSpec.php b/DataCatalog/src/V1/VertexModelSpec.php index 431b02b4abfc..649d11443130 100644 --- a/DataCatalog/src/V1/VertexModelSpec.php +++ b/DataCatalog/src/V1/VertexModelSpec.php @@ -20,7 +20,7 @@ class VertexModelSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string version_id = 1; */ - private $version_id = ''; + protected $version_id = ''; /** * User provided version aliases so that a model version can be referenced via * alias @@ -33,20 +33,20 @@ class VertexModelSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string version_description = 3; */ - private $version_description = ''; + protected $version_description = ''; /** * Source of a Vertex model. * * Generated from protobuf field .google.cloud.datacatalog.v1.VertexModelSourceInfo vertex_model_source_info = 4; */ - private $vertex_model_source_info = null; + protected $vertex_model_source_info = null; /** * URI of the Docker image to be used as the custom container for serving * predictions. * * Generated from protobuf field string container_image_uri = 5; */ - private $container_image_uri = ''; + protected $container_image_uri = ''; /** * Constructor. diff --git a/DataCatalog/src/V1/ViewSpec.php b/DataCatalog/src/V1/ViewSpec.php index 0c8775f1d703..644575cef61f 100644 --- a/DataCatalog/src/V1/ViewSpec.php +++ b/DataCatalog/src/V1/ViewSpec.php @@ -20,7 +20,7 @@ class ViewSpec extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string view_query = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $view_query = ''; + protected $view_query = ''; /** * Constructor. diff --git a/DataCatalog/tests/Unit/V1/Client/DataCatalogClientTest.php b/DataCatalog/tests/Unit/V1/Client/DataCatalogClientTest.php index 4ca2efaf6725..ce241156d6d4 100644 --- a/DataCatalog/tests/Unit/V1/Client/DataCatalogClientTest.php +++ b/DataCatalog/tests/Unit/V1/Client/DataCatalogClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return DataCatalogClient */ @@ -178,12 +180,15 @@ public function createEntryExceptionTest() $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); + $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); @@ -226,9 +231,7 @@ public function createEntryGroupTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $entryGroupId = 'entryGroupId-43122680'; - $request = (new CreateEntryGroupRequest()) - ->setParent($formattedParent) - ->setEntryGroupId($entryGroupId); + $request = (new CreateEntryGroupRequest())->setParent($formattedParent)->setEntryGroupId($entryGroupId); $response = $gapicClient->createEntryGroup($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -254,19 +257,20 @@ public function createEntryGroupExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); $entryGroupId = 'entryGroupId-43122680'; - $request = (new CreateEntryGroupRequest()) - ->setParent($formattedParent) - ->setEntryGroupId($entryGroupId); + $request = (new CreateEntryGroupRequest())->setParent($formattedParent)->setEntryGroupId($entryGroupId); try { $gapicClient->createEntryGroup($request); // If the $gapicClient method call did not throw, fail the test @@ -309,9 +313,7 @@ public function createTagTest() 'fieldsKey' => $fieldsValue, ]; $tag->setFields($tagFields); - $request = (new CreateTagRequest()) - ->setParent($formattedParent) - ->setTag($tag); + $request = (new CreateTagRequest())->setParent($formattedParent)->setTag($tag); $response = $gapicClient->createTag($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -337,12 +339,15 @@ public function createTagExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); @@ -354,9 +359,7 @@ public function createTagExceptionTest() 'fieldsKey' => $fieldsValue, ]; $tag->setFields($tagFields); - $request = (new CreateTagRequest()) - ->setParent($formattedParent) - ->setTag($tag); + $request = (new CreateTagRequest())->setParent($formattedParent)->setTag($tag); try { $gapicClient->createTag($request); // If the $gapicClient method call did not throw, fail the test @@ -429,12 +432,15 @@ public function createTagTemplateExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -522,12 +528,15 @@ public function createTagTemplateFieldExceptionTest() $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); + $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->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); @@ -565,8 +574,7 @@ public function deleteEntryTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new DeleteEntryRequest()) - ->setName($formattedName); + $request = (new DeleteEntryRequest())->setName($formattedName); $gapicClient->deleteEntry($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -589,17 +597,19 @@ public function deleteEntryExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new DeleteEntryRequest()) - ->setName($formattedName); + $request = (new DeleteEntryRequest())->setName($formattedName); try { $gapicClient->deleteEntry($request); // If the $gapicClient method call did not throw, fail the test @@ -626,8 +636,7 @@ public function deleteEntryGroupTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $request = (new DeleteEntryGroupRequest()) - ->setName($formattedName); + $request = (new DeleteEntryGroupRequest())->setName($formattedName); $gapicClient->deleteEntryGroup($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -650,17 +659,19 @@ public function deleteEntryGroupExceptionTest() $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); + $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $request = (new DeleteEntryGroupRequest()) - ->setName($formattedName); + $request = (new DeleteEntryGroupRequest())->setName($formattedName); try { $gapicClient->deleteEntryGroup($request); // If the $gapicClient method call did not throw, fail the test @@ -687,8 +698,7 @@ public function deleteTagTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new DeleteTagRequest()) - ->setName($formattedName); + $request = (new DeleteTagRequest())->setName($formattedName); $gapicClient->deleteTag($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -711,17 +721,19 @@ public function deleteTagExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new DeleteTagRequest()) - ->setName($formattedName); + $request = (new DeleteTagRequest())->setName($formattedName); try { $gapicClient->deleteTag($request); // If the $gapicClient method call did not throw, fail the test @@ -749,9 +761,7 @@ public function deleteTagTemplateTest() // Mock request $formattedName = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); $force = false; - $request = (new DeleteTagTemplateRequest()) - ->setName($formattedName) - ->setForce($force); + $request = (new DeleteTagTemplateRequest())->setName($formattedName)->setForce($force); $gapicClient->deleteTagTemplate($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -776,19 +786,20 @@ public function deleteTagTemplateExceptionTest() $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); + $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->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); $force = false; - $request = (new DeleteTagTemplateRequest()) - ->setName($formattedName) - ->setForce($force); + $request = (new DeleteTagTemplateRequest())->setName($formattedName)->setForce($force); try { $gapicClient->deleteTagTemplate($request); // If the $gapicClient method call did not throw, fail the test @@ -816,9 +827,7 @@ public function deleteTagTemplateFieldTest() // Mock request $formattedName = $gapicClient->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); $force = false; - $request = (new DeleteTagTemplateFieldRequest()) - ->setName($formattedName) - ->setForce($force); + $request = (new DeleteTagTemplateFieldRequest())->setName($formattedName)->setForce($force); $gapicClient->deleteTagTemplateField($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -843,19 +852,20 @@ public function deleteTagTemplateFieldExceptionTest() $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); + $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->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); $force = false; - $request = (new DeleteTagTemplateFieldRequest()) - ->setName($formattedName) - ->setForce($force); + $request = (new DeleteTagTemplateFieldRequest())->setName($formattedName)->setForce($force); try { $gapicClient->deleteTagTemplateField($request); // If the $gapicClient method call did not throw, fail the test @@ -896,8 +906,7 @@ public function getEntryTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new GetEntryRequest()) - ->setName($formattedName); + $request = (new GetEntryRequest())->setName($formattedName); $response = $gapicClient->getEntry($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -921,17 +930,19 @@ public function getEntryExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new GetEntryRequest()) - ->setName($formattedName); + $request = (new GetEntryRequest())->setName($formattedName); try { $gapicClient->getEntry($request); // If the $gapicClient method call did not throw, fail the test @@ -964,8 +975,7 @@ public function getEntryGroupTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $request = (new GetEntryGroupRequest()) - ->setName($formattedName); + $request = (new GetEntryGroupRequest())->setName($formattedName); $response = $gapicClient->getEntryGroup($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -989,17 +999,19 @@ public function getEntryGroupExceptionTest() $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); + $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $request = (new GetEntryGroupRequest()) - ->setName($formattedName); + $request = (new GetEntryGroupRequest())->setName($formattedName); try { $gapicClient->getEntryGroup($request); // If the $gapicClient method call did not throw, fail the test @@ -1030,8 +1042,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1055,17 +1066,19 @@ public function getIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -1098,8 +1111,7 @@ public function getTagTemplateTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $request = (new GetTagTemplateRequest()) - ->setName($formattedName); + $request = (new GetTagTemplateRequest())->setName($formattedName); $response = $gapicClient->getTagTemplate($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1123,17 +1135,19 @@ public function getTagTemplateExceptionTest() $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); + $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->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $request = (new GetTagTemplateRequest()) - ->setName($formattedName); + $request = (new GetTagTemplateRequest())->setName($formattedName); try { $gapicClient->getTagTemplate($request); // If the $gapicClient method call did not throw, fail the test @@ -1182,8 +1196,7 @@ public function importEntriesTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $request = (new ImportEntriesRequest()) - ->setParent($formattedParent); + $request = (new ImportEntriesRequest())->setParent($formattedParent); $response = $gapicClient->importEntries($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1239,17 +1252,19 @@ public function importEntriesExceptionTest() $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); + $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $request = (new ImportEntriesRequest()) - ->setParent($formattedParent); + $request = (new ImportEntriesRequest())->setParent($formattedParent); $response = $gapicClient->importEntries($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1283,17 +1298,14 @@ public function listEntriesTest() // Mock response $nextPageToken = ''; $entriesElement = new Entry(); - $entries = [ - $entriesElement, - ]; + $entries = [$entriesElement]; $expectedResponse = new ListEntriesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setEntries($entries); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $request = (new ListEntriesRequest()) - ->setParent($formattedParent); + $request = (new ListEntriesRequest())->setParent($formattedParent); $response = $gapicClient->listEntries($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1320,17 +1332,19 @@ public function listEntriesExceptionTest() $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); + $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $request = (new ListEntriesRequest()) - ->setParent($formattedParent); + $request = (new ListEntriesRequest())->setParent($formattedParent); try { $gapicClient->listEntries($request); // If the $gapicClient method call did not throw, fail the test @@ -1355,17 +1369,14 @@ public function listEntryGroupsTest() // Mock response $nextPageToken = ''; $entryGroupsElement = new EntryGroup(); - $entryGroups = [ - $entryGroupsElement, - ]; + $entryGroups = [$entryGroupsElement]; $expectedResponse = new ListEntryGroupsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setEntryGroups($entryGroups); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListEntryGroupsRequest()) - ->setParent($formattedParent); + $request = (new ListEntryGroupsRequest())->setParent($formattedParent); $response = $gapicClient->listEntryGroups($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1392,17 +1403,19 @@ public function listEntryGroupsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListEntryGroupsRequest()) - ->setParent($formattedParent); + $request = (new ListEntryGroupsRequest())->setParent($formattedParent); try { $gapicClient->listEntryGroups($request); // If the $gapicClient method call did not throw, fail the test @@ -1427,17 +1440,14 @@ public function listTagsTest() // Mock response $nextPageToken = ''; $tagsElement = new Tag(); - $tags = [ - $tagsElement, - ]; + $tags = [$tagsElement]; $expectedResponse = new ListTagsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setTags($tags); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new ListTagsRequest()) - ->setParent($formattedParent); + $request = (new ListTagsRequest())->setParent($formattedParent); $response = $gapicClient->listTags($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1464,17 +1474,19 @@ public function listTagsExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new ListTagsRequest()) - ->setParent($formattedParent); + $request = (new ListTagsRequest())->setParent($formattedParent); try { $gapicClient->listTags($request); // If the $gapicClient method call did not throw, fail the test @@ -1535,12 +1547,15 @@ public function lookupEntryExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new LookupEntryRequest(); try { @@ -1570,9 +1585,7 @@ public function modifyEntryContactsTest() // Mock request $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); $contacts = new Contacts(); - $request = (new ModifyEntryContactsRequest()) - ->setName($formattedName) - ->setContacts($contacts); + $request = (new ModifyEntryContactsRequest())->setName($formattedName)->setContacts($contacts); $response = $gapicClient->modifyEntryContacts($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1598,19 +1611,20 @@ public function modifyEntryContactsExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); $contacts = new Contacts(); - $request = (new ModifyEntryContactsRequest()) - ->setName($formattedName) - ->setContacts($contacts); + $request = (new ModifyEntryContactsRequest())->setName($formattedName)->setContacts($contacts); try { $gapicClient->modifyEntryContacts($request); // If the $gapicClient method call did not throw, fail the test @@ -1640,9 +1654,7 @@ public function modifyEntryOverviewTest() // Mock request $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); $entryOverview = new EntryOverview(); - $request = (new ModifyEntryOverviewRequest()) - ->setName($formattedName) - ->setEntryOverview($entryOverview); + $request = (new ModifyEntryOverviewRequest())->setName($formattedName)->setEntryOverview($entryOverview); $response = $gapicClient->modifyEntryOverview($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1668,19 +1680,20 @@ public function modifyEntryOverviewExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); $entryOverview = new EntryOverview(); - $request = (new ModifyEntryOverviewRequest()) - ->setName($formattedName) - ->setEntryOverview($entryOverview); + $request = (new ModifyEntryOverviewRequest())->setName($formattedName)->setEntryOverview($entryOverview); try { $gapicClient->modifyEntryOverview($request); // If the $gapicClient method call did not throw, fail the test @@ -1732,9 +1745,7 @@ public function reconcileTagsTest() // Mock request $formattedParent = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); $formattedTagTemplate = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $request = (new ReconcileTagsRequest()) - ->setParent($formattedParent) - ->setTagTemplate($formattedTagTemplate); + $request = (new ReconcileTagsRequest())->setParent($formattedParent)->setTagTemplate($formattedTagTemplate); $response = $gapicClient->reconcileTags($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1792,19 +1803,20 @@ public function reconcileTagsExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); $formattedTagTemplate = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $request = (new ReconcileTagsRequest()) - ->setParent($formattedParent) - ->setTagTemplate($formattedTagTemplate); + $request = (new ReconcileTagsRequest())->setParent($formattedParent)->setTagTemplate($formattedTagTemplate); $response = $gapicClient->reconcileTags($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1879,12 +1891,15 @@ public function renameTagTemplateFieldExceptionTest() $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); + $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->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); @@ -1927,7 +1942,13 @@ public function renameTagTemplateFieldEnumValueTest() $expectedResponse->setOrder($order); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->tagTemplateFieldEnumValueName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[TAG_TEMPLATE_FIELD_ID]', '[ENUM_VALUE_DISPLAY_NAME]'); + $formattedName = $gapicClient->tagTemplateFieldEnumValueName( + '[PROJECT]', + '[LOCATION]', + '[TAG_TEMPLATE]', + '[TAG_TEMPLATE_FIELD_ID]', + '[ENUM_VALUE_DISPLAY_NAME]' + ); $newEnumValueDisplayName = 'newEnumValueDisplayName2138960469'; $request = (new RenameTagTemplateFieldEnumValueRequest()) ->setName($formattedName) @@ -1957,15 +1978,24 @@ public function renameTagTemplateFieldEnumValueExceptionTest() $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); + $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->tagTemplateFieldEnumValueName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[TAG_TEMPLATE_FIELD_ID]', '[ENUM_VALUE_DISPLAY_NAME]'); + $formattedName = $gapicClient->tagTemplateFieldEnumValueName( + '[PROJECT]', + '[LOCATION]', + '[TAG_TEMPLATE]', + '[TAG_TEMPLATE_FIELD_ID]', + '[ENUM_VALUE_DISPLAY_NAME]' + ); $newEnumValueDisplayName = 'newEnumValueDisplayName2138960469'; $request = (new RenameTagTemplateFieldEnumValueRequest()) ->setName($formattedName) @@ -1995,9 +2025,7 @@ public function searchCatalogTest() $totalSize = 705419236; $nextPageToken = ''; $resultsElement = new SearchCatalogResult(); - $results = [ - $resultsElement, - ]; + $results = [$resultsElement]; $expectedResponse = new SearchCatalogResponse(); $expectedResponse->setTotalSize($totalSize); $expectedResponse->setNextPageToken($nextPageToken); @@ -2006,9 +2034,7 @@ public function searchCatalogTest() // Mock request $scope = new Scope(); $query = 'query107944136'; - $request = (new SearchCatalogRequest()) - ->setScope($scope) - ->setQuery($query); + $request = (new SearchCatalogRequest())->setScope($scope)->setQuery($query); $response = $gapicClient->searchCatalog($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2037,19 +2063,20 @@ public function searchCatalogExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $scope = new Scope(); $query = 'query107944136'; - $request = (new SearchCatalogRequest()) - ->setScope($scope) - ->setQuery($query); + $request = (new SearchCatalogRequest())->setScope($scope)->setQuery($query); try { $gapicClient->searchCatalog($request); // If the $gapicClient method call did not throw, fail the test @@ -2081,9 +2108,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2109,19 +2134,20 @@ public function setIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -2148,8 +2174,7 @@ public function starEntryTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new StarEntryRequest()) - ->setName($formattedName); + $request = (new StarEntryRequest())->setName($formattedName); $response = $gapicClient->starEntry($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2173,17 +2198,19 @@ public function starEntryExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new StarEntryRequest()) - ->setName($formattedName); + $request = (new StarEntryRequest())->setName($formattedName); try { $gapicClient->starEntry($request); // If the $gapicClient method call did not throw, fail the test @@ -2211,9 +2238,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2239,19 +2264,20 @@ public function testIamPermissionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -2278,8 +2304,7 @@ public function unstarEntryTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new UnstarEntryRequest()) - ->setName($formattedName); + $request = (new UnstarEntryRequest())->setName($formattedName); $response = $gapicClient->unstarEntry($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2303,17 +2328,19 @@ public function unstarEntryExceptionTest() $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); + $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $request = (new UnstarEntryRequest()) - ->setName($formattedName); + $request = (new UnstarEntryRequest())->setName($formattedName); try { $gapicClient->unstarEntry($request); // If the $gapicClient method call did not throw, fail the test @@ -2354,8 +2381,7 @@ public function updateEntryTest() $transport->addResponse($expectedResponse); // Mock request $entry = new Entry(); - $request = (new UpdateEntryRequest()) - ->setEntry($entry); + $request = (new UpdateEntryRequest())->setEntry($entry); $response = $gapicClient->updateEntry($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2379,17 +2405,19 @@ public function updateEntryExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $entry = new Entry(); - $request = (new UpdateEntryRequest()) - ->setEntry($entry); + $request = (new UpdateEntryRequest())->setEntry($entry); try { $gapicClient->updateEntry($request); // If the $gapicClient method call did not throw, fail the test @@ -2422,8 +2450,7 @@ public function updateEntryGroupTest() $transport->addResponse($expectedResponse); // Mock request $entryGroup = new EntryGroup(); - $request = (new UpdateEntryGroupRequest()) - ->setEntryGroup($entryGroup); + $request = (new UpdateEntryGroupRequest())->setEntryGroup($entryGroup); $response = $gapicClient->updateEntryGroup($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2447,17 +2474,19 @@ public function updateEntryGroupExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $entryGroup = new EntryGroup(); - $request = (new UpdateEntryGroupRequest()) - ->setEntryGroup($entryGroup); + $request = (new UpdateEntryGroupRequest())->setEntryGroup($entryGroup); try { $gapicClient->updateEntryGroup($request); // If the $gapicClient method call did not throw, fail the test @@ -2499,8 +2528,7 @@ public function updateTagTest() 'fieldsKey' => $fieldsValue, ]; $tag->setFields($tagFields); - $request = (new UpdateTagRequest()) - ->setTag($tag); + $request = (new UpdateTagRequest())->setTag($tag); $response = $gapicClient->updateTag($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2524,12 +2552,15 @@ public function updateTagExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $tag = new Tag(); @@ -2540,8 +2571,7 @@ public function updateTagExceptionTest() 'fieldsKey' => $fieldsValue, ]; $tag->setFields($tagFields); - $request = (new UpdateTagRequest()) - ->setTag($tag); + $request = (new UpdateTagRequest())->setTag($tag); try { $gapicClient->updateTag($request); // If the $gapicClient method call did not throw, fail the test @@ -2581,8 +2611,7 @@ public function updateTagTemplateTest() 'fieldsKey' => $fieldsValue, ]; $tagTemplate->setFields($tagTemplateFields); - $request = (new UpdateTagTemplateRequest()) - ->setTagTemplate($tagTemplate); + $request = (new UpdateTagTemplateRequest())->setTagTemplate($tagTemplate); $response = $gapicClient->updateTagTemplate($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2606,12 +2635,15 @@ public function updateTagTemplateExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $tagTemplate = new TagTemplate(); @@ -2622,8 +2654,7 @@ public function updateTagTemplateExceptionTest() 'fieldsKey' => $fieldsValue, ]; $tagTemplate->setFields($tagTemplateFields); - $request = (new UpdateTagTemplateRequest()) - ->setTagTemplate($tagTemplate); + $request = (new UpdateTagTemplateRequest())->setTagTemplate($tagTemplate); try { $gapicClient->updateTagTemplate($request); // If the $gapicClient method call did not throw, fail the test @@ -2691,12 +2722,15 @@ public function updateTagTemplateFieldExceptionTest() $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); + $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->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); diff --git a/DataCatalog/tests/Unit/V1/Client/PolicyTagManagerClientTest.php b/DataCatalog/tests/Unit/V1/Client/PolicyTagManagerClientTest.php index 45dd9eece522..21d668985584 100644 --- a/DataCatalog/tests/Unit/V1/Client/PolicyTagManagerClientTest.php +++ b/DataCatalog/tests/Unit/V1/Client/PolicyTagManagerClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return PolicyTagManagerClient */ @@ -99,8 +101,7 @@ public function createPolicyTagTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new CreatePolicyTagRequest()) - ->setParent($formattedParent); + $request = (new CreatePolicyTagRequest())->setParent($formattedParent); $response = $gapicClient->createPolicyTag($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -124,17 +125,19 @@ public function createPolicyTagExceptionTest() $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); + $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new CreatePolicyTagRequest()) - ->setParent($formattedParent); + $request = (new CreatePolicyTagRequest())->setParent($formattedParent); try { $gapicClient->createPolicyTag($request); // If the $gapicClient method call did not throw, fail the test @@ -169,8 +172,7 @@ public function createTaxonomyTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new CreateTaxonomyRequest()) - ->setParent($formattedParent); + $request = (new CreateTaxonomyRequest())->setParent($formattedParent); $response = $gapicClient->createTaxonomy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -194,17 +196,19 @@ public function createTaxonomyExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new CreateTaxonomyRequest()) - ->setParent($formattedParent); + $request = (new CreateTaxonomyRequest())->setParent($formattedParent); try { $gapicClient->createTaxonomy($request); // If the $gapicClient method call did not throw, fail the test @@ -231,8 +235,7 @@ public function deletePolicyTagTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - $request = (new DeletePolicyTagRequest()) - ->setName($formattedName); + $request = (new DeletePolicyTagRequest())->setName($formattedName); $gapicClient->deletePolicyTag($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -255,17 +258,19 @@ public function deletePolicyTagExceptionTest() $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); + $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->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - $request = (new DeletePolicyTagRequest()) - ->setName($formattedName); + $request = (new DeletePolicyTagRequest())->setName($formattedName); try { $gapicClient->deletePolicyTag($request); // If the $gapicClient method call did not throw, fail the test @@ -292,8 +297,7 @@ public function deleteTaxonomyTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new DeleteTaxonomyRequest()) - ->setName($formattedName); + $request = (new DeleteTaxonomyRequest())->setName($formattedName); $gapicClient->deleteTaxonomy($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -316,17 +320,19 @@ public function deleteTaxonomyExceptionTest() $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); + $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new DeleteTaxonomyRequest()) - ->setName($formattedName); + $request = (new DeleteTaxonomyRequest())->setName($formattedName); try { $gapicClient->deleteTaxonomy($request); // If the $gapicClient method call did not throw, fail the test @@ -357,8 +363,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -382,17 +387,19 @@ public function getIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -427,8 +434,7 @@ public function getPolicyTagTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - $request = (new GetPolicyTagRequest()) - ->setName($formattedName); + $request = (new GetPolicyTagRequest())->setName($formattedName); $response = $gapicClient->getPolicyTag($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -452,17 +458,19 @@ public function getPolicyTagExceptionTest() $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); + $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->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - $request = (new GetPolicyTagRequest()) - ->setName($formattedName); + $request = (new GetPolicyTagRequest())->setName($formattedName); try { $gapicClient->getPolicyTag($request); // If the $gapicClient method call did not throw, fail the test @@ -497,8 +505,7 @@ public function getTaxonomyTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new GetTaxonomyRequest()) - ->setName($formattedName); + $request = (new GetTaxonomyRequest())->setName($formattedName); $response = $gapicClient->getTaxonomy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -522,17 +529,19 @@ public function getTaxonomyExceptionTest() $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); + $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new GetTaxonomyRequest()) - ->setName($formattedName); + $request = (new GetTaxonomyRequest())->setName($formattedName); try { $gapicClient->getTaxonomy($request); // If the $gapicClient method call did not throw, fail the test @@ -557,17 +566,14 @@ public function listPolicyTagsTest() // Mock response $nextPageToken = ''; $policyTagsElement = new PolicyTag(); - $policyTags = [ - $policyTagsElement, - ]; + $policyTags = [$policyTagsElement]; $expectedResponse = new ListPolicyTagsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setPolicyTags($policyTags); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new ListPolicyTagsRequest()) - ->setParent($formattedParent); + $request = (new ListPolicyTagsRequest())->setParent($formattedParent); $response = $gapicClient->listPolicyTags($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -594,17 +600,19 @@ public function listPolicyTagsExceptionTest() $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); + $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new ListPolicyTagsRequest()) - ->setParent($formattedParent); + $request = (new ListPolicyTagsRequest())->setParent($formattedParent); try { $gapicClient->listPolicyTags($request); // If the $gapicClient method call did not throw, fail the test @@ -629,17 +637,14 @@ public function listTaxonomiesTest() // Mock response $nextPageToken = ''; $taxonomiesElement = new Taxonomy(); - $taxonomies = [ - $taxonomiesElement, - ]; + $taxonomies = [$taxonomiesElement]; $expectedResponse = new ListTaxonomiesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setTaxonomies($taxonomies); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListTaxonomiesRequest()) - ->setParent($formattedParent); + $request = (new ListTaxonomiesRequest())->setParent($formattedParent); $response = $gapicClient->listTaxonomies($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -666,17 +671,19 @@ public function listTaxonomiesExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListTaxonomiesRequest()) - ->setParent($formattedParent); + $request = (new ListTaxonomiesRequest())->setParent($formattedParent); try { $gapicClient->listTaxonomies($request); // If the $gapicClient method call did not throw, fail the test @@ -708,9 +715,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -736,19 +741,20 @@ public function setIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -776,9 +782,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -804,19 +808,20 @@ public function testIamPermissionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -871,12 +876,15 @@ public function updatePolicyTagExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdatePolicyTagRequest(); try { @@ -933,12 +941,15 @@ public function updateTaxonomyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdateTaxonomyRequest(); try { @@ -975,8 +986,7 @@ public function createPolicyTagAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $request = (new CreatePolicyTagRequest()) - ->setParent($formattedParent); + $request = (new CreatePolicyTagRequest())->setParent($formattedParent); $response = $gapicClient->createPolicyTagAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); diff --git a/DataCatalog/tests/Unit/V1/Client/PolicyTagManagerSerializationClientTest.php b/DataCatalog/tests/Unit/V1/Client/PolicyTagManagerSerializationClientTest.php index a9fa090478d9..879c36aff22c 100644 --- a/DataCatalog/tests/Unit/V1/Client/PolicyTagManagerSerializationClientTest.php +++ b/DataCatalog/tests/Unit/V1/Client/PolicyTagManagerSerializationClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return PolicyTagManagerSerializationClient */ @@ -78,19 +80,18 @@ public function exportTaxonomiesTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $formattedTaxonomies = [ - $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'), - ]; - $request = (new ExportTaxonomiesRequest()) - ->setParent($formattedParent) - ->setTaxonomies($formattedTaxonomies); + $formattedTaxonomies = [$gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]')]; + $request = (new ExportTaxonomiesRequest())->setParent($formattedParent)->setTaxonomies($formattedTaxonomies); $response = $gapicClient->exportTaxonomies($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.datacatalog.v1.PolicyTagManagerSerialization/ExportTaxonomies', $actualFuncCall); + $this->assertSame( + '/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ExportTaxonomies', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getTaxonomies(); @@ -109,21 +110,20 @@ public function exportTaxonomiesExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $formattedTaxonomies = [ - $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'), - ]; - $request = (new ExportTaxonomiesRequest()) - ->setParent($formattedParent) - ->setTaxonomies($formattedTaxonomies); + $formattedTaxonomies = [$gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]')]; + $request = (new ExportTaxonomiesRequest())->setParent($formattedParent)->setTaxonomies($formattedTaxonomies); try { $gapicClient->exportTaxonomies($request); // If the $gapicClient method call did not throw, fail the test @@ -150,15 +150,17 @@ public function importTaxonomiesTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ImportTaxonomiesRequest()) - ->setParent($formattedParent); + $request = (new ImportTaxonomiesRequest())->setParent($formattedParent); $response = $gapicClient->importTaxonomies($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.datacatalog.v1.PolicyTagManagerSerialization/ImportTaxonomies', $actualFuncCall); + $this->assertSame( + '/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ImportTaxonomies', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -175,17 +177,19 @@ public function importTaxonomiesExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ImportTaxonomiesRequest()) - ->setParent($formattedParent); + $request = (new ImportTaxonomiesRequest())->setParent($formattedParent); try { $gapicClient->importTaxonomies($request); // If the $gapicClient method call did not throw, fail the test @@ -223,16 +227,17 @@ public function replaceTaxonomyTest() $serializedTaxonomy = new SerializedTaxonomy(); $serializedTaxonomyDisplayName = 'serializedTaxonomyDisplayName1493662264'; $serializedTaxonomy->setDisplayName($serializedTaxonomyDisplayName); - $request = (new ReplaceTaxonomyRequest()) - ->setName($formattedName) - ->setSerializedTaxonomy($serializedTaxonomy); + $request = (new ReplaceTaxonomyRequest())->setName($formattedName)->setSerializedTaxonomy($serializedTaxonomy); $response = $gapicClient->replaceTaxonomy($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.datacatalog.v1.PolicyTagManagerSerialization/ReplaceTaxonomy', $actualFuncCall); + $this->assertSame( + '/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ReplaceTaxonomy', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $actualValue = $actualRequestObject->getSerializedTaxonomy(); @@ -251,21 +256,22 @@ public function replaceTaxonomyExceptionTest() $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); + $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); $serializedTaxonomy = new SerializedTaxonomy(); $serializedTaxonomyDisplayName = 'serializedTaxonomyDisplayName1493662264'; $serializedTaxonomy->setDisplayName($serializedTaxonomyDisplayName); - $request = (new ReplaceTaxonomyRequest()) - ->setName($formattedName) - ->setSerializedTaxonomy($serializedTaxonomy); + $request = (new ReplaceTaxonomyRequest())->setName($formattedName)->setSerializedTaxonomy($serializedTaxonomy); try { $gapicClient->replaceTaxonomy($request); // If the $gapicClient method call did not throw, fail the test @@ -292,19 +298,18 @@ public function exportTaxonomiesAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $formattedTaxonomies = [ - $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'), - ]; - $request = (new ExportTaxonomiesRequest()) - ->setParent($formattedParent) - ->setTaxonomies($formattedTaxonomies); + $formattedTaxonomies = [$gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]')]; + $request = (new ExportTaxonomiesRequest())->setParent($formattedParent)->setTaxonomies($formattedTaxonomies); $response = $gapicClient->exportTaxonomiesAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ExportTaxonomies', $actualFuncCall); + $this->assertSame( + '/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ExportTaxonomies', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getTaxonomies(); diff --git a/DataCatalog/tests/Unit/V1/DataCatalogClientTest.php b/DataCatalog/tests/Unit/V1/DataCatalogClientTest.php deleted file mode 100644 index d4b911d39939..000000000000 --- a/DataCatalog/tests/Unit/V1/DataCatalogClientTest.php +++ /dev/null @@ -1,2515 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return DataCatalogClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new DataCatalogClient($options); - } - - /** @test */ - public function createEntryTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $linkedResource = 'linkedResource1544625012'; - $fullyQualifiedName = 'fullyQualifiedName338146659'; - $userSpecifiedType = 'userSpecifiedType-940364963'; - $userSpecifiedSystem = 'userSpecifiedSystem-1776119406'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new Entry(); - $expectedResponse->setName($name); - $expectedResponse->setLinkedResource($linkedResource); - $expectedResponse->setFullyQualifiedName($fullyQualifiedName); - $expectedResponse->setUserSpecifiedType($userSpecifiedType); - $expectedResponse->setUserSpecifiedSystem($userSpecifiedSystem); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $entryId = 'entryId-2093663224'; - $entry = new Entry(); - $response = $gapicClient->createEntry($formattedParent, $entryId, $entry); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/CreateEntry', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getEntryId(); - $this->assertProtobufEquals($entryId, $actualValue); - $actualValue = $actualRequestObject->getEntry(); - $this->assertProtobufEquals($entry, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createEntryExceptionTest() - { - $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $entryId = 'entryId-2093663224'; - $entry = new Entry(); - try { - $gapicClient->createEntry($formattedParent, $entryId, $entry); - // 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 createEntryGroupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new EntryGroup(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $entryGroupId = 'entryGroupId-43122680'; - $response = $gapicClient->createEntryGroup($formattedParent, $entryGroupId); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/CreateEntryGroup', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getEntryGroupId(); - $this->assertProtobufEquals($entryGroupId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createEntryGroupExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - $entryGroupId = 'entryGroupId-43122680'; - try { - $gapicClient->createEntryGroup($formattedParent, $entryGroupId); - // 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 createTagTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $template = 'template-1321546630'; - $templateDisplayName = 'templateDisplayName-532252787'; - $column = 'column-1354837162'; - $expectedResponse = new Tag(); - $expectedResponse->setName($name); - $expectedResponse->setTemplate($template); - $expectedResponse->setTemplateDisplayName($templateDisplayName); - $expectedResponse->setColumn($column); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $tag = new Tag(); - $tagTemplate = 'tagTemplate1678947892'; - $tag->setTemplate($tagTemplate); - $fieldsValue = new TagField(); - $tagFields = [ - 'fieldsKey' => $fieldsValue, - ]; - $tag->setFields($tagFields); - $response = $gapicClient->createTag($formattedParent, $tag); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/CreateTag', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getTag(); - $this->assertProtobufEquals($tag, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createTagExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $tag = new Tag(); - $tagTemplate = 'tagTemplate1678947892'; - $tag->setTemplate($tagTemplate); - $fieldsValue = new TagField(); - $tagFields = [ - 'fieldsKey' => $fieldsValue, - ]; - $tag->setFields($tagFields); - try { - $gapicClient->createTag($formattedParent, $tag); - // 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 createTagTemplateTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $isPubliclyReadable = true; - $expectedResponse = new TagTemplate(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsPubliclyReadable($isPubliclyReadable); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $tagTemplateId = 'tagTemplateId-2020335141'; - $tagTemplate = new TagTemplate(); - $fieldsValue = new TagTemplateField(); - $valueType = new FieldType(); - $fieldsValue->setType($valueType); - $tagTemplateFields = [ - 'fieldsKey' => $fieldsValue, - ]; - $tagTemplate->setFields($tagTemplateFields); - $response = $gapicClient->createTagTemplate($formattedParent, $tagTemplateId, $tagTemplate); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/CreateTagTemplate', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getTagTemplateId(); - $this->assertProtobufEquals($tagTemplateId, $actualValue); - $actualValue = $actualRequestObject->getTagTemplate(); - $this->assertProtobufEquals($tagTemplate, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createTagTemplateExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - $tagTemplateId = 'tagTemplateId-2020335141'; - $tagTemplate = new TagTemplate(); - $fieldsValue = new TagTemplateField(); - $valueType = new FieldType(); - $fieldsValue->setType($valueType); - $tagTemplateFields = [ - 'fieldsKey' => $fieldsValue, - ]; - $tagTemplate->setFields($tagTemplateFields); - try { - $gapicClient->createTagTemplate($formattedParent, $tagTemplateId, $tagTemplate); - // 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 createTagTemplateFieldTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $isRequired = true; - $description = 'description-1724546052'; - $order = 106006350; - $expectedResponse = new TagTemplateField(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsRequired($isRequired); - $expectedResponse->setDescription($description); - $expectedResponse->setOrder($order); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $tagTemplateFieldId = 'tagTemplateFieldId-92144832'; - $tagTemplateField = new TagTemplateField(); - $tagTemplateFieldType = new FieldType(); - $tagTemplateField->setType($tagTemplateFieldType); - $response = $gapicClient->createTagTemplateField($formattedParent, $tagTemplateFieldId, $tagTemplateField); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/CreateTagTemplateField', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getTagTemplateFieldId(); - $this->assertProtobufEquals($tagTemplateFieldId, $actualValue); - $actualValue = $actualRequestObject->getTagTemplateField(); - $this->assertProtobufEquals($tagTemplateField, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createTagTemplateFieldExceptionTest() - { - $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->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $tagTemplateFieldId = 'tagTemplateFieldId-92144832'; - $tagTemplateField = new TagTemplateField(); - $tagTemplateFieldType = new FieldType(); - $tagTemplateField->setType($tagTemplateFieldType); - try { - $gapicClient->createTagTemplateField($formattedParent, $tagTemplateFieldId, $tagTemplateField); - // 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 deleteEntryTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $gapicClient->deleteEntry($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/DeleteEntry', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteEntryExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - try { - $gapicClient->deleteEntry($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 deleteEntryGroupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $gapicClient->deleteEntryGroup($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/DeleteEntryGroup', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteEntryGroupExceptionTest() - { - $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - try { - $gapicClient->deleteEntryGroup($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 deleteTagTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $gapicClient->deleteTag($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/DeleteTag', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteTagExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - try { - $gapicClient->deleteTag($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 deleteTagTemplateTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $force = false; - $gapicClient->deleteTagTemplate($formattedName, $force); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/DeleteTagTemplate', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getForce(); - $this->assertProtobufEquals($force, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteTagTemplateExceptionTest() - { - $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->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $force = false; - try { - $gapicClient->deleteTagTemplate($formattedName, $force); - // 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 deleteTagTemplateFieldTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - $force = false; - $gapicClient->deleteTagTemplateField($formattedName, $force); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/DeleteTagTemplateField', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getForce(); - $this->assertProtobufEquals($force, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteTagTemplateFieldExceptionTest() - { - $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->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - $force = false; - try { - $gapicClient->deleteTagTemplateField($formattedName, $force); - // 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 getEntryTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $linkedResource = 'linkedResource1544625012'; - $fullyQualifiedName = 'fullyQualifiedName338146659'; - $userSpecifiedType = 'userSpecifiedType-940364963'; - $userSpecifiedSystem = 'userSpecifiedSystem-1776119406'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new Entry(); - $expectedResponse->setName($name2); - $expectedResponse->setLinkedResource($linkedResource); - $expectedResponse->setFullyQualifiedName($fullyQualifiedName); - $expectedResponse->setUserSpecifiedType($userSpecifiedType); - $expectedResponse->setUserSpecifiedSystem($userSpecifiedSystem); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $response = $gapicClient->getEntry($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.datacatalog.v1.DataCatalog/GetEntry', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getEntryExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - try { - $gapicClient->getEntry($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 getEntryGroupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new EntryGroup(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $response = $gapicClient->getEntryGroup($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.datacatalog.v1.DataCatalog/GetEntryGroup', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getEntryGroupExceptionTest() - { - $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - try { - $gapicClient->getEntryGroup($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 getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 getTagTemplateTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $isPubliclyReadable = true; - $expectedResponse = new TagTemplate(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsPubliclyReadable($isPubliclyReadable); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $response = $gapicClient->getTagTemplate($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.datacatalog.v1.DataCatalog/GetTagTemplate', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getTagTemplateExceptionTest() - { - $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->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - try { - $gapicClient->getTagTemplate($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 importEntriesTest() - { - $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/importEntriesTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $upsertedEntriesCount = 250168367; - $deletedEntriesCount = 167383302; - $expectedResponse = new ImportEntriesResponse(); - $expectedResponse->setUpsertedEntriesCount($upsertedEntriesCount); - $expectedResponse->setDeletedEntriesCount($deletedEntriesCount); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/importEntriesTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $response = $gapicClient->importEntries($formattedParent); - $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.datacatalog.v1.DataCatalog/ImportEntries', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/importEntriesTest'); - $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 importEntriesExceptionTest() - { - $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/importEntriesTest'); - $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $response = $gapicClient->importEntries($formattedParent); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/importEntriesTest'); - 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 listEntriesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $entriesElement = new Entry(); - $entries = [ - $entriesElement, - ]; - $expectedResponse = new ListEntriesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setEntries($entries); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - $response = $gapicClient->listEntries($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getEntries()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/ListEntries', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listEntriesExceptionTest() - { - $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->entryGroupName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]'); - try { - $gapicClient->listEntries($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 listEntryGroupsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $entryGroupsElement = new EntryGroup(); - $entryGroups = [ - $entryGroupsElement, - ]; - $expectedResponse = new ListEntryGroupsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setEntryGroups($entryGroups); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listEntryGroups($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getEntryGroups()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/ListEntryGroups', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listEntryGroupsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listEntryGroups($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 listTagsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $tagsElement = new Tag(); - $tags = [ - $tagsElement, - ]; - $expectedResponse = new ListTagsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setTags($tags); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $response = $gapicClient->listTags($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getTags()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/ListTags', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listTagsExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - try { - $gapicClient->listTags($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 lookupEntryTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $linkedResource2 = 'linkedResource2-1674044889'; - $fullyQualifiedName = 'fullyQualifiedName338146659'; - $userSpecifiedType = 'userSpecifiedType-940364963'; - $userSpecifiedSystem = 'userSpecifiedSystem-1776119406'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new Entry(); - $expectedResponse->setName($name); - $expectedResponse->setLinkedResource($linkedResource2); - $expectedResponse->setFullyQualifiedName($fullyQualifiedName); - $expectedResponse->setUserSpecifiedType($userSpecifiedType); - $expectedResponse->setUserSpecifiedSystem($userSpecifiedSystem); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - $response = $gapicClient->lookupEntry(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/LookupEntry', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function lookupEntryExceptionTest() - { - $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); - try { - $gapicClient->lookupEntry(); - // 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 modifyEntryContactsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new Contacts(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $contacts = new Contacts(); - $response = $gapicClient->modifyEntryContacts($formattedName, $contacts); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/ModifyEntryContacts', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getContacts(); - $this->assertProtobufEquals($contacts, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function modifyEntryContactsExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $contacts = new Contacts(); - try { - $gapicClient->modifyEntryContacts($formattedName, $contacts); - // 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 modifyEntryOverviewTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $overview = 'overview530115961'; - $expectedResponse = new EntryOverview(); - $expectedResponse->setOverview($overview); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $entryOverview = new EntryOverview(); - $response = $gapicClient->modifyEntryOverview($formattedName, $entryOverview); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/ModifyEntryOverview', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getEntryOverview(); - $this->assertProtobufEquals($entryOverview, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function modifyEntryOverviewExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $entryOverview = new EntryOverview(); - try { - $gapicClient->modifyEntryOverview($formattedName, $entryOverview); - // 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 reconcileTagsTest() - { - $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/reconcileTagsTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $createdTagsCount = 986601696; - $updatedTagsCount = 344847213; - $deletedTagsCount = 59637071; - $expectedResponse = new ReconcileTagsResponse(); - $expectedResponse->setCreatedTagsCount($createdTagsCount); - $expectedResponse->setUpdatedTagsCount($updatedTagsCount); - $expectedResponse->setDeletedTagsCount($deletedTagsCount); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/reconcileTagsTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $formattedTagTemplate = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $response = $gapicClient->reconcileTags($formattedParent, $formattedTagTemplate); - $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.datacatalog.v1.DataCatalog/ReconcileTags', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getTagTemplate(); - $this->assertProtobufEquals($formattedTagTemplate, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/reconcileTagsTest'); - $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 reconcileTagsExceptionTest() - { - $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/reconcileTagsTest'); - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $formattedTagTemplate = $gapicClient->tagTemplateName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]'); - $response = $gapicClient->reconcileTags($formattedParent, $formattedTagTemplate); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/reconcileTagsTest'); - 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 renameTagTemplateFieldTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $isRequired = true; - $description = 'description-1724546052'; - $order = 106006350; - $expectedResponse = new TagTemplateField(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsRequired($isRequired); - $expectedResponse->setDescription($description); - $expectedResponse->setOrder($order); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - $newTagTemplateFieldId = 'newTagTemplateFieldId-1668354591'; - $response = $gapicClient->renameTagTemplateField($formattedName, $newTagTemplateFieldId); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/RenameTagTemplateField', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getNewTagTemplateFieldId(); - $this->assertProtobufEquals($newTagTemplateFieldId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameTagTemplateFieldExceptionTest() - { - $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->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - $newTagTemplateFieldId = 'newTagTemplateFieldId-1668354591'; - try { - $gapicClient->renameTagTemplateField($formattedName, $newTagTemplateFieldId); - // 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 renameTagTemplateFieldEnumValueTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $isRequired = true; - $description = 'description-1724546052'; - $order = 106006350; - $expectedResponse = new TagTemplateField(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsRequired($isRequired); - $expectedResponse->setDescription($description); - $expectedResponse->setOrder($order); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tagTemplateFieldEnumValueName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[TAG_TEMPLATE_FIELD_ID]', '[ENUM_VALUE_DISPLAY_NAME]'); - $newEnumValueDisplayName = 'newEnumValueDisplayName2138960469'; - $response = $gapicClient->renameTagTemplateFieldEnumValue($formattedName, $newEnumValueDisplayName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/RenameTagTemplateFieldEnumValue', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getNewEnumValueDisplayName(); - $this->assertProtobufEquals($newEnumValueDisplayName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameTagTemplateFieldEnumValueExceptionTest() - { - $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->tagTemplateFieldEnumValueName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[TAG_TEMPLATE_FIELD_ID]', '[ENUM_VALUE_DISPLAY_NAME]'); - $newEnumValueDisplayName = 'newEnumValueDisplayName2138960469'; - try { - $gapicClient->renameTagTemplateFieldEnumValue($formattedName, $newEnumValueDisplayName); - // 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 searchCatalogTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $totalSize = 705419236; - $nextPageToken = ''; - $resultsElement = new SearchCatalogResult(); - $results = [ - $resultsElement, - ]; - $expectedResponse = new SearchCatalogResponse(); - $expectedResponse->setTotalSize($totalSize); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setResults($results); - $transport->addResponse($expectedResponse); - // Mock request - $scope = new Scope(); - $query = 'query107944136'; - $response = $gapicClient->searchCatalog($scope, $query); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getResults()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/SearchCatalog', $actualFuncCall); - $actualValue = $actualRequestObject->getScope(); - $this->assertProtobufEquals($scope, $actualValue); - $actualValue = $actualRequestObject->getQuery(); - $this->assertProtobufEquals($query, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function searchCatalogExceptionTest() - { - $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 - $scope = new Scope(); - $query = 'query107944136'; - try { - $gapicClient->searchCatalog($scope, $query); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 starEntryTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new StarEntryResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $response = $gapicClient->starEntry($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.datacatalog.v1.DataCatalog/StarEntry', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function starEntryExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - try { - $gapicClient->starEntry($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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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 unstarEntryTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new UnstarEntryResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - $response = $gapicClient->unstarEntry($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.datacatalog.v1.DataCatalog/UnstarEntry', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function unstarEntryExceptionTest() - { - $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->entryName('[PROJECT]', '[LOCATION]', '[ENTRY_GROUP]', '[ENTRY]'); - try { - $gapicClient->unstarEntry($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 updateEntryTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $linkedResource = 'linkedResource1544625012'; - $fullyQualifiedName = 'fullyQualifiedName338146659'; - $userSpecifiedType = 'userSpecifiedType-940364963'; - $userSpecifiedSystem = 'userSpecifiedSystem-1776119406'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new Entry(); - $expectedResponse->setName($name); - $expectedResponse->setLinkedResource($linkedResource); - $expectedResponse->setFullyQualifiedName($fullyQualifiedName); - $expectedResponse->setUserSpecifiedType($userSpecifiedType); - $expectedResponse->setUserSpecifiedSystem($userSpecifiedSystem); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $entry = new Entry(); - $response = $gapicClient->updateEntry($entry); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/UpdateEntry', $actualFuncCall); - $actualValue = $actualRequestObject->getEntry(); - $this->assertProtobufEquals($entry, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateEntryExceptionTest() - { - $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 - $entry = new Entry(); - try { - $gapicClient->updateEntry($entry); - // 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 updateEntryGroupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new EntryGroup(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $entryGroup = new EntryGroup(); - $response = $gapicClient->updateEntryGroup($entryGroup); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/UpdateEntryGroup', $actualFuncCall); - $actualValue = $actualRequestObject->getEntryGroup(); - $this->assertProtobufEquals($entryGroup, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateEntryGroupExceptionTest() - { - $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 - $entryGroup = new EntryGroup(); - try { - $gapicClient->updateEntryGroup($entryGroup); - // 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 updateTagTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $template = 'template-1321546630'; - $templateDisplayName = 'templateDisplayName-532252787'; - $column = 'column-1354837162'; - $expectedResponse = new Tag(); - $expectedResponse->setName($name); - $expectedResponse->setTemplate($template); - $expectedResponse->setTemplateDisplayName($templateDisplayName); - $expectedResponse->setColumn($column); - $transport->addResponse($expectedResponse); - // Mock request - $tag = new Tag(); - $tagTemplate = 'tagTemplate1678947892'; - $tag->setTemplate($tagTemplate); - $fieldsValue = new TagField(); - $tagFields = [ - 'fieldsKey' => $fieldsValue, - ]; - $tag->setFields($tagFields); - $response = $gapicClient->updateTag($tag); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/UpdateTag', $actualFuncCall); - $actualValue = $actualRequestObject->getTag(); - $this->assertProtobufEquals($tag, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateTagExceptionTest() - { - $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 - $tag = new Tag(); - $tagTemplate = 'tagTemplate1678947892'; - $tag->setTemplate($tagTemplate); - $fieldsValue = new TagField(); - $tagFields = [ - 'fieldsKey' => $fieldsValue, - ]; - $tag->setFields($tagFields); - try { - $gapicClient->updateTag($tag); - // 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 updateTagTemplateTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $isPubliclyReadable = true; - $expectedResponse = new TagTemplate(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsPubliclyReadable($isPubliclyReadable); - $transport->addResponse($expectedResponse); - // Mock request - $tagTemplate = new TagTemplate(); - $fieldsValue = new TagTemplateField(); - $valueType = new FieldType(); - $fieldsValue->setType($valueType); - $tagTemplateFields = [ - 'fieldsKey' => $fieldsValue, - ]; - $tagTemplate->setFields($tagTemplateFields); - $response = $gapicClient->updateTagTemplate($tagTemplate); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/UpdateTagTemplate', $actualFuncCall); - $actualValue = $actualRequestObject->getTagTemplate(); - $this->assertProtobufEquals($tagTemplate, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateTagTemplateExceptionTest() - { - $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 - $tagTemplate = new TagTemplate(); - $fieldsValue = new TagTemplateField(); - $valueType = new FieldType(); - $fieldsValue->setType($valueType); - $tagTemplateFields = [ - 'fieldsKey' => $fieldsValue, - ]; - $tagTemplate->setFields($tagTemplateFields); - try { - $gapicClient->updateTagTemplate($tagTemplate); - // 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 updateTagTemplateFieldTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $isRequired = true; - $description = 'description-1724546052'; - $order = 106006350; - $expectedResponse = new TagTemplateField(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsRequired($isRequired); - $expectedResponse->setDescription($description); - $expectedResponse->setOrder($order); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - $tagTemplateField = new TagTemplateField(); - $tagTemplateFieldType = new FieldType(); - $tagTemplateField->setType($tagTemplateFieldType); - $response = $gapicClient->updateTagTemplateField($formattedName, $tagTemplateField); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.DataCatalog/UpdateTagTemplateField', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getTagTemplateField(); - $this->assertProtobufEquals($tagTemplateField, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateTagTemplateFieldExceptionTest() - { - $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->tagTemplateFieldName('[PROJECT]', '[LOCATION]', '[TAG_TEMPLATE]', '[FIELD]'); - $tagTemplateField = new TagTemplateField(); - $tagTemplateFieldType = new FieldType(); - $tagTemplateField->setType($tagTemplateFieldType); - try { - $gapicClient->updateTagTemplateField($formattedName, $tagTemplateField); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/DataCatalog/tests/Unit/V1/PolicyTagManagerClientTest.php b/DataCatalog/tests/Unit/V1/PolicyTagManagerClientTest.php deleted file mode 100644 index c181c5fffa2e..000000000000 --- a/DataCatalog/tests/Unit/V1/PolicyTagManagerClientTest.php +++ /dev/null @@ -1,891 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return PolicyTagManagerClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new PolicyTagManagerClient($options); - } - - /** @test */ - public function createPolicyTagTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $parentPolicyTag = 'parentPolicyTag2071382466'; - $expectedResponse = new PolicyTag(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setParentPolicyTag($parentPolicyTag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $response = $gapicClient->createPolicyTag($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/CreatePolicyTag', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createPolicyTagExceptionTest() - { - $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - try { - $gapicClient->createPolicyTag($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 createTaxonomyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $policyTagCount = 1074340189; - $expectedResponse = new Taxonomy(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPolicyTagCount($policyTagCount); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->createTaxonomy($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/CreateTaxonomy', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createTaxonomyExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->createTaxonomy($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 deletePolicyTagTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - $gapicClient->deletePolicyTag($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/DeletePolicyTag', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deletePolicyTagExceptionTest() - { - $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->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - try { - $gapicClient->deletePolicyTag($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 deleteTaxonomyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $gapicClient->deleteTaxonomy($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/DeleteTaxonomy', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteTaxonomyExceptionTest() - { - $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - try { - $gapicClient->deleteTaxonomy($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 getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 getPolicyTagTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $parentPolicyTag = 'parentPolicyTag2071382466'; - $expectedResponse = new PolicyTag(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setParentPolicyTag($parentPolicyTag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - $response = $gapicClient->getPolicyTag($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.datacatalog.v1.PolicyTagManager/GetPolicyTag', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getPolicyTagExceptionTest() - { - $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->policyTagName('[PROJECT]', '[LOCATION]', '[TAXONOMY]', '[POLICY_TAG]'); - try { - $gapicClient->getPolicyTag($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 getTaxonomyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $policyTagCount = 1074340189; - $expectedResponse = new Taxonomy(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPolicyTagCount($policyTagCount); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $response = $gapicClient->getTaxonomy($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.datacatalog.v1.PolicyTagManager/GetTaxonomy', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getTaxonomyExceptionTest() - { - $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - try { - $gapicClient->getTaxonomy($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 listPolicyTagsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $policyTagsElement = new PolicyTag(); - $policyTags = [ - $policyTagsElement, - ]; - $expectedResponse = new ListPolicyTagsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setPolicyTags($policyTags); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $response = $gapicClient->listPolicyTags($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getPolicyTags()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/ListPolicyTags', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listPolicyTagsExceptionTest() - { - $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - try { - $gapicClient->listPolicyTags($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 listTaxonomiesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $taxonomiesElement = new Taxonomy(); - $taxonomies = [ - $taxonomiesElement, - ]; - $expectedResponse = new ListTaxonomiesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setTaxonomies($taxonomies); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listTaxonomies($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getTaxonomies()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/ListTaxonomies', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listTaxonomiesExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listTaxonomies($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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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 updatePolicyTagTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $parentPolicyTag = 'parentPolicyTag2071382466'; - $expectedResponse = new PolicyTag(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setParentPolicyTag($parentPolicyTag); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updatePolicyTag(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/UpdatePolicyTag', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updatePolicyTagExceptionTest() - { - $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); - try { - $gapicClient->updatePolicyTag(); - // 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 updateTaxonomyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $policyTagCount = 1074340189; - $expectedResponse = new Taxonomy(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPolicyTagCount($policyTagCount); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateTaxonomy(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManager/UpdateTaxonomy', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateTaxonomyExceptionTest() - { - $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); - try { - $gapicClient->updateTaxonomy(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/DataCatalog/tests/Unit/V1/PolicyTagManagerSerializationClientTest.php b/DataCatalog/tests/Unit/V1/PolicyTagManagerSerializationClientTest.php deleted file mode 100644 index 1fceafeaa666..000000000000 --- a/DataCatalog/tests/Unit/V1/PolicyTagManagerSerializationClientTest.php +++ /dev/null @@ -1,262 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return PolicyTagManagerSerializationClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new PolicyTagManagerSerializationClient($options); - } - - /** @test */ - public function exportTaxonomiesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ExportTaxonomiesResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $formattedTaxonomies = [ - $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'), - ]; - $response = $gapicClient->exportTaxonomies($formattedParent, $formattedTaxonomies); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ExportTaxonomies', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getTaxonomies(); - $this->assertProtobufEquals($formattedTaxonomies, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function exportTaxonomiesExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - $formattedTaxonomies = [ - $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'), - ]; - try { - $gapicClient->exportTaxonomies($formattedParent, $formattedTaxonomies); - // 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 importTaxonomiesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ImportTaxonomiesResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->importTaxonomies($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ImportTaxonomies', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function importTaxonomiesExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->importTaxonomies($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 replaceTaxonomyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $policyTagCount = 1074340189; - $expectedResponse = new Taxonomy(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPolicyTagCount($policyTagCount); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $serializedTaxonomy = new SerializedTaxonomy(); - $serializedTaxonomyDisplayName = 'serializedTaxonomyDisplayName1493662264'; - $serializedTaxonomy->setDisplayName($serializedTaxonomyDisplayName); - $response = $gapicClient->replaceTaxonomy($formattedName, $serializedTaxonomy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.datacatalog.v1.PolicyTagManagerSerialization/ReplaceTaxonomy', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getSerializedTaxonomy(); - $this->assertProtobufEquals($serializedTaxonomy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function replaceTaxonomyExceptionTest() - { - $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->taxonomyName('[PROJECT]', '[LOCATION]', '[TAXONOMY]'); - $serializedTaxonomy = new SerializedTaxonomy(); - $serializedTaxonomyDisplayName = 'serializedTaxonomyDisplayName1493662264'; - $serializedTaxonomy->setDisplayName($serializedTaxonomyDisplayName); - try { - $gapicClient->replaceTaxonomy($formattedName, $serializedTaxonomy); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/Dms/owlbot.py b/Dms/owlbot.py index 831213e3c2e7..01b0836f603d 100644 --- a/Dms/owlbot.py +++ b/Dms/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,28 +41,16 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/Dms/src/V1/AlloyDbConnectionProfile.php b/Dms/src/V1/AlloyDbConnectionProfile.php index b63c8b6c99c6..99f46bc7a6a7 100644 --- a/Dms/src/V1/AlloyDbConnectionProfile.php +++ b/Dms/src/V1/AlloyDbConnectionProfile.php @@ -22,13 +22,13 @@ class AlloyDbConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cluster_id = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $cluster_id = ''; + protected $cluster_id = ''; /** * Immutable. Metadata used to create the destination AlloyDB cluster. * * Generated from protobuf field .google.cloud.clouddms.v1.AlloyDbSettings settings = 2 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $settings = null; + protected $settings = null; /** * Constructor. diff --git a/Dms/src/V1/AlloyDbSettings.php b/Dms/src/V1/AlloyDbSettings.php index bea3bb953803..3b45778053b8 100644 --- a/Dms/src/V1/AlloyDbSettings.php +++ b/Dms/src/V1/AlloyDbSettings.php @@ -21,7 +21,7 @@ class AlloyDbSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.AlloyDbSettings.UserPassword initial_user = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = INPUT_ONLY]; */ - private $initial_user = null; + protected $initial_user = null; /** * Required. The resource link for the VPC network in which cluster resources * are created and from which they are accessible via Private IP. The network @@ -31,7 +31,7 @@ class AlloyDbSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vpc_network = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $vpc_network = ''; + protected $vpc_network = ''; /** * Labels for the AlloyDB cluster created by DMS. An object containing a list * of 'key', 'value' pairs. @@ -42,7 +42,7 @@ class AlloyDbSettings extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field .google.cloud.clouddms.v1.AlloyDbSettings.PrimaryInstanceSettings primary_instance_settings = 4; */ - private $primary_instance_settings = null; + protected $primary_instance_settings = null; /** * Optional. The encryption config can be specified to encrypt the data disks * and other persistent data resources of a cluster with a @@ -52,7 +52,7 @@ class AlloyDbSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.AlloyDbSettings.EncryptionConfig encryption_config = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $encryption_config = null; + protected $encryption_config = null; /** * Constructor. diff --git a/Dms/src/V1/AlloyDbSettings/EncryptionConfig.php b/Dms/src/V1/AlloyDbSettings/EncryptionConfig.php index 2e1b1accc7ab..d4e1a79708f6 100644 --- a/Dms/src/V1/AlloyDbSettings/EncryptionConfig.php +++ b/Dms/src/V1/AlloyDbSettings/EncryptionConfig.php @@ -23,7 +23,7 @@ class EncryptionConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string kms_key_name = 1; */ - private $kms_key_name = ''; + protected $kms_key_name = ''; /** * Constructor. diff --git a/Dms/src/V1/AlloyDbSettings/PrimaryInstanceSettings.php b/Dms/src/V1/AlloyDbSettings/PrimaryInstanceSettings.php index 25865f49e8e7..cded65b81e2f 100644 --- a/Dms/src/V1/AlloyDbSettings/PrimaryInstanceSettings.php +++ b/Dms/src/V1/AlloyDbSettings/PrimaryInstanceSettings.php @@ -21,14 +21,14 @@ class PrimaryInstanceSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $id = ''; + protected $id = ''; /** * Configuration for the machines that host the underlying * database engine. * * Generated from protobuf field .google.cloud.clouddms.v1.AlloyDbSettings.PrimaryInstanceSettings.MachineConfig machine_config = 2; */ - private $machine_config = null; + protected $machine_config = null; /** * Database flags to pass to AlloyDB when DMS is creating the AlloyDB * cluster and instances. See the AlloyDB documentation for how these can be @@ -50,7 +50,7 @@ class PrimaryInstanceSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string private_ip = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $private_ip = ''; + protected $private_ip = ''; /** * Constructor. diff --git a/Dms/src/V1/AlloyDbSettings/PrimaryInstanceSettings/MachineConfig.php b/Dms/src/V1/AlloyDbSettings/PrimaryInstanceSettings/MachineConfig.php index a00b96445d0f..aa96e0df43da 100644 --- a/Dms/src/V1/AlloyDbSettings/PrimaryInstanceSettings/MachineConfig.php +++ b/Dms/src/V1/AlloyDbSettings/PrimaryInstanceSettings/MachineConfig.php @@ -20,7 +20,7 @@ class MachineConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 cpu_count = 1; */ - private $cpu_count = 0; + protected $cpu_count = 0; /** * Constructor. diff --git a/Dms/src/V1/AlloyDbSettings/UserPassword.php b/Dms/src/V1/AlloyDbSettings/UserPassword.php index 83c7bbba92df..55d7687aac62 100644 --- a/Dms/src/V1/AlloyDbSettings/UserPassword.php +++ b/Dms/src/V1/AlloyDbSettings/UserPassword.php @@ -21,19 +21,19 @@ class UserPassword extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string user = 1; */ - private $user = ''; + protected $user = ''; /** * The initial password for the user. * * Generated from protobuf field string password = 2; */ - private $password = ''; + protected $password = ''; /** * Output only. Indicates if the initial_user.password field has been set. * * Generated from protobuf field bool password_set = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $password_set = false; + protected $password_set = false; /** * Constructor. diff --git a/Dms/src/V1/ApplyConversionWorkspaceRequest.php b/Dms/src/V1/ApplyConversionWorkspaceRequest.php index 74d4cce114d3..5a30540d4999 100644 --- a/Dms/src/V1/ApplyConversionWorkspaceRequest.php +++ b/Dms/src/V1/ApplyConversionWorkspaceRequest.php @@ -22,14 +22,14 @@ class ApplyConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Filter which entities to apply. Leaving this field empty will apply all of * the entities. Supports Google AIP 160 based filtering. * * Generated from protobuf field string filter = 2; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Only validates the apply process, but doesn't change the * destination database. Only works for PostgreSQL destination connection @@ -37,14 +37,14 @@ class ApplyConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool dry_run = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $dry_run = false; + protected $dry_run = false; /** * Optional. Specifies whether the conversion workspace is to be committed * automatically after the apply. * * Generated from protobuf field bool auto_commit = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $auto_commit = false; + protected $auto_commit = false; protected $destination; /** diff --git a/Dms/src/V1/AssignSpecificValue.php b/Dms/src/V1/AssignSpecificValue.php index 08018fabcf7d..7d8419dd8cc6 100644 --- a/Dms/src/V1/AssignSpecificValue.php +++ b/Dms/src/V1/AssignSpecificValue.php @@ -20,7 +20,7 @@ class AssignSpecificValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string value = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $value = ''; + protected $value = ''; /** * Constructor. diff --git a/Dms/src/V1/BackgroundJobLogEntry.php b/Dms/src/V1/BackgroundJobLogEntry.php index 2ad1d3f4ca2e..01d05ded0328 100644 --- a/Dms/src/V1/BackgroundJobLogEntry.php +++ b/Dms/src/V1/BackgroundJobLogEntry.php @@ -20,46 +20,46 @@ class BackgroundJobLogEntry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * The type of job that was executed. * * Generated from protobuf field .google.cloud.clouddms.v1.BackgroundJobType job_type = 2; */ - private $job_type = 0; + protected $job_type = 0; /** * The timestamp when the background job was started. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 3; */ - private $start_time = null; + protected $start_time = null; /** * The timestamp when the background job was finished. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 4; */ - private $finish_time = null; + protected $finish_time = null; /** * Output only. Job completion state, i.e. the final state after the job * completed. * * Generated from protobuf field .google.cloud.clouddms.v1.BackgroundJobLogEntry.JobCompletionState completion_state = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $completion_state = 0; + protected $completion_state = 0; /** * Output only. Job completion comment, such as how many entities were seeded, * how many warnings were found during conversion, and similar information. * * Generated from protobuf field string completion_comment = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $completion_comment = ''; + protected $completion_comment = ''; /** * Output only. Whether the client requested the conversion workspace to be * committed after a successful completion of the job. * * Generated from protobuf field bool request_autocommit = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $request_autocommit = false; + protected $request_autocommit = false; protected $job_details; /** diff --git a/Dms/src/V1/BackgroundJobLogEntry/ApplyJobDetails.php b/Dms/src/V1/BackgroundJobLogEntry/ApplyJobDetails.php index f8c660aae459..5da1879db98e 100644 --- a/Dms/src/V1/BackgroundJobLogEntry/ApplyJobDetails.php +++ b/Dms/src/V1/BackgroundJobLogEntry/ApplyJobDetails.php @@ -20,13 +20,13 @@ class ApplyJobDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string connection_profile = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $connection_profile = ''; + protected $connection_profile = ''; /** * Output only. AIP-160 based filter used to specify the entities to apply * * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $filter = ''; + protected $filter = ''; /** * Constructor. diff --git a/Dms/src/V1/BackgroundJobLogEntry/ConvertJobDetails.php b/Dms/src/V1/BackgroundJobLogEntry/ConvertJobDetails.php index ba5421da2064..b49a67f72493 100644 --- a/Dms/src/V1/BackgroundJobLogEntry/ConvertJobDetails.php +++ b/Dms/src/V1/BackgroundJobLogEntry/ConvertJobDetails.php @@ -20,7 +20,7 @@ class ConvertJobDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $filter = ''; + protected $filter = ''; /** * Constructor. diff --git a/Dms/src/V1/BackgroundJobLogEntry/ImportRulesJobDetails.php b/Dms/src/V1/BackgroundJobLogEntry/ImportRulesJobDetails.php index 7b54dfda7629..d70f043486f2 100644 --- a/Dms/src/V1/BackgroundJobLogEntry/ImportRulesJobDetails.php +++ b/Dms/src/V1/BackgroundJobLogEntry/ImportRulesJobDetails.php @@ -26,7 +26,7 @@ class ImportRulesJobDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.ImportRulesFileFormat file_format = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $file_format = 0; + protected $file_format = 0; /** * Constructor. diff --git a/Dms/src/V1/BackgroundJobLogEntry/SeedJobDetails.php b/Dms/src/V1/BackgroundJobLogEntry/SeedJobDetails.php index 672e1d5b8654..a8a9afb5a31c 100644 --- a/Dms/src/V1/BackgroundJobLogEntry/SeedJobDetails.php +++ b/Dms/src/V1/BackgroundJobLogEntry/SeedJobDetails.php @@ -20,7 +20,7 @@ class SeedJobDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string connection_profile = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $connection_profile = ''; + protected $connection_profile = ''; /** * Constructor. diff --git a/Dms/src/V1/Client/DataMigrationServiceClient.php b/Dms/src/V1/Client/DataMigrationServiceClient.php index 8463e47007d0..28098656d526 100644 --- a/Dms/src/V1/Client/DataMigrationServiceClient.php +++ b/Dms/src/V1/Client/DataMigrationServiceClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a * connection_profile resource. @@ -249,8 +268,11 @@ public static function connectionProfileName(string $project, string $location, * * @return string The formatted conversion_workspace resource. */ - public static function conversionWorkspaceName(string $project, string $location, string $conversionWorkspace): string - { + public static function conversionWorkspaceName( + string $project, + string $location, + string $conversionWorkspace + ): string { return self::getPathTemplate('conversionWorkspace')->render([ 'project' => $project, 'location' => $location, @@ -286,8 +308,12 @@ public static function locationName(string $project, string $location): string * * @return string The formatted mapping_rule resource. */ - public static function mappingRuleName(string $project, string $location, string $conversionWorkspace, string $mappingRule): string - { + public static function mappingRuleName( + string $project, + string $location, + string $conversionWorkspace, + string $mappingRule + ): string { return self::getPathTemplate('mappingRule')->render([ 'project' => $project, 'location' => $location, @@ -475,8 +501,10 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function applyConversionWorkspace(ApplyConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { + public function applyConversionWorkspace( + ApplyConversionWorkspaceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('ApplyConversionWorkspace', $request, $callOptions)->wait(); } @@ -502,8 +530,10 @@ public function applyConversionWorkspace(ApplyConversionWorkspaceRequest $reques * * @throws ApiException Thrown if the API call fails. */ - public function commitConversionWorkspace(CommitConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { + public function commitConversionWorkspace( + CommitConversionWorkspaceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CommitConversionWorkspace', $request, $callOptions)->wait(); } @@ -529,8 +559,10 @@ public function commitConversionWorkspace(CommitConversionWorkspaceRequest $requ * * @throws ApiException Thrown if the API call fails. */ - public function convertConversionWorkspace(ConvertConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { + public function convertConversionWorkspace( + ConvertConversionWorkspaceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('ConvertConversionWorkspace', $request, $callOptions)->wait(); } @@ -556,8 +588,10 @@ public function convertConversionWorkspace(ConvertConversionWorkspaceRequest $re * * @throws ApiException Thrown if the API call fails. */ - public function createConnectionProfile(CreateConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { + public function createConnectionProfile( + CreateConnectionProfileRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CreateConnectionProfile', $request, $callOptions)->wait(); } @@ -583,8 +617,10 @@ public function createConnectionProfile(CreateConnectionProfileRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function createConversionWorkspace(CreateConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { + public function createConversionWorkspace( + CreateConversionWorkspaceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CreateConversionWorkspace', $request, $callOptions)->wait(); } @@ -664,8 +700,10 @@ public function createMigrationJob(CreateMigrationJobRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { + public function createPrivateConnection( + CreatePrivateConnectionRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); } @@ -693,8 +731,10 @@ public function createPrivateConnection(CreatePrivateConnectionRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function deleteConnectionProfile(DeleteConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { + public function deleteConnectionProfile( + DeleteConnectionProfileRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('DeleteConnectionProfile', $request, $callOptions)->wait(); } @@ -720,8 +760,10 @@ public function deleteConnectionProfile(DeleteConnectionProfileRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function deleteConversionWorkspace(DeleteConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { + public function deleteConversionWorkspace( + DeleteConversionWorkspaceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('DeleteConversionWorkspace', $request, $callOptions)->wait(); } @@ -799,8 +841,10 @@ public function deleteMigrationJob(DeleteMigrationJobRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { + public function deletePrivateConnection( + DeletePrivateConnectionRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); } @@ -827,8 +871,10 @@ public function deletePrivateConnection(DeletePrivateConnectionRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function describeConversionWorkspaceRevisions(DescribeConversionWorkspaceRevisionsRequest $request, array $callOptions = []): DescribeConversionWorkspaceRevisionsResponse - { + public function describeConversionWorkspaceRevisions( + DescribeConversionWorkspaceRevisionsRequest $request, + array $callOptions = [] + ): DescribeConversionWorkspaceRevisionsResponse { return $this->startApiCall('DescribeConversionWorkspaceRevisions', $request, $callOptions)->wait(); } @@ -859,8 +905,10 @@ public function describeConversionWorkspaceRevisions(DescribeConversionWorkspace * * @throws ApiException Thrown if the API call fails. */ - public function describeDatabaseEntities(DescribeDatabaseEntitiesRequest $request, array $callOptions = []): PagedListResponse - { + public function describeDatabaseEntities( + DescribeDatabaseEntitiesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('DescribeDatabaseEntities', $request, $callOptions); } @@ -942,8 +990,10 @@ public function generateSshScript(GenerateSshScriptRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function generateTcpProxyScript(GenerateTcpProxyScriptRequest $request, array $callOptions = []): TcpProxyScript - { + public function generateTcpProxyScript( + GenerateTcpProxyScriptRequest $request, + array $callOptions = [] + ): TcpProxyScript { return $this->startApiCall('GenerateTcpProxyScript', $request, $callOptions)->wait(); } @@ -969,8 +1019,10 @@ public function generateTcpProxyScript(GenerateTcpProxyScriptRequest $request, a * * @throws ApiException Thrown if the API call fails. */ - public function getConnectionProfile(GetConnectionProfileRequest $request, array $callOptions = []): ConnectionProfile - { + public function getConnectionProfile( + GetConnectionProfileRequest $request, + array $callOptions = [] + ): ConnectionProfile { return $this->startApiCall('GetConnectionProfile', $request, $callOptions)->wait(); } @@ -996,8 +1048,10 @@ public function getConnectionProfile(GetConnectionProfileRequest $request, array * * @throws ApiException Thrown if the API call fails. */ - public function getConversionWorkspace(GetConversionWorkspaceRequest $request, array $callOptions = []): ConversionWorkspace - { + public function getConversionWorkspace( + GetConversionWorkspaceRequest $request, + array $callOptions = [] + ): ConversionWorkspace { return $this->startApiCall('GetConversionWorkspace', $request, $callOptions)->wait(); } @@ -1075,8 +1129,10 @@ public function getMigrationJob(GetMigrationJobRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection - { + public function getPrivateConnection( + GetPrivateConnectionRequest $request, + array $callOptions = [] + ): PrivateConnection { return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); } @@ -1131,8 +1187,10 @@ public function importMappingRules(ImportMappingRulesRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function listConnectionProfiles(ListConnectionProfilesRequest $request, array $callOptions = []): PagedListResponse - { + public function listConnectionProfiles( + ListConnectionProfilesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListConnectionProfiles', $request, $callOptions); } @@ -1158,8 +1216,10 @@ public function listConnectionProfiles(ListConnectionProfilesRequest $request, a * * @throws ApiException Thrown if the API call fails. */ - public function listConversionWorkspaces(ListConversionWorkspacesRequest $request, array $callOptions = []): PagedListResponse - { + public function listConversionWorkspaces( + ListConversionWorkspacesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListConversionWorkspaces', $request, $callOptions); } @@ -1239,8 +1299,10 @@ public function listMigrationJobs(ListMigrationJobsRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse - { + public function listPrivateConnections( + ListPrivateConnectionsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListPrivateConnections', $request, $callOptions); } @@ -1351,8 +1413,10 @@ public function resumeMigrationJob(ResumeMigrationJobRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function rollbackConversionWorkspace(RollbackConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { + public function rollbackConversionWorkspace( + RollbackConversionWorkspaceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('RollbackConversionWorkspace', $request, $callOptions)->wait(); } @@ -1383,8 +1447,10 @@ public function rollbackConversionWorkspace(RollbackConversionWorkspaceRequest $ * * @throws ApiException Thrown if the API call fails. */ - public function searchBackgroundJobs(SearchBackgroundJobsRequest $request, array $callOptions = []): SearchBackgroundJobsResponse - { + public function searchBackgroundJobs( + SearchBackgroundJobsRequest $request, + array $callOptions = [] + ): SearchBackgroundJobsResponse { return $this->startApiCall('SearchBackgroundJobs', $request, $callOptions)->wait(); } @@ -1411,8 +1477,10 @@ public function searchBackgroundJobs(SearchBackgroundJobsRequest $request, array * * @throws ApiException Thrown if the API call fails. */ - public function seedConversionWorkspace(SeedConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { + public function seedConversionWorkspace( + SeedConversionWorkspaceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('SeedConversionWorkspace', $request, $callOptions)->wait(); } @@ -1492,8 +1560,10 @@ public function stopMigrationJob(StopMigrationJobRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function updateConnectionProfile(UpdateConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { + public function updateConnectionProfile( + UpdateConnectionProfileRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('UpdateConnectionProfile', $request, $callOptions)->wait(); } @@ -1519,8 +1589,10 @@ public function updateConnectionProfile(UpdateConnectionProfileRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function updateConversionWorkspace(UpdateConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { + public function updateConversionWorkspace( + UpdateConversionWorkspaceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('UpdateConversionWorkspace', $request, $callOptions)->wait(); } diff --git a/Dms/src/V1/CloudSqlConnectionProfile.php b/Dms/src/V1/CloudSqlConnectionProfile.php index b218d5b0049b..e44deeb2e895 100644 --- a/Dms/src/V1/CloudSqlConnectionProfile.php +++ b/Dms/src/V1/CloudSqlConnectionProfile.php @@ -22,25 +22,25 @@ class CloudSqlConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cloud_sql_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $cloud_sql_id = ''; + protected $cloud_sql_id = ''; /** * Immutable. Metadata used to create the destination Cloud SQL database. * * Generated from protobuf field .google.cloud.clouddms.v1.CloudSqlSettings settings = 2 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $settings = null; + protected $settings = null; /** * Output only. The Cloud SQL database instance's private IP. * * Generated from protobuf field string private_ip = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $private_ip = ''; + protected $private_ip = ''; /** * Output only. The Cloud SQL database instance's public IP. * * Generated from protobuf field string public_ip = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $public_ip = ''; + protected $public_ip = ''; /** * Output only. The Cloud SQL database instance's additional (outgoing) public * IP. Used when the Cloud SQL database availability type is REGIONAL (i.e. @@ -48,7 +48,7 @@ class CloudSqlConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string additional_public_ip = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $additional_public_ip = ''; + protected $additional_public_ip = ''; /** * Constructor. diff --git a/Dms/src/V1/CloudSqlSettings.php b/Dms/src/V1/CloudSqlSettings.php index d9a0ef8e6199..373267b469a0 100644 --- a/Dms/src/V1/CloudSqlSettings.php +++ b/Dms/src/V1/CloudSqlSettings.php @@ -20,7 +20,7 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.CloudSqlSettings.SqlDatabaseVersion database_version = 1; */ - private $database_version = 0; + protected $database_version = 0; /** * The resource labels for a Cloud SQL instance to use to annotate any related * underlying resources such as Compute Engine VMs. @@ -40,14 +40,14 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string tier = 3; */ - private $tier = ''; + protected $tier = ''; /** * The maximum size to which storage capacity can be automatically increased. * The default value is 0, which specifies that there is no limit. * * Generated from protobuf field .google.protobuf.Int64Value storage_auto_resize_limit = 4; */ - private $storage_auto_resize_limit = null; + protected $storage_auto_resize_limit = null; /** * The activation policy specifies when the instance is activated; it is * applicable only when the instance state is 'RUNNABLE'. Valid values: @@ -58,7 +58,7 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.CloudSqlSettings.SqlActivationPolicy activation_policy = 5; */ - private $activation_policy = 0; + protected $activation_policy = 0; /** * The settings for IP Management. This allows to enable or disable the * instance IP and manage which external networks can connect to the instance. @@ -66,7 +66,7 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.SqlIpConfig ip_config = 6; */ - private $ip_config = null; + protected $ip_config = null; /** * [default: ON] If you enable this setting, Cloud SQL checks your available * storage every 30 seconds. If the available storage falls below a threshold @@ -76,7 +76,7 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.BoolValue auto_storage_increase = 7; */ - private $auto_storage_increase = null; + protected $auto_storage_increase = null; /** * The database flags passed to the Cloud SQL instance at startup. * An object containing a list of "key": value pairs. @@ -90,21 +90,21 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.CloudSqlSettings.SqlDataDiskType data_disk_type = 9; */ - private $data_disk_type = 0; + protected $data_disk_type = 0; /** * The storage capacity available to the database, in GB. * The minimum (and default) size is 10GB. * * Generated from protobuf field .google.protobuf.Int64Value data_disk_size_gb = 10; */ - private $data_disk_size_gb = null; + protected $data_disk_size_gb = null; /** * The Google Cloud Platform zone where your Cloud SQL database instance is * located. * * Generated from protobuf field string zone = 11; */ - private $zone = ''; + protected $zone = ''; /** * Optional. The Google Cloud Platform zone where the failover Cloud SQL * database instance is located. Used when the Cloud SQL database availability @@ -112,7 +112,7 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string secondary_zone = 18 [(.google.api.field_behavior) = OPTIONAL]; */ - private $secondary_zone = ''; + protected $secondary_zone = ''; /** * The Database Migration Service source connection profile ID, * in the format: @@ -120,31 +120,31 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_id = 12; */ - private $source_id = ''; + protected $source_id = ''; /** * Input only. Initial root password. * * Generated from protobuf field string root_password = 13 [(.google.api.field_behavior) = INPUT_ONLY]; */ - private $root_password = ''; + protected $root_password = ''; /** * Output only. Indicates If this connection profile root password is stored. * * Generated from protobuf field bool root_password_set = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $root_password_set = false; + protected $root_password_set = false; /** * The Cloud SQL default instance level collation. * * Generated from protobuf field string collation = 15; */ - private $collation = ''; + protected $collation = ''; /** * The KMS key name used for the csql instance. * * Generated from protobuf field string cmek_key_name = 16; */ - private $cmek_key_name = ''; + protected $cmek_key_name = ''; /** * Optional. Availability type. Potential values: * * `ZONAL`: The instance serves data from only one zone. Outages in that @@ -154,13 +154,13 @@ class CloudSqlSettings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.CloudSqlSettings.SqlAvailabilityType availability_type = 17 [(.google.api.field_behavior) = OPTIONAL]; */ - private $availability_type = 0; + protected $availability_type = 0; /** * Optional. The edition of the given Cloud SQL instance. * * Generated from protobuf field .google.cloud.clouddms.v1.CloudSqlSettings.Edition edition = 19 [(.google.api.field_behavior) = OPTIONAL]; */ - private $edition = 0; + protected $edition = 0; /** * Constructor. @@ -370,7 +370,7 @@ public function clearStorageAutoResizeLimit() * Generated from protobuf field .google.protobuf.Int64Value storage_auto_resize_limit = 4; * @return int|string|null */ - public function getStorageAutoResizeLimitValue() + public function getStorageAutoResizeLimitUnwrapped() { return $this->readWrapperValue("storage_auto_resize_limit"); } @@ -401,7 +401,7 @@ public function setStorageAutoResizeLimit($var) * @param int|string|null $var * @return $this */ - public function setStorageAutoResizeLimitValue($var) + public function setStorageAutoResizeLimitUnwrapped($var) { $this->writeWrapperValue("storage_auto_resize_limit", $var); return $this;} @@ -519,7 +519,7 @@ public function clearAutoStorageIncrease() * Generated from protobuf field .google.protobuf.BoolValue auto_storage_increase = 7; * @return bool|null */ - public function getAutoStorageIncreaseValue() + public function getAutoStorageIncreaseUnwrapped() { return $this->readWrapperValue("auto_storage_increase"); } @@ -556,7 +556,7 @@ public function setAutoStorageIncrease($var) * @param bool|null $var * @return $this */ - public function setAutoStorageIncreaseValue($var) + public function setAutoStorageIncreaseUnwrapped($var) { $this->writeWrapperValue("auto_storage_increase", $var); return $this;} @@ -648,7 +648,7 @@ public function clearDataDiskSizeGb() * Generated from protobuf field .google.protobuf.Int64Value data_disk_size_gb = 10; * @return int|string|null */ - public function getDataDiskSizeGbValue() + public function getDataDiskSizeGbUnwrapped() { return $this->readWrapperValue("data_disk_size_gb"); } @@ -679,7 +679,7 @@ public function setDataDiskSizeGb($var) * @param int|string|null $var * @return $this */ - public function setDataDiskSizeGbValue($var) + public function setDataDiskSizeGbUnwrapped($var) { $this->writeWrapperValue("data_disk_size_gb", $var); return $this;} diff --git a/Dms/src/V1/ColumnEntity.php b/Dms/src/V1/ColumnEntity.php index 7f5e851f799d..2a56ea90f0ee 100644 --- a/Dms/src/V1/ColumnEntity.php +++ b/Dms/src/V1/ColumnEntity.php @@ -21,85 +21,85 @@ class ColumnEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Column data type. * * Generated from protobuf field string data_type = 2; */ - private $data_type = ''; + protected $data_type = ''; /** * Charset override - instead of table level charset. * * Generated from protobuf field string charset = 3; */ - private $charset = ''; + protected $charset = ''; /** * Collation override - instead of table level collation. * * Generated from protobuf field string collation = 4; */ - private $collation = ''; + protected $collation = ''; /** * Column length - e.g. varchar (50). * * Generated from protobuf field int64 length = 5; */ - private $length = 0; + protected $length = 0; /** * Column precision - when relevant. * * Generated from protobuf field int32 precision = 6; */ - private $precision = 0; + protected $precision = 0; /** * Column scale - when relevant. * * Generated from protobuf field int32 scale = 7; */ - private $scale = 0; + protected $scale = 0; /** * Column fractional second precision - used for timestamp based datatypes. * * Generated from protobuf field int32 fractional_seconds_precision = 8; */ - private $fractional_seconds_precision = 0; + protected $fractional_seconds_precision = 0; /** * Is the column of array type. * * Generated from protobuf field bool array = 9; */ - private $array = false; + protected $array = false; /** * If the column is array, of which length. * * Generated from protobuf field int32 array_length = 10; */ - private $array_length = 0; + protected $array_length = 0; /** * Is the column nullable. * * Generated from protobuf field bool nullable = 11; */ - private $nullable = false; + protected $nullable = false; /** * Is the column auto-generated/identity. * * Generated from protobuf field bool auto_generated = 12; */ - private $auto_generated = false; + protected $auto_generated = false; /** * Is the column a UDT. * * Generated from protobuf field bool udt = 13; */ - private $udt = false; + protected $udt = false; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 14; */ - private $custom_features = null; + protected $custom_features = null; /** * Specifies the list of values allowed in the column. * Only used for set data type. @@ -112,19 +112,19 @@ class ColumnEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string comment = 16; */ - private $comment = ''; + protected $comment = ''; /** * Column order in the table. * * Generated from protobuf field int32 ordinal_position = 17; */ - private $ordinal_position = 0; + protected $ordinal_position = 0; /** * Default value of the column. * * Generated from protobuf field string default_value = 18; */ - private $default_value = ''; + protected $default_value = ''; /** * Constructor. diff --git a/Dms/src/V1/CommitConversionWorkspaceRequest.php b/Dms/src/V1/CommitConversionWorkspaceRequest.php index a60ceff3ffe1..5facbdca1246 100644 --- a/Dms/src/V1/CommitConversionWorkspaceRequest.php +++ b/Dms/src/V1/CommitConversionWorkspaceRequest.php @@ -20,13 +20,13 @@ class CommitConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. Optional name of the commit. * * Generated from protobuf field string commit_name = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $commit_name = ''; + protected $commit_name = ''; /** * Constructor. diff --git a/Dms/src/V1/ConditionalColumnSetValue.php b/Dms/src/V1/ConditionalColumnSetValue.php index 0ed94540f57b..63139802cf40 100644 --- a/Dms/src/V1/ConditionalColumnSetValue.php +++ b/Dms/src/V1/ConditionalColumnSetValue.php @@ -23,13 +23,13 @@ class ConditionalColumnSetValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.ValueTransformation value_transformation = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $value_transformation = null; + protected $value_transformation = null; /** * Optional. Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $custom_features = null; + protected $custom_features = null; protected $source_filter; /** diff --git a/Dms/src/V1/ConnectionProfile.php b/Dms/src/V1/ConnectionProfile.php index 7dd9b789ad2a..f834caa8f4c5 100644 --- a/Dms/src/V1/ConnectionProfile.php +++ b/Dms/src/V1/ConnectionProfile.php @@ -21,7 +21,7 @@ class ConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. The timestamp when the resource was created. * A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. @@ -29,7 +29,7 @@ class ConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The timestamp when the resource was last updated. * A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. @@ -37,7 +37,7 @@ class ConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * The resource labels for connection profile to use to annotate any related * underlying resources such as Compute Engine VMs. An object containing a @@ -52,25 +52,25 @@ class ConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.ConnectionProfile.State state = 5; */ - private $state = 0; + protected $state = 0; /** * The connection profile display name. * * Generated from protobuf field string display_name = 6; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. The error details in case of state FAILED. * * Generated from protobuf field .google.rpc.Status error = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $error = null; + protected $error = null; /** * The database provider. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseProvider provider = 8; */ - private $provider = 0; + protected $provider = 0; protected $connection_profile; /** diff --git a/Dms/src/V1/ConstraintEntity.php b/Dms/src/V1/ConstraintEntity.php index 9838706771ce..a4ed414f62f2 100644 --- a/Dms/src/V1/ConstraintEntity.php +++ b/Dms/src/V1/ConstraintEntity.php @@ -21,14 +21,14 @@ class ConstraintEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Type of constraint, for example unique, primary key, foreign key (currently * only primary key is supported). * * Generated from protobuf field string type = 2; */ - private $type = ''; + protected $type = ''; /** * Table columns used as part of the Constraint, for example primary key * constraint should list the columns which constitutes the key. @@ -41,7 +41,7 @@ class ConstraintEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct custom_features = 4; */ - private $custom_features = null; + protected $custom_features = null; /** * Reference columns which may be associated with the constraint. For example, * if the constraint is a FOREIGN_KEY, this represents the list of full names @@ -57,7 +57,7 @@ class ConstraintEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string reference_table = 6; */ - private $reference_table = ''; + protected $reference_table = ''; /** * Table which is associated with the constraint. In case the constraint * is defined on a table, this field is left empty as this information is @@ -66,7 +66,7 @@ class ConstraintEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_name = 7; */ - private $table_name = ''; + protected $table_name = ''; /** * Constructor. diff --git a/Dms/src/V1/ConversionWorkspace.php b/Dms/src/V1/ConversionWorkspace.php index db11b6c3fc04..3d1564edf41c 100644 --- a/Dms/src/V1/ConversionWorkspace.php +++ b/Dms/src/V1/ConversionWorkspace.php @@ -21,19 +21,19 @@ class ConversionWorkspace extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Required. The source engine details. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEngineInfo source = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $source = null; + protected $source = null; /** * Required. The destination engine details. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEngineInfo destination = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $destination = null; + protected $destination = null; /** * Optional. A generic list of settings for the workspace. * The settings are database pair dependant and can indicate default behavior @@ -50,37 +50,37 @@ class ConversionWorkspace extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool has_uncommitted_changes = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $has_uncommitted_changes = false; + protected $has_uncommitted_changes = false; /** * Output only. The latest commit ID. * * Generated from protobuf field string latest_commit_id = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $latest_commit_id = ''; + protected $latest_commit_id = ''; /** * Output only. The timestamp when the workspace was committed. * * Generated from protobuf field .google.protobuf.Timestamp latest_commit_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $latest_commit_time = null; + protected $latest_commit_time = null; /** * Output only. The timestamp when the workspace resource was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The timestamp when the workspace resource was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional. The display name for the workspace. * * Generated from protobuf field string display_name = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. diff --git a/Dms/src/V1/ConversionWorkspaceInfo.php b/Dms/src/V1/ConversionWorkspaceInfo.php index e850c1a8c5d4..bd8ce661a178 100644 --- a/Dms/src/V1/ConversionWorkspaceInfo.php +++ b/Dms/src/V1/ConversionWorkspaceInfo.php @@ -20,13 +20,13 @@ class ConversionWorkspaceInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The commit ID of the conversion workspace. * * Generated from protobuf field string commit_id = 2; */ - private $commit_id = ''; + protected $commit_id = ''; /** * Constructor. diff --git a/Dms/src/V1/ConvertConversionWorkspaceRequest.php b/Dms/src/V1/ConvertConversionWorkspaceRequest.php index 08d36d786ecf..2626d58d565d 100644 --- a/Dms/src/V1/ConvertConversionWorkspaceRequest.php +++ b/Dms/src/V1/ConvertConversionWorkspaceRequest.php @@ -21,21 +21,21 @@ class ConvertConversionWorkspaceRequest extends \Google\Protobuf\Internal\Messag * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. Specifies whether the conversion workspace is to be committed * automatically after the conversion. * * Generated from protobuf field bool auto_commit = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $auto_commit = false; + protected $auto_commit = false; /** * Optional. Filter the entities to convert. Leaving this field empty will * convert all of the entities. Supports Google AIP-160 style filtering. * * Generated from protobuf field string filter = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Automatically convert the full entity path for each entity * specified by the filter. For example, if the filter specifies a table, that @@ -43,7 +43,7 @@ class ConvertConversionWorkspaceRequest extends \Google\Protobuf\Internal\Messag * * Generated from protobuf field bool convert_full_path = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $convert_full_path = false; + protected $convert_full_path = false; /** * Constructor. diff --git a/Dms/src/V1/ConvertRowIdToColumn.php b/Dms/src/V1/ConvertRowIdToColumn.php index b398a060f576..20653db324e9 100644 --- a/Dms/src/V1/ConvertRowIdToColumn.php +++ b/Dms/src/V1/ConvertRowIdToColumn.php @@ -27,7 +27,7 @@ class ConvertRowIdToColumn extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool only_if_no_primary_key = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $only_if_no_primary_key = false; + protected $only_if_no_primary_key = false; /** * Constructor. diff --git a/Dms/src/V1/CreateConnectionProfileRequest.php b/Dms/src/V1/CreateConnectionProfileRequest.php index e37a9072b57f..a30091a5f1fc 100644 --- a/Dms/src/V1/CreateConnectionProfileRequest.php +++ b/Dms/src/V1/CreateConnectionProfileRequest.php @@ -20,19 +20,19 @@ class CreateConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The connection profile identifier. * * Generated from protobuf field string connection_profile_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $connection_profile_id = ''; + protected $connection_profile_id = ''; /** * Required. The create request body including the connection profile data * * Generated from protobuf field .google.cloud.clouddms.v1.ConnectionProfile connection_profile = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $connection_profile = null; + protected $connection_profile = null; /** * Optional. A unique ID used to identify the request. If the server receives * two requests with the same ID, then the second request is ignored. @@ -42,7 +42,7 @@ class CreateConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. Only validate the connection profile, but don't create any * resources. The default is false. Only supported for Oracle connection @@ -50,7 +50,7 @@ class CreateConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool validate_only = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * Optional. Create the connection profile without validating it. * The default is false. @@ -58,7 +58,7 @@ class CreateConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool skip_validation = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $skip_validation = false; + protected $skip_validation = false; /** * @param string $parent Required. The parent which owns this collection of connection profiles. Please see diff --git a/Dms/src/V1/CreateConversionWorkspaceRequest.php b/Dms/src/V1/CreateConversionWorkspaceRequest.php index 5e664f66a5c6..cc63bb4eadc2 100644 --- a/Dms/src/V1/CreateConversionWorkspaceRequest.php +++ b/Dms/src/V1/CreateConversionWorkspaceRequest.php @@ -21,19 +21,19 @@ class CreateConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID of the conversion workspace to create. * * Generated from protobuf field string conversion_workspace_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $conversion_workspace_id = ''; + protected $conversion_workspace_id = ''; /** * Required. Represents a conversion workspace object. * * Generated from protobuf field .google.cloud.clouddms.v1.ConversionWorkspace conversion_workspace = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $conversion_workspace = null; + protected $conversion_workspace = null; /** * A unique ID used to identify the request. If the server receives two * requests with the same ID, then the second request is ignored. @@ -43,7 +43,7 @@ class CreateConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $parent Required. The parent which owns this collection of conversion workspaces. Please see diff --git a/Dms/src/V1/CreateMappingRuleRequest.php b/Dms/src/V1/CreateMappingRuleRequest.php index 18fb567186c4..4b1f3f6d1021 100644 --- a/Dms/src/V1/CreateMappingRuleRequest.php +++ b/Dms/src/V1/CreateMappingRuleRequest.php @@ -20,13 +20,13 @@ class CreateMappingRuleRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID of the rule to create. * * Generated from protobuf field string mapping_rule_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $mapping_rule_id = ''; + protected $mapping_rule_id = ''; /** * Required. Represents a [mapping rule] * (https://cloud.google.com/database-migration/reference/rest/v1/projects.locations.mappingRules) @@ -34,7 +34,7 @@ class CreateMappingRuleRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.MappingRule mapping_rule = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $mapping_rule = null; + protected $mapping_rule = null; /** * A unique ID used to identify the request. If the server receives two * requests with the same ID, then the second request is ignored. @@ -44,7 +44,7 @@ class CreateMappingRuleRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $parent Required. The parent which owns this collection of mapping rules. Please see diff --git a/Dms/src/V1/CreateMigrationJobRequest.php b/Dms/src/V1/CreateMigrationJobRequest.php index 9a2a3a0cc27a..d3cb5ac3c98b 100644 --- a/Dms/src/V1/CreateMigrationJobRequest.php +++ b/Dms/src/V1/CreateMigrationJobRequest.php @@ -21,13 +21,13 @@ class CreateMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID of the instance to create. * * Generated from protobuf field string migration_job_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $migration_job_id = ''; + protected $migration_job_id = ''; /** * Required. Represents a [migration * job](https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.migrationJobs) @@ -35,7 +35,7 @@ class CreateMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob migration_job = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $migration_job = null; + protected $migration_job = null; /** * Optional. A unique ID used to identify the request. If the server receives * two requests with the same ID, then the second request is ignored. @@ -45,7 +45,7 @@ class CreateMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $parent Required. The parent which owns this collection of migration jobs. Please see diff --git a/Dms/src/V1/CreatePrivateConnectionRequest.php b/Dms/src/V1/CreatePrivateConnectionRequest.php index 3413867833ff..a0675ee6edf7 100644 --- a/Dms/src/V1/CreatePrivateConnectionRequest.php +++ b/Dms/src/V1/CreatePrivateConnectionRequest.php @@ -21,19 +21,19 @@ class CreatePrivateConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The private connection identifier. * * Generated from protobuf field string private_connection_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $private_connection_id = ''; + protected $private_connection_id = ''; /** * Required. The private connection resource to create. * * Generated from protobuf field .google.cloud.clouddms.v1.PrivateConnection private_connection = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $private_connection = null; + protected $private_connection = null; /** * Optional. A unique ID used to identify the request. If the server receives * two requests with the same ID, then the second request is ignored. @@ -43,13 +43,13 @@ class CreatePrivateConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set to true, will skip validations. * * Generated from protobuf field bool skip_validation = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $skip_validation = false; + protected $skip_validation = false; /** * @param string $parent Required. The parent that owns the collection of PrivateConnections. Please see diff --git a/Dms/src/V1/DataMigrationServiceClient.php b/Dms/src/V1/DataMigrationServiceClient.php deleted file mode 100644 index e7795a942c75..000000000000 --- a/Dms/src/V1/DataMigrationServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -.google.cloud.clouddms.v1.DatabaseEngine engine = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $engine = 0; + protected $engine = 0; /** * Required. Engine named version, for example 12.c.1. * * Generated from protobuf field string version = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $version = ''; + protected $version = ''; /** * Constructor. diff --git a/Dms/src/V1/DatabaseEntity.php b/Dms/src/V1/DatabaseEntity.php index 2a4fb75d8a56..daeaf8281155 100644 --- a/Dms/src/V1/DatabaseEntity.php +++ b/Dms/src/V1/DatabaseEntity.php @@ -22,25 +22,25 @@ class DatabaseEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string short_name = 1; */ - private $short_name = ''; + protected $short_name = ''; /** * The full name of the parent entity (e.g. schema name). * * Generated from protobuf field string parent_entity = 2; */ - private $parent_entity = ''; + protected $parent_entity = ''; /** * The type of tree the entity belongs to. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntity.TreeType tree = 3; */ - private $tree = 0; + protected $tree = 0; /** * The type of the database entity (table, view, index, ...). * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntityType entity_type = 4; */ - private $entity_type = 0; + protected $entity_type = 0; /** * Details about entity mappings. * For source tree entities, this holds the draft entities which were diff --git a/Dms/src/V1/DatabaseInstanceEntity.php b/Dms/src/V1/DatabaseInstanceEntity.php index e5e266781ace..d1b8dc7263c0 100644 --- a/Dms/src/V1/DatabaseInstanceEntity.php +++ b/Dms/src/V1/DatabaseInstanceEntity.php @@ -20,7 +20,7 @@ class DatabaseInstanceEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct custom_features = 1; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/DatabaseType.php b/Dms/src/V1/DatabaseType.php index 70160fbaa71e..3680d49c6141 100644 --- a/Dms/src/V1/DatabaseType.php +++ b/Dms/src/V1/DatabaseType.php @@ -20,13 +20,13 @@ class DatabaseType extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseProvider provider = 1; */ - private $provider = 0; + protected $provider = 0; /** * The database engine. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEngine engine = 2; */ - private $engine = 0; + protected $engine = 0; /** * Constructor. diff --git a/Dms/src/V1/DeleteConnectionProfileRequest.php b/Dms/src/V1/DeleteConnectionProfileRequest.php index c7c99c4cb1fa..5508513ffa3a 100644 --- a/Dms/src/V1/DeleteConnectionProfileRequest.php +++ b/Dms/src/V1/DeleteConnectionProfileRequest.php @@ -20,7 +20,7 @@ class DeleteConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * A unique ID used to identify the request. If the server receives two * requests with the same ID, then the second request is ignored. @@ -30,14 +30,14 @@ class DeleteConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2; */ - private $request_id = ''; + protected $request_id = ''; /** * In case of force delete, the CloudSQL replica database is also deleted * (only for CloudSQL connection profile). * * Generated from protobuf field bool force = 3; */ - private $force = false; + protected $force = false; /** * @param string $name Required. Name of the connection profile resource to delete. Please see diff --git a/Dms/src/V1/DeleteConversionWorkspaceRequest.php b/Dms/src/V1/DeleteConversionWorkspaceRequest.php index 610558722150..8a5b009b9d61 100644 --- a/Dms/src/V1/DeleteConversionWorkspaceRequest.php +++ b/Dms/src/V1/DeleteConversionWorkspaceRequest.php @@ -20,7 +20,7 @@ class DeleteConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * A unique ID used to identify the request. If the server receives two * requests with the same ID, then the second request is ignored. @@ -30,14 +30,14 @@ class DeleteConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2; */ - private $request_id = ''; + protected $request_id = ''; /** * Force delete the conversion workspace, even if there's a running migration * that is using the workspace. * * Generated from protobuf field bool force = 3; */ - private $force = false; + protected $force = false; /** * @param string $name Required. Name of the conversion workspace resource to delete. Please see diff --git a/Dms/src/V1/DeleteMappingRuleRequest.php b/Dms/src/V1/DeleteMappingRuleRequest.php index 4d14f657b12d..8ffc37ca6d27 100644 --- a/Dms/src/V1/DeleteMappingRuleRequest.php +++ b/Dms/src/V1/DeleteMappingRuleRequest.php @@ -20,7 +20,7 @@ class DeleteMappingRuleRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. A unique ID used to identify the request. If the server receives * two requests with the same ID, then the second request is ignored. @@ -30,7 +30,7 @@ class DeleteMappingRuleRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $name Required. Name of the mapping rule resource to delete. Please see diff --git a/Dms/src/V1/DeleteMigrationJobRequest.php b/Dms/src/V1/DeleteMigrationJobRequest.php index ee3759d03070..e62675ed847b 100644 --- a/Dms/src/V1/DeleteMigrationJobRequest.php +++ b/Dms/src/V1/DeleteMigrationJobRequest.php @@ -20,7 +20,7 @@ class DeleteMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * A unique ID used to identify the request. If the server receives two * requests with the same ID, then the second request is ignored. @@ -30,7 +30,7 @@ class DeleteMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2; */ - private $request_id = ''; + protected $request_id = ''; /** * The destination CloudSQL connection profile is always deleted with the * migration job. In case of force delete, the destination CloudSQL replica @@ -38,7 +38,7 @@ class DeleteMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool force = 3; */ - private $force = false; + protected $force = false; /** * @param string $name Required. Name of the migration job resource to delete. Please see diff --git a/Dms/src/V1/DeletePrivateConnectionRequest.php b/Dms/src/V1/DeletePrivateConnectionRequest.php index 74f6bce29fb3..34bfd97c2db1 100644 --- a/Dms/src/V1/DeletePrivateConnectionRequest.php +++ b/Dms/src/V1/DeletePrivateConnectionRequest.php @@ -20,7 +20,7 @@ class DeletePrivateConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. A unique ID used to identify the request. If the server receives * two requests with the same ID, then the second request is ignored. @@ -30,7 +30,7 @@ class DeletePrivateConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $name Required. The name of the private connection to delete. Please see diff --git a/Dms/src/V1/DescribeConversionWorkspaceRevisionsRequest.php b/Dms/src/V1/DescribeConversionWorkspaceRevisionsRequest.php index f38f39e02cf5..9ecfae7b6d9d 100644 --- a/Dms/src/V1/DescribeConversionWorkspaceRevisionsRequest.php +++ b/Dms/src/V1/DescribeConversionWorkspaceRevisionsRequest.php @@ -22,13 +22,13 @@ class DescribeConversionWorkspaceRevisionsRequest extends \Google\Protobuf\Inter * * Generated from protobuf field string conversion_workspace = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $conversion_workspace = ''; + protected $conversion_workspace = ''; /** * Optional. Optional filter to request a specific commit ID. * * Generated from protobuf field string commit_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $commit_id = ''; + protected $commit_id = ''; /** * Constructor. diff --git a/Dms/src/V1/DescribeDatabaseEntitiesRequest.php b/Dms/src/V1/DescribeDatabaseEntitiesRequest.php index 8a38aa9e6a9b..d70dc0c804c3 100644 --- a/Dms/src/V1/DescribeDatabaseEntitiesRequest.php +++ b/Dms/src/V1/DescribeDatabaseEntitiesRequest.php @@ -22,14 +22,14 @@ class DescribeDatabaseEntitiesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string conversion_workspace = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $conversion_workspace = ''; + protected $conversion_workspace = ''; /** * Optional. The maximum number of entities to return. The service may return * fewer entities than the value specifies. * * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The nextPageToken value received in the previous call to * conversionWorkspace.describeDatabaseEntities, used in the subsequent @@ -40,13 +40,13 @@ class DescribeDatabaseEntitiesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Required. The tree to fetch. * * Generated from protobuf field .google.cloud.clouddms.v1.DescribeDatabaseEntitiesRequest.DBTreeType tree = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $tree = 0; + protected $tree = 0; /** * Optional. Whether to retrieve the latest committed version of the entities * or the latest version. This field is ignored if a specific commit_id is @@ -54,26 +54,26 @@ class DescribeDatabaseEntitiesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool uncommitted = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $uncommitted = false; + protected $uncommitted = false; /** * Optional. Request a specific commit ID. If not specified, the entities from * the latest commit are returned. * * Generated from protobuf field string commit_id = 12 [(.google.api.field_behavior) = OPTIONAL]; */ - private $commit_id = ''; + protected $commit_id = ''; /** * Optional. Filter the returned entities based on AIP-160 standard. * * Generated from protobuf field string filter = 13 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Results view based on AIP-157 * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntityView view = 14 [(.google.api.field_behavior) = OPTIONAL]; */ - private $view = 0; + protected $view = 0; /** * Constructor. diff --git a/Dms/src/V1/DescribeDatabaseEntitiesResponse.php b/Dms/src/V1/DescribeDatabaseEntitiesResponse.php index f3b9a2126c8d..837134030a05 100644 --- a/Dms/src/V1/DescribeDatabaseEntitiesResponse.php +++ b/Dms/src/V1/DescribeDatabaseEntitiesResponse.php @@ -27,7 +27,7 @@ class DescribeDatabaseEntitiesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Dms/src/V1/DoubleComparisonFilter.php b/Dms/src/V1/DoubleComparisonFilter.php index c92acbb197a6..395982c2ce8f 100644 --- a/Dms/src/V1/DoubleComparisonFilter.php +++ b/Dms/src/V1/DoubleComparisonFilter.php @@ -21,13 +21,13 @@ class DoubleComparisonFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.ValueComparison value_comparison = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $value_comparison = 0; + protected $value_comparison = 0; /** * Required. Double compare value to be used * * Generated from protobuf field double value = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $value = 0.0; + protected $value = 0.0; /** * Constructor. diff --git a/Dms/src/V1/EntityDdl.php b/Dms/src/V1/EntityDdl.php index d36d4a99465d..e6bf0006e5ab 100644 --- a/Dms/src/V1/EntityDdl.php +++ b/Dms/src/V1/EntityDdl.php @@ -20,25 +20,25 @@ class EntityDdl extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string ddl_type = 1; */ - private $ddl_type = ''; + protected $ddl_type = ''; /** * The name of the database entity the ddl refers to. * * Generated from protobuf field string entity = 2; */ - private $entity = ''; + protected $entity = ''; /** * The actual ddl code. * * Generated from protobuf field string ddl = 3; */ - private $ddl = ''; + protected $ddl = ''; /** * The entity type (if the DDL is for a sub entity). * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntityType entity_type = 4; */ - private $entity_type = 0; + protected $entity_type = 0; /** * EntityIssues found for this ddl. * diff --git a/Dms/src/V1/EntityIssue.php b/Dms/src/V1/EntityIssue.php index b183ee952a8d..af570982c5f3 100644 --- a/Dms/src/V1/EntityIssue.php +++ b/Dms/src/V1/EntityIssue.php @@ -20,49 +20,49 @@ class EntityIssue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * The type of the issue. * * Generated from protobuf field .google.cloud.clouddms.v1.EntityIssue.IssueType type = 2; */ - private $type = 0; + protected $type = 0; /** * Severity of the issue * * Generated from protobuf field .google.cloud.clouddms.v1.EntityIssue.IssueSeverity severity = 3; */ - private $severity = 0; + protected $severity = 0; /** * Issue detailed message * * Generated from protobuf field string message = 4; */ - private $message = ''; + protected $message = ''; /** * Error/Warning code * * Generated from protobuf field string code = 5; */ - private $code = ''; + protected $code = ''; /** * The ddl which caused the issue, if relevant. * * Generated from protobuf field optional string ddl = 6; */ - private $ddl = null; + protected $ddl = null; /** * The position of the issue found, if relevant. * * Generated from protobuf field optional .google.cloud.clouddms.v1.EntityIssue.Position position = 7; */ - private $position = null; + protected $position = null; /** * The entity type (if the DDL is for a sub entity). * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntityType entity_type = 8; */ - private $entity_type = 0; + protected $entity_type = 0; /** * Constructor. diff --git a/Dms/src/V1/EntityIssue/Position.php b/Dms/src/V1/EntityIssue/Position.php index 6fa5a9ed1e1a..c632834ced2d 100644 --- a/Dms/src/V1/EntityIssue/Position.php +++ b/Dms/src/V1/EntityIssue/Position.php @@ -20,25 +20,25 @@ class Position extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 line = 1; */ - private $line = 0; + protected $line = 0; /** * Issue column number * * Generated from protobuf field int32 column = 2; */ - private $column = 0; + protected $column = 0; /** * Issue offset * * Generated from protobuf field int32 offset = 3; */ - private $offset = 0; + protected $offset = 0; /** * Issue length * * Generated from protobuf field int32 length = 4; */ - private $length = 0; + protected $length = 0; /** * Constructor. diff --git a/Dms/src/V1/EntityMapping.php b/Dms/src/V1/EntityMapping.php index 1fdd715a5aad..93a107245cf6 100644 --- a/Dms/src/V1/EntityMapping.php +++ b/Dms/src/V1/EntityMapping.php @@ -22,7 +22,7 @@ class EntityMapping extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_entity = 1; */ - private $source_entity = ''; + protected $source_entity = ''; /** * Target entity full name. * The draft entity can also include a column, index or constraint using the @@ -30,19 +30,19 @@ class EntityMapping extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string draft_entity = 2; */ - private $draft_entity = ''; + protected $draft_entity = ''; /** * Type of source entity. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntityType source_type = 4; */ - private $source_type = 0; + protected $source_type = 0; /** * Type of draft entity. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntityType draft_type = 5; */ - private $draft_type = 0; + protected $draft_type = 0; /** * Entity mapping log entries. * Multiple rules can be effective and contribute changes to a converted diff --git a/Dms/src/V1/EntityMappingLogEntry.php b/Dms/src/V1/EntityMappingLogEntry.php index cca0103667e9..a3d520b13a82 100644 --- a/Dms/src/V1/EntityMappingLogEntry.php +++ b/Dms/src/V1/EntityMappingLogEntry.php @@ -20,19 +20,19 @@ class EntityMappingLogEntry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string rule_id = 1; */ - private $rule_id = ''; + protected $rule_id = ''; /** * Rule revision ID. * * Generated from protobuf field string rule_revision_id = 2; */ - private $rule_revision_id = ''; + protected $rule_revision_id = ''; /** * Comment. * * Generated from protobuf field string mapping_comment = 3; */ - private $mapping_comment = ''; + protected $mapping_comment = ''; /** * Constructor. diff --git a/Dms/src/V1/EntityMove.php b/Dms/src/V1/EntityMove.php index b4ece9d7f858..6541ec8aa272 100644 --- a/Dms/src/V1/EntityMove.php +++ b/Dms/src/V1/EntityMove.php @@ -24,7 +24,7 @@ class EntityMove extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string new_schema = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_schema = ''; + protected $new_schema = ''; /** * Constructor. diff --git a/Dms/src/V1/FetchStaticIpsRequest.php b/Dms/src/V1/FetchStaticIpsRequest.php index 47ef81aebcb7..a2b818dfa649 100644 --- a/Dms/src/V1/FetchStaticIpsRequest.php +++ b/Dms/src/V1/FetchStaticIpsRequest.php @@ -21,19 +21,19 @@ class FetchStaticIpsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Maximum number of IPs to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A page token, received from a previous `FetchStaticIps` call. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $name Required. The resource name for the location for which static IPs should be diff --git a/Dms/src/V1/FetchStaticIpsResponse.php b/Dms/src/V1/FetchStaticIpsResponse.php index 6793d129cd55..42862263c849 100644 --- a/Dms/src/V1/FetchStaticIpsResponse.php +++ b/Dms/src/V1/FetchStaticIpsResponse.php @@ -27,7 +27,7 @@ class FetchStaticIpsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Dms/src/V1/ForwardSshTunnelConnectivity.php b/Dms/src/V1/ForwardSshTunnelConnectivity.php index d012f158b558..d16597685de0 100644 --- a/Dms/src/V1/ForwardSshTunnelConnectivity.php +++ b/Dms/src/V1/ForwardSshTunnelConnectivity.php @@ -20,19 +20,19 @@ class ForwardSshTunnelConnectivity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string hostname = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $hostname = ''; + protected $hostname = ''; /** * Required. Username for the SSH tunnel. * * Generated from protobuf field string username = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $username = ''; + protected $username = ''; /** * Port for the SSH tunnel, default value is 22. * * Generated from protobuf field int32 port = 3; */ - private $port = 0; + protected $port = 0; protected $authentication_method; /** diff --git a/Dms/src/V1/FunctionEntity.php b/Dms/src/V1/FunctionEntity.php index e391807f70f8..5021029ef395 100644 --- a/Dms/src/V1/FunctionEntity.php +++ b/Dms/src/V1/FunctionEntity.php @@ -20,13 +20,13 @@ class FunctionEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string sql_code = 1; */ - private $sql_code = ''; + protected $sql_code = ''; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 2; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/Gapic/DataMigrationServiceGapicClient.php b/Dms/src/V1/Gapic/DataMigrationServiceGapicClient.php deleted file mode 100644 index 7dc8cd68cbb3..000000000000 --- a/Dms/src/V1/Gapic/DataMigrationServiceGapicClient.php +++ /dev/null @@ -1,3570 +0,0 @@ -conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $operationResponse = $dataMigrationServiceClient->applyConversionWorkspace($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 = $dataMigrationServiceClient->applyConversionWorkspace($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'applyConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\CloudDms\V1\Client\DataMigrationServiceClient}. - */ -class DataMigrationServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.clouddms.v1.DataMigrationService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'datamigration.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'datamigration.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $connectionProfileNameTemplate; - - private static $conversionWorkspaceNameTemplate; - - private static $locationNameTemplate; - - private static $mappingRuleNameTemplate; - - private static $migrationJobNameTemplate; - - private static $networksNameTemplate; - - private static $privateConnectionNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getConnectionProfileNameTemplate() - { - if (self::$connectionProfileNameTemplate == null) { - self::$connectionProfileNameTemplate = new PathTemplate('projects/{project}/locations/{location}/connectionProfiles/{connection_profile}'); - } - - return self::$connectionProfileNameTemplate; - } - - private static function getConversionWorkspaceNameTemplate() - { - if (self::$conversionWorkspaceNameTemplate == null) { - self::$conversionWorkspaceNameTemplate = new PathTemplate('projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}'); - } - - return self::$conversionWorkspaceNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getMappingRuleNameTemplate() - { - if (self::$mappingRuleNameTemplate == null) { - self::$mappingRuleNameTemplate = new PathTemplate('projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}/mappingRules/{mapping_rule}'); - } - - return self::$mappingRuleNameTemplate; - } - - private static function getMigrationJobNameTemplate() - { - if (self::$migrationJobNameTemplate == null) { - self::$migrationJobNameTemplate = new PathTemplate('projects/{project}/locations/{location}/migrationJobs/{migration_job}'); - } - - return self::$migrationJobNameTemplate; - } - - private static function getNetworksNameTemplate() - { - if (self::$networksNameTemplate == null) { - self::$networksNameTemplate = new PathTemplate('projects/{project}/global/networks/{network}'); - } - - return self::$networksNameTemplate; - } - - private static function getPrivateConnectionNameTemplate() - { - if (self::$privateConnectionNameTemplate == null) { - self::$privateConnectionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/privateConnections/{private_connection}'); - } - - return self::$privateConnectionNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'connectionProfile' => self::getConnectionProfileNameTemplate(), - 'conversionWorkspace' => self::getConversionWorkspaceNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'mappingRule' => self::getMappingRuleNameTemplate(), - 'migrationJob' => self::getMigrationJobNameTemplate(), - 'networks' => self::getNetworksNameTemplate(), - 'privateConnection' => self::getPrivateConnectionNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location, $connectionProfile) - { - return self::getConnectionProfileNameTemplate()->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($project, $location, $conversionWorkspace) - { - return self::getConversionWorkspaceNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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($project, $location, $conversionWorkspace, $mappingRule) - { - return self::getMappingRuleNameTemplate()->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($project, $location, $migrationJob) - { - return self::getMigrationJobNameTemplate()->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($project, $network) - { - return self::getNetworksNameTemplate()->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($project, $location, $privateConnection) - { - return self::getPrivateConnectionNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Applies draft tree onto a specific destination database. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $operationResponse = $dataMigrationServiceClient->applyConversionWorkspace($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 = $dataMigrationServiceClient->applyConversionWorkspace($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'applyConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the conversion workspace resource for which to apply - * the draft tree. Must be in the form of: - * projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * Filter which entities to apply. Leaving this field empty will apply all of - * the entities. Supports Google AIP 160 based filtering. - * @type bool $dryRun - * Optional. Only validates the apply process, but doesn't change the - * destination database. Only works for PostgreSQL destination connection - * profile. - * @type bool $autoCommit - * Optional. Specifies whether the conversion workspace is to be committed - * automatically after the apply. - * @type string $connectionProfile - * Optional. Fully qualified (Uri) name of the destination connection - * profile. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 applyConversionWorkspace($name, array $optionalArgs = []) - { - $request = new ApplyConversionWorkspaceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['dryRun'])) { - $request->setDryRun($optionalArgs['dryRun']); - } - - if (isset($optionalArgs['autoCommit'])) { - $request->setAutoCommit($optionalArgs['autoCommit']); - } - - if (isset($optionalArgs['connectionProfile'])) { - $request->setConnectionProfile($optionalArgs['connectionProfile']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ApplyConversionWorkspace', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Marks all the data in the conversion workspace as committed. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $operationResponse = $dataMigrationServiceClient->commitConversionWorkspace($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 = $dataMigrationServiceClient->commitConversionWorkspace($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'commitConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the conversion workspace resource to commit. - * @param array $optionalArgs { - * Optional. - * - * @type string $commitName - * Optional. Optional name of the commit. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 commitConversionWorkspace($name, array $optionalArgs = []) - { - $request = new CommitConversionWorkspaceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['commitName'])) { - $request->setCommitName($optionalArgs['commitName']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CommitConversionWorkspace', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a draft tree schema for the destination database. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $operationResponse = $dataMigrationServiceClient->convertConversionWorkspace(); - * $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 = $dataMigrationServiceClient->convertConversionWorkspace(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'convertConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the conversion workspace resource to convert in the form of: - * projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. - * @type bool $autoCommit - * Optional. Specifies whether the conversion workspace is to be committed - * automatically after the conversion. - * @type string $filter - * Optional. Filter the entities to convert. Leaving this field empty will - * convert all of the entities. Supports Google AIP-160 style filtering. - * @type bool $convertFullPath - * Optional. Automatically convert the full entity path for each entity - * specified by the filter. For example, if the filter specifies a table, that - * table schema (and database if there is one) will also be converted. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 convertConversionWorkspace(array $optionalArgs = []) - { - $request = new ConvertConversionWorkspaceRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['autoCommit'])) { - $request->setAutoCommit($optionalArgs['autoCommit']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['convertFullPath'])) { - $request->setConvertFullPath($optionalArgs['convertFullPath']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ConvertConversionWorkspace', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a new connection profile in a given project and location. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $connectionProfileId = 'connection_profile_id'; - * $connectionProfile = new ConnectionProfile(); - * $operationResponse = $dataMigrationServiceClient->createConnectionProfile($formattedParent, $connectionProfileId, $connectionProfile); - * $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 = $dataMigrationServiceClient->createConnectionProfile($formattedParent, $connectionProfileId, $connectionProfile); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'createConnectionProfile'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent which owns this collection of connection profiles. - * @param string $connectionProfileId Required. The connection profile identifier. - * @param ConnectionProfile $connectionProfile Required. The create request body including the connection profile data - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A unique ID used to identify the request. If the server receives - * two requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type bool $validateOnly - * Optional. Only validate the connection profile, but don't create any - * resources. The default is false. Only supported for Oracle connection - * profiles. - * @type bool $skipValidation - * Optional. Create the connection profile without validating it. - * The default is false. - * Only supported for Oracle connection profiles. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 createConnectionProfile($parent, $connectionProfileId, $connectionProfile, array $optionalArgs = []) - { - $request = new CreateConnectionProfileRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setConnectionProfileId($connectionProfileId); - $request->setConnectionProfile($connectionProfile); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - if (isset($optionalArgs['skipValidation'])) { - $request->setSkipValidation($optionalArgs['skipValidation']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateConnectionProfile', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a new conversion workspace in a given project and location. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $conversionWorkspaceId = 'conversion_workspace_id'; - * $conversionWorkspace = new ConversionWorkspace(); - * $operationResponse = $dataMigrationServiceClient->createConversionWorkspace($formattedParent, $conversionWorkspaceId, $conversionWorkspace); - * $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 = $dataMigrationServiceClient->createConversionWorkspace($formattedParent, $conversionWorkspaceId, $conversionWorkspace); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'createConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent which owns this collection of conversion workspaces. - * @param string $conversionWorkspaceId Required. The ID of the conversion workspace to create. - * @param ConversionWorkspace $conversionWorkspace Required. Represents a conversion workspace object. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * A unique ID used to identify the request. If the server receives two - * requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 createConversionWorkspace($parent, $conversionWorkspaceId, $conversionWorkspace, array $optionalArgs = []) - { - $request = new CreateConversionWorkspaceRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setConversionWorkspaceId($conversionWorkspaceId); - $request->setConversionWorkspace($conversionWorkspace); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateConversionWorkspace', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a new mapping rule for a given conversion workspace. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $mappingRuleId = 'mapping_rule_id'; - * $mappingRule = new MappingRule(); - * $response = $dataMigrationServiceClient->createMappingRule($formattedParent, $mappingRuleId, $mappingRule); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent which owns this collection of mapping rules. - * @param string $mappingRuleId Required. The ID of the rule to create. - * @param MappingRule $mappingRule Required. Represents a [mapping rule] - * (https://cloud.google.com/database-migration/reference/rest/v1/projects.locations.mappingRules) - * object. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * A unique ID used to identify the request. If the server receives two - * requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\CloudDms\V1\MappingRule - * - * @throws ApiException if the remote call fails - */ - public function createMappingRule($parent, $mappingRuleId, $mappingRule, array $optionalArgs = []) - { - $request = new CreateMappingRuleRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setMappingRuleId($mappingRuleId); - $request->setMappingRule($mappingRule); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateMappingRule', MappingRule::class, $optionalArgs, $request)->wait(); - } - - /** - * Creates a new migration job in a given project and location. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $migrationJobId = 'migration_job_id'; - * $migrationJob = new MigrationJob(); - * $operationResponse = $dataMigrationServiceClient->createMigrationJob($formattedParent, $migrationJobId, $migrationJob); - * $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 = $dataMigrationServiceClient->createMigrationJob($formattedParent, $migrationJobId, $migrationJob); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'createMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent which owns this collection of migration jobs. - * @param string $migrationJobId Required. The ID of the instance to create. - * @param MigrationJob $migrationJob Required. Represents a [migration - * job](https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.migrationJobs) - * object. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A unique ID used to identify the request. If the server receives - * two requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 createMigrationJob($parent, $migrationJobId, $migrationJob, array $optionalArgs = []) - { - $request = new CreateMigrationJobRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setMigrationJobId($migrationJobId); - $request->setMigrationJob($migrationJob); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a new private connection in a given project and location. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $privateConnectionId = 'private_connection_id'; - * $privateConnection = new PrivateConnection(); - * $operationResponse = $dataMigrationServiceClient->createPrivateConnection($formattedParent, $privateConnectionId, $privateConnection); - * $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 = $dataMigrationServiceClient->createPrivateConnection($formattedParent, $privateConnectionId, $privateConnection); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'createPrivateConnection'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent that owns the collection of PrivateConnections. - * @param string $privateConnectionId Required. The private connection identifier. - * @param PrivateConnection $privateConnection Required. The private connection resource to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A unique ID used to identify the request. If the server receives - * two requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type bool $skipValidation - * Optional. If set to true, will skip validations. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 createPrivateConnection($parent, $privateConnectionId, $privateConnection, array $optionalArgs = []) - { - $request = new CreatePrivateConnectionRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setPrivateConnectionId($privateConnectionId); - $request->setPrivateConnection($privateConnection); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['skipValidation'])) { - $request->setSkipValidation($optionalArgs['skipValidation']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreatePrivateConnection', $optionalArgs, $request, $this->getOperationsClient())->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. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - * $operationResponse = $dataMigrationServiceClient->deleteConnectionProfile($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 = $dataMigrationServiceClient->deleteConnectionProfile($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'deleteConnectionProfile'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the connection profile resource to delete. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * A unique ID used to identify the request. If the server receives two - * requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type bool $force - * In case of force delete, the CloudSQL replica database is also deleted - * (only for CloudSQL connection profile). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deleteConnectionProfile($name, array $optionalArgs = []) - { - $request = new DeleteConnectionProfileRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('DeleteConnectionProfile', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes a single conversion workspace. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $operationResponse = $dataMigrationServiceClient->deleteConversionWorkspace($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 = $dataMigrationServiceClient->deleteConversionWorkspace($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'deleteConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the conversion workspace resource to delete. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * A unique ID used to identify the request. If the server receives two - * requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type bool $force - * Force delete the conversion workspace, even if there's a running migration - * that is using the workspace. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deleteConversionWorkspace($name, array $optionalArgs = []) - { - $request = new DeleteConversionWorkspaceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('DeleteConversionWorkspace', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes a single mapping rule. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $dataMigrationServiceClient->deleteMappingRule($formattedName); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the mapping rule resource to delete. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A unique ID used to identify the request. If the server receives - * two requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 deleteMappingRule($name, array $optionalArgs = []) - { - $request = new DeleteMappingRuleRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteMappingRule', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes a single migration job. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - * $operationResponse = $dataMigrationServiceClient->deleteMigrationJob($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 = $dataMigrationServiceClient->deleteMigrationJob($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'deleteMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the migration job resource to delete. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * A unique ID used to identify the request. If the server receives two - * requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type bool $force - * The destination CloudSQL connection profile is always deleted with the - * migration job. In case of force delete, the destination CloudSQL replica - * database is also deleted. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deleteMigrationJob($name, array $optionalArgs = []) - { - $request = new DeleteMigrationJobRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('DeleteMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes a single Database Migration Service private connection. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - * $operationResponse = $dataMigrationServiceClient->deletePrivateConnection($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 = $dataMigrationServiceClient->deletePrivateConnection($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'deletePrivateConnection'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the private connection to delete. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A unique ID used to identify the request. If the server receives - * two requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deletePrivateConnection($name, array $optionalArgs = []) - { - $request = new DeletePrivateConnectionRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('DeletePrivateConnection', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Retrieves a list of committed revisions of a specific conversion - * workspace. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedConversionWorkspace = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $response = $dataMigrationServiceClient->describeConversionWorkspaceRevisions($formattedConversionWorkspace); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $conversionWorkspace Required. Name of the conversion workspace resource whose revisions are - * listed. Must be in the form of: - * projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. - * @param array $optionalArgs { - * Optional. - * - * @type string $commitId - * Optional. Optional filter to request a specific commit ID. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\CloudDms\V1\DescribeConversionWorkspaceRevisionsResponse - * - * @throws ApiException if the remote call fails - */ - public function describeConversionWorkspaceRevisions($conversionWorkspace, array $optionalArgs = []) - { - $request = new DescribeConversionWorkspaceRevisionsRequest(); - $requestParamHeaders = []; - $request->setConversionWorkspace($conversionWorkspace); - $requestParamHeaders['conversion_workspace'] = $conversionWorkspace; - if (isset($optionalArgs['commitId'])) { - $request->setCommitId($optionalArgs['commitId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DescribeConversionWorkspaceRevisions', DescribeConversionWorkspaceRevisionsResponse::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedConversionWorkspace = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * // Iterate over pages of elements - * $pagedResponse = $dataMigrationServiceClient->describeDatabaseEntities($formattedConversionWorkspace); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataMigrationServiceClient->describeDatabaseEntities($formattedConversionWorkspace); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $conversionWorkspace Required. Name of the conversion workspace resource whose database entities - * are described. Must be in the form of: - * projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. - * @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 int $tree - * Required. The tree to fetch. - * For allowed values, use constants defined on {@see \Google\Cloud\CloudDms\V1\DescribeDatabaseEntitiesRequest\DBTreeType} - * @type bool $uncommitted - * Optional. Whether to retrieve the latest committed version of the entities - * or the latest version. This field is ignored if a specific commit_id is - * specified. - * @type string $commitId - * Optional. Request a specific commit ID. If not specified, the entities from - * the latest commit are returned. - * @type string $filter - * Optional. Filter the returned entities based on AIP-160 standard. - * @type int $view - * Optional. Results view based on AIP-157 - * For allowed values, use constants defined on {@see \Google\Cloud\CloudDms\V1\DatabaseEntityView} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 describeDatabaseEntities($conversionWorkspace, array $optionalArgs = []) - { - $request = new DescribeDatabaseEntitiesRequest(); - $requestParamHeaders = []; - $request->setConversionWorkspace($conversionWorkspace); - $requestParamHeaders['conversion_workspace'] = $conversionWorkspace; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['tree'])) { - $request->setTree($optionalArgs['tree']); - } - - if (isset($optionalArgs['uncommitted'])) { - $request->setUncommitted($optionalArgs['uncommitted']); - } - - if (isset($optionalArgs['commitId'])) { - $request->setCommitId($optionalArgs['commitId']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('DescribeDatabaseEntities', $optionalArgs, DescribeDatabaseEntitiesResponse::class, $request); - } - - /** - * Fetches a set of static IP addresses that need to be allowlisted by the - * customer when using the static-IP connectivity method. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $dataMigrationServiceClient->fetchStaticIps($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataMigrationServiceClient->fetchStaticIps($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name for the location for which static IPs should be - * returned. Must be in the format `projects/*/locations/*`. - * @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 fetchStaticIps($name, array $optionalArgs = []) - { - $request = new FetchStaticIpsRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - 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('FetchStaticIps', $optionalArgs, FetchStaticIpsResponse::class, $request); - } - - /** - * Generate a SSH configuration script to configure the reverse SSH - * connectivity. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $vm = 'vm'; - * $response = $dataMigrationServiceClient->generateSshScript($vm); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $vm Required. Bastion VM Instance name to use or to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $migrationJob - * Name of the migration job resource to generate the SSH script. - * @type VmCreationConfig $vmCreationConfig - * The VM creation configuration - * @type VmSelectionConfig $vmSelectionConfig - * The VM selection configuration - * @type int $vmPort - * The port that will be open on the bastion host. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\CloudDms\V1\SshScript - * - * @throws ApiException if the remote call fails - */ - public function generateSshScript($vm, array $optionalArgs = []) - { - $request = new GenerateSshScriptRequest(); - $requestParamHeaders = []; - $request->setVm($vm); - if (isset($optionalArgs['migrationJob'])) { - $request->setMigrationJob($optionalArgs['migrationJob']); - $requestParamHeaders['migration_job'] = $optionalArgs['migrationJob']; - } - - if (isset($optionalArgs['vmCreationConfig'])) { - $request->setVmCreationConfig($optionalArgs['vmCreationConfig']); - } - - if (isset($optionalArgs['vmSelectionConfig'])) { - $request->setVmSelectionConfig($optionalArgs['vmSelectionConfig']); - } - - if (isset($optionalArgs['vmPort'])) { - $request->setVmPort($optionalArgs['vmPort']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GenerateSshScript', SshScript::class, $optionalArgs, $request)->wait(); - } - - /** - * Generate a TCP Proxy configuration script to configure a cloud-hosted VM - * running a TCP Proxy. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $vmName = 'vm_name'; - * $vmMachineType = 'vm_machine_type'; - * $vmSubnet = 'vm_subnet'; - * $response = $dataMigrationServiceClient->generateTcpProxyScript($vmName, $vmMachineType, $vmSubnet); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $vmName Required. The name of the Compute instance that will host the proxy. - * @param string $vmMachineType Required. The type of the Compute instance that will host the proxy. - * @param string $vmSubnet Required. The name of the subnet the Compute instance will use for private - * connectivity. Must be supplied in the form of - * projects/{project}/regions/{region}/subnetworks/{subnetwork}. - * Note: the region for the subnet must match the Compute instance region. - * @param array $optionalArgs { - * Optional. - * - * @type string $migrationJob - * Name of the migration job resource to generate the TCP Proxy script. - * @type string $vmZone - * Optional. The Google Cloud Platform zone to create the VM in. The fully - * qualified name of the zone must be specified, including the region name, - * for example "us-central1-b". If not specified, uses the "-b" zone of the - * destination Connection Profile's region. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\CloudDms\V1\TcpProxyScript - * - * @throws ApiException if the remote call fails - */ - public function generateTcpProxyScript($vmName, $vmMachineType, $vmSubnet, array $optionalArgs = []) - { - $request = new GenerateTcpProxyScriptRequest(); - $requestParamHeaders = []; - $request->setVmName($vmName); - $request->setVmMachineType($vmMachineType); - $request->setVmSubnet($vmSubnet); - if (isset($optionalArgs['migrationJob'])) { - $request->setMigrationJob($optionalArgs['migrationJob']); - $requestParamHeaders['migration_job'] = $optionalArgs['migrationJob']; - } - - if (isset($optionalArgs['vmZone'])) { - $request->setVmZone($optionalArgs['vmZone']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GenerateTcpProxyScript', TcpProxyScript::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets details of a single connection profile. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - * $response = $dataMigrationServiceClient->getConnectionProfile($formattedName); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the connection profile resource to get. - * @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\CloudDms\V1\ConnectionProfile - * - * @throws ApiException if the remote call fails - */ - public function getConnectionProfile($name, array $optionalArgs = []) - { - $request = new GetConnectionProfileRequest(); - $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('GetConnectionProfile', ConnectionProfile::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets details of a single conversion workspace. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $response = $dataMigrationServiceClient->getConversionWorkspace($formattedName); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the conversion workspace resource to get. - * @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\CloudDms\V1\ConversionWorkspace - * - * @throws ApiException if the remote call fails - */ - public function getConversionWorkspace($name, array $optionalArgs = []) - { - $request = new GetConversionWorkspaceRequest(); - $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('GetConversionWorkspace', ConversionWorkspace::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the details of a mapping rule. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->mappingRuleName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]', '[MAPPING_RULE]'); - * $response = $dataMigrationServiceClient->getMappingRule($formattedName); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the mapping rule resource to get. - * Example: conversionWorkspaces/123/mappingRules/rule123 - * - * In order to retrieve a previous revision of the mapping rule, also provide - * the revision ID. - * Example: - * conversionWorkspace/123/mappingRules/rule123@c7cfa2a8c7cfa2a8c7cfa2a8c7cfa2a8 - * @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\CloudDms\V1\MappingRule - * - * @throws ApiException if the remote call fails - */ - public function getMappingRule($name, array $optionalArgs = []) - { - $request = new GetMappingRuleRequest(); - $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('GetMappingRule', MappingRule::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets details of a single migration job. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - * $response = $dataMigrationServiceClient->getMigrationJob($formattedName); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the migration job resource to get. - * @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\CloudDms\V1\MigrationJob - * - * @throws ApiException if the remote call fails - */ - public function getMigrationJob($name, array $optionalArgs = []) - { - $request = new GetMigrationJobRequest(); - $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('GetMigrationJob', MigrationJob::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets details of a single private connection. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - * $response = $dataMigrationServiceClient->getPrivateConnection($formattedName); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the private connection to get. - * @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\CloudDms\V1\PrivateConnection - * - * @throws ApiException if the remote call fails - */ - public function getPrivateConnection($name, array $optionalArgs = []) - { - $request = new GetPrivateConnectionRequest(); - $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('GetPrivateConnection', PrivateConnection::class, $optionalArgs, $request)->wait(); - } - - /** - * Imports the mapping rules for a given conversion workspace. - * Supports various formats of external rules files. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $operationResponse = $dataMigrationServiceClient->importMappingRules($formattedParent); - * $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 = $dataMigrationServiceClient->importMappingRules($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'importMappingRules'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Name of the conversion workspace resource to import the rules to - * in the form of: - * projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. - * @param array $optionalArgs { - * Optional. - * - * @type int $rulesFormat - * Required. The format of the rules content file. - * For allowed values, use constants defined on {@see \Google\Cloud\CloudDms\V1\ImportRulesFileFormat} - * @type RulesFile[] $rulesFiles - * Required. One or more rules files. - * @type bool $autoCommit - * Required. Should the conversion workspace be committed automatically after - * the import operation. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 importMappingRules($parent, array $optionalArgs = []) - { - $request = new ImportMappingRulesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['rulesFormat'])) { - $request->setRulesFormat($optionalArgs['rulesFormat']); - } - - if (isset($optionalArgs['rulesFiles'])) { - $request->setRulesFiles($optionalArgs['rulesFiles']); - } - - if (isset($optionalArgs['autoCommit'])) { - $request->setAutoCommit($optionalArgs['autoCommit']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ImportMappingRules', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Retrieves a list of all connection profiles in a given project and - * location. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $dataMigrationServiceClient->listConnectionProfiles($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataMigrationServiceClient->listConnectionProfiles($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent which owns this collection of connection profiles. - * @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 string $filter - * A filter expression that filters connection profiles listed in the - * response. The expression must specify the field name, a comparison - * operator, and the value that you want to use for filtering. The value must - * be a string, a number, or a boolean. The comparison operator must be either - * =, !=, >, or <. For example, list connection profiles created this year by - * specifying **createTime %gt; 2020-01-01T00:00:00.000000000Z**. You can - * also filter nested fields. For example, you could specify **mySql.username - * = %lt;my_username%gt;** to list all connection profiles configured to - * connect with a specific username. - * @type string $orderBy - * A comma-separated list of fields to order results according to. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listConnectionProfiles($parent, array $optionalArgs = []) - { - $request = new ListConnectionProfilesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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('ListConnectionProfiles', $optionalArgs, ListConnectionProfilesResponse::class, $request); - } - - /** - * Lists conversion workspaces in a given project and location. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $dataMigrationServiceClient->listConversionWorkspaces($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataMigrationServiceClient->listConversionWorkspaces($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent which owns this collection of conversion workspaces. - * @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 string $filter - * A filter expression that filters conversion workspaces listed in the - * response. The expression must specify the field name, a comparison - * operator, and the value that you want to use for filtering. The value must - * be a string, a number, or a boolean. The comparison operator must be either - * =, !=, >, or <. For example, list conversion workspaces created this year - * by specifying **createTime %gt; 2020-01-01T00:00:00.000000000Z.** You can - * also filter nested fields. For example, you could specify - * **source.version = "12.c.1"** to select all conversion workspaces with - * source database version equal to 12.c.1. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listConversionWorkspaces($parent, array $optionalArgs = []) - { - $request = new ListConversionWorkspacesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListConversionWorkspaces', $optionalArgs, ListConversionWorkspacesResponse::class, $request); - } - - /** - * Lists the mapping rules for a specific conversion workspace. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * // Iterate over pages of elements - * $pagedResponse = $dataMigrationServiceClient->listMappingRules($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataMigrationServiceClient->listMappingRules($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Name of the conversion workspace resource whose mapping rules are - * listed in the form of: - * projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. - * @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 listMappingRules($parent, array $optionalArgs = []) - { - $request = new ListMappingRulesRequest(); - $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('ListMappingRules', $optionalArgs, ListMappingRulesResponse::class, $request); - } - - /** - * Lists migration jobs in a given project and location. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $dataMigrationServiceClient->listMigrationJobs($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataMigrationServiceClient->listMigrationJobs($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent which owns this collection of migrationJobs. - * @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 string $filter - * A filter expression that filters migration jobs listed in the response. - * The expression must specify the field name, a comparison operator, and the - * value that you want to use for filtering. The value must be a string, - * a number, or a boolean. The comparison operator must be - * either =, !=, >, or <. For example, list migration jobs created this year - * by specifying **createTime %gt; 2020-01-01T00:00:00.000000000Z.** - * You can also filter nested fields. For example, you could specify - * **reverseSshConnectivity.vmIp = "1.2.3.4"** to select all migration - * jobs connecting through the specific SSH tunnel bastion. - * @type string $orderBy - * Sort the results based on the migration job name. - * Valid values are: "name", "name asc", and "name desc". - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listMigrationJobs($parent, array $optionalArgs = []) - { - $request = new ListMigrationJobsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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('ListMigrationJobs', $optionalArgs, ListMigrationJobsResponse::class, $request); - } - - /** - * Retrieves a list of private connections in a given project and location. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedParent = $dataMigrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $dataMigrationServiceClient->listPrivateConnections($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $dataMigrationServiceClient->listPrivateConnections($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent that owns the collection of private connections. - * @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 string $filter - * A filter expression that filters private connections listed in the - * response. The expression must specify the field name, a comparison - * operator, and the value that you want to use for filtering. The value must - * be a string, a number, or a boolean. The comparison operator must be either - * =, !=, >, or <. For example, list private connections created this year by - * specifying **createTime %gt; 2021-01-01T00:00:00.000000000Z**. - * @type string $orderBy - * Order by fields for the result. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listPrivateConnections($parent, array $optionalArgs = []) - { - $request = new ListPrivateConnectionsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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('ListPrivateConnections', $optionalArgs, ListPrivateConnectionsResponse::class, $request); - } - - /** - * Promote a migration job, stopping replication to the destination and - * promoting the destination to be a standalone database. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $operationResponse = $dataMigrationServiceClient->promoteMigrationJob(); - * $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 = $dataMigrationServiceClient->promoteMigrationJob(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'promoteMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the migration job resource to promote. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 promoteMigrationJob(array $optionalArgs = []) - { - $request = new PromoteMigrationJobRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('PromoteMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Restart a stopped or failed migration job, resetting the destination - * instance to its original state and starting the migration process from - * scratch. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $operationResponse = $dataMigrationServiceClient->restartMigrationJob(); - * $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 = $dataMigrationServiceClient->restartMigrationJob(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'restartMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the migration job resource to restart. - * @type bool $skipValidation - * Optional. Restart the migration job without running prior configuration - * verification. Defaults to `false`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 restartMigrationJob(array $optionalArgs = []) - { - $request = new RestartMigrationJobRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['skipValidation'])) { - $request->setSkipValidation($optionalArgs['skipValidation']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('RestartMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Resume a migration job that is currently stopped and is resumable (was - * stopped during CDC phase). - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $operationResponse = $dataMigrationServiceClient->resumeMigrationJob(); - * $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 = $dataMigrationServiceClient->resumeMigrationJob(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'resumeMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the migration job resource to resume. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 resumeMigrationJob(array $optionalArgs = []) - { - $request = new ResumeMigrationJobRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ResumeMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Rolls back a conversion workspace to the last committed snapshot. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedName = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $operationResponse = $dataMigrationServiceClient->rollbackConversionWorkspace($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 = $dataMigrationServiceClient->rollbackConversionWorkspace($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'rollbackConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the conversion workspace resource to roll back to. - * @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 rollbackConversionWorkspace($name, array $optionalArgs = []) - { - $request = new RollbackConversionWorkspaceRequest(); - $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('RollbackConversionWorkspace', $optionalArgs, $request, $this->getOperationsClient())->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. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $formattedConversionWorkspace = $dataMigrationServiceClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - * $response = $dataMigrationServiceClient->searchBackgroundJobs($formattedConversionWorkspace); - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param string $conversionWorkspace Required. Name of the conversion workspace resource whose jobs are listed, - * in the form of: - * projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. - * @param array $optionalArgs { - * Optional. - * - * @type bool $returnMostRecentPerJobType - * Optional. Whether or not to return just the most recent job per job type, - * @type int $maxSize - * Optional. The maximum number of jobs to return. The service may return - * fewer than this value. If unspecified, at most 100 jobs are - * returned. The maximum value is 100; values above 100 are coerced to - * 100. - * @type Timestamp $completedUntilTime - * Optional. If provided, only returns jobs that completed until (not - * including) the given timestamp. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\CloudDms\V1\SearchBackgroundJobsResponse - * - * @throws ApiException if the remote call fails - */ - public function searchBackgroundJobs($conversionWorkspace, array $optionalArgs = []) - { - $request = new SearchBackgroundJobsRequest(); - $requestParamHeaders = []; - $request->setConversionWorkspace($conversionWorkspace); - $requestParamHeaders['conversion_workspace'] = $conversionWorkspace; - if (isset($optionalArgs['returnMostRecentPerJobType'])) { - $request->setReturnMostRecentPerJobType($optionalArgs['returnMostRecentPerJobType']); - } - - if (isset($optionalArgs['maxSize'])) { - $request->setMaxSize($optionalArgs['maxSize']); - } - - if (isset($optionalArgs['completedUntilTime'])) { - $request->setCompletedUntilTime($optionalArgs['completedUntilTime']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('SearchBackgroundJobs', SearchBackgroundJobsResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Imports a snapshot of the source database into the - * conversion workspace. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $operationResponse = $dataMigrationServiceClient->seedConversionWorkspace(); - * $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 = $dataMigrationServiceClient->seedConversionWorkspace(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'seedConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the conversion workspace resource to seed with new database - * structure, in the form of: - * projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. - * @type bool $autoCommit - * Should the conversion workspace be committed automatically after the - * seed operation. - * @type string $sourceConnectionProfile - * Optional. Fully qualified (Uri) name of the source connection profile. - * @type string $destinationConnectionProfile - * Optional. Fully qualified (Uri) name of the destination connection - * profile. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 seedConversionWorkspace(array $optionalArgs = []) - { - $request = new SeedConversionWorkspaceRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['autoCommit'])) { - $request->setAutoCommit($optionalArgs['autoCommit']); - } - - if (isset($optionalArgs['sourceConnectionProfile'])) { - $request->setSourceConnectionProfile($optionalArgs['sourceConnectionProfile']); - } - - if (isset($optionalArgs['destinationConnectionProfile'])) { - $request->setDestinationConnectionProfile($optionalArgs['destinationConnectionProfile']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('SeedConversionWorkspace', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Start an already created migration job. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $operationResponse = $dataMigrationServiceClient->startMigrationJob(); - * $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 = $dataMigrationServiceClient->startMigrationJob(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'startMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the migration job resource to start. - * @type bool $skipValidation - * Optional. Start the migration job without running prior configuration - * verification. Defaults to `false`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 startMigrationJob(array $optionalArgs = []) - { - $request = new StartMigrationJobRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['skipValidation'])) { - $request->setSkipValidation($optionalArgs['skipValidation']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('StartMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Stops a running migration job. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $operationResponse = $dataMigrationServiceClient->stopMigrationJob(); - * $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 = $dataMigrationServiceClient->stopMigrationJob(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'stopMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the migration job resource to stop. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 stopMigrationJob(array $optionalArgs = []) - { - $request = new StopMigrationJobRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('StopMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Update the configuration of a single connection profile. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $connectionProfile = new ConnectionProfile(); - * $operationResponse = $dataMigrationServiceClient->updateConnectionProfile($updateMask, $connectionProfile); - * $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 = $dataMigrationServiceClient->updateConnectionProfile($updateMask, $connectionProfile); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'updateConnectionProfile'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Field mask is used to specify the fields to be overwritten by the - * update in the conversion workspace resource. - * @param ConnectionProfile $connectionProfile Required. The connection profile parameters to update. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A unique ID used to identify the request. If the server receives - * two requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type bool $validateOnly - * Optional. Only validate the connection profile, but don't update any - * resources. The default is false. Only supported for Oracle connection - * profiles. - * @type bool $skipValidation - * Optional. Update the connection profile without validating it. - * The default is false. - * Only supported for Oracle connection profiles. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 updateConnectionProfile($updateMask, $connectionProfile, array $optionalArgs = []) - { - $request = new UpdateConnectionProfileRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setConnectionProfile($connectionProfile); - $requestParamHeaders['connection_profile.name'] = $connectionProfile->getName(); - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - if (isset($optionalArgs['skipValidation'])) { - $request->setSkipValidation($optionalArgs['skipValidation']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateConnectionProfile', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates the parameters of a single conversion workspace. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $conversionWorkspace = new ConversionWorkspace(); - * $operationResponse = $dataMigrationServiceClient->updateConversionWorkspace($updateMask, $conversionWorkspace); - * $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 = $dataMigrationServiceClient->updateConversionWorkspace($updateMask, $conversionWorkspace); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'updateConversionWorkspace'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Field mask is used to specify the fields to be overwritten by the - * update in the conversion workspace resource. - * @param ConversionWorkspace $conversionWorkspace Required. The conversion workspace parameters to update. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * A unique ID used to identify the request. If the server receives two - * requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 updateConversionWorkspace($updateMask, $conversionWorkspace, array $optionalArgs = []) - { - $request = new UpdateConversionWorkspaceRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setConversionWorkspace($conversionWorkspace); - $requestParamHeaders['conversion_workspace.name'] = $conversionWorkspace->getName(); - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateConversionWorkspace', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates the parameters of a single migration job. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $migrationJob = new MigrationJob(); - * $operationResponse = $dataMigrationServiceClient->updateMigrationJob($updateMask, $migrationJob); - * $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 = $dataMigrationServiceClient->updateMigrationJob($updateMask, $migrationJob); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'updateMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Field mask is used to specify the fields to be overwritten by the - * update in the conversion workspace resource. - * @param MigrationJob $migrationJob Required. The migration job parameters to update. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * A unique ID used to identify the request. If the server receives two - * requests with the same ID, then the second request is ignored. - * - * It is recommended to always set this value to a UUID. - * - * The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores - * (_), and hyphens (-). The maximum length is 40 characters. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 updateMigrationJob($updateMask, $migrationJob, array $optionalArgs = []) - { - $request = new UpdateMigrationJobRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setMigrationJob($migrationJob); - $requestParamHeaders['migration_job.name'] = $migrationJob->getName(); - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Verify a migration job, making sure the destination can reach the source - * and that all configuration and prerequisites are met. - * - * Sample code: - * ``` - * $dataMigrationServiceClient = new DataMigrationServiceClient(); - * try { - * $operationResponse = $dataMigrationServiceClient->verifyMigrationJob(); - * $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 = $dataMigrationServiceClient->verifyMigrationJob(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $dataMigrationServiceClient->resumeOperation($operationName, 'verifyMigrationJob'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $dataMigrationServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the migration job resource to verify. - * @type FieldMask $updateMask - * Optional. Field mask is used to specify the changed fields to be verified. - * It will not update the migration job. - * @type MigrationJob $migrationJob - * Optional. The changed migration job parameters to verify. - * It will not update the migration job. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 verifyMigrationJob(array $optionalArgs = []) - { - $request = new VerifyMigrationJobRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - if (isset($optionalArgs['migrationJob'])) { - $request->setMigrationJob($optionalArgs['migrationJob']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('VerifyMigrationJob', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } -} diff --git a/Dms/src/V1/GenerateSshScriptRequest.php b/Dms/src/V1/GenerateSshScriptRequest.php index 06ac5f779390..aa98f9ad72e9 100644 --- a/Dms/src/V1/GenerateSshScriptRequest.php +++ b/Dms/src/V1/GenerateSshScriptRequest.php @@ -20,19 +20,19 @@ class GenerateSshScriptRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string migration_job = 1 [(.google.api.resource_reference) = { */ - private $migration_job = ''; + protected $migration_job = ''; /** * Required. Bastion VM Instance name to use or to create. * * Generated from protobuf field string vm = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $vm = ''; + protected $vm = ''; /** * The port that will be open on the bastion host. * * Generated from protobuf field int32 vm_port = 3; */ - private $vm_port = 0; + protected $vm_port = 0; protected $vm_config; /** diff --git a/Dms/src/V1/GenerateTcpProxyScriptRequest.php b/Dms/src/V1/GenerateTcpProxyScriptRequest.php index 5f30d085dc4a..d972498955bc 100644 --- a/Dms/src/V1/GenerateTcpProxyScriptRequest.php +++ b/Dms/src/V1/GenerateTcpProxyScriptRequest.php @@ -20,19 +20,19 @@ class GenerateTcpProxyScriptRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string migration_job = 1 [(.google.api.resource_reference) = { */ - private $migration_job = ''; + protected $migration_job = ''; /** * Required. The name of the Compute instance that will host the proxy. * * Generated from protobuf field string vm_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $vm_name = ''; + protected $vm_name = ''; /** * Required. The type of the Compute instance that will host the proxy. * * Generated from protobuf field string vm_machine_type = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $vm_machine_type = ''; + protected $vm_machine_type = ''; /** * Optional. The Google Cloud Platform zone to create the VM in. The fully * qualified name of the zone must be specified, including the region name, @@ -41,7 +41,7 @@ class GenerateTcpProxyScriptRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vm_zone = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $vm_zone = ''; + protected $vm_zone = ''; /** * Required. The name of the subnet the Compute instance will use for private * connectivity. Must be supplied in the form of @@ -50,7 +50,7 @@ class GenerateTcpProxyScriptRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vm_subnet = 5 [(.google.api.field_behavior) = REQUIRED]; */ - private $vm_subnet = ''; + protected $vm_subnet = ''; /** * Constructor. diff --git a/Dms/src/V1/GetConnectionProfileRequest.php b/Dms/src/V1/GetConnectionProfileRequest.php index be9b5d85597e..aa85d7175131 100644 --- a/Dms/src/V1/GetConnectionProfileRequest.php +++ b/Dms/src/V1/GetConnectionProfileRequest.php @@ -20,7 +20,7 @@ class GetConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the connection profile resource to get. Please see diff --git a/Dms/src/V1/GetConversionWorkspaceRequest.php b/Dms/src/V1/GetConversionWorkspaceRequest.php index 65b30b2728eb..7fc21537e5a1 100644 --- a/Dms/src/V1/GetConversionWorkspaceRequest.php +++ b/Dms/src/V1/GetConversionWorkspaceRequest.php @@ -20,7 +20,7 @@ class GetConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the conversion workspace resource to get. Please see diff --git a/Dms/src/V1/GetMappingRuleRequest.php b/Dms/src/V1/GetMappingRuleRequest.php index 3bd88cca3d08..9c53c17e6471 100644 --- a/Dms/src/V1/GetMappingRuleRequest.php +++ b/Dms/src/V1/GetMappingRuleRequest.php @@ -25,7 +25,7 @@ class GetMappingRuleRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the mapping rule resource to get. diff --git a/Dms/src/V1/GetMigrationJobRequest.php b/Dms/src/V1/GetMigrationJobRequest.php index 18f4fb3b70f9..96d6287b7d56 100644 --- a/Dms/src/V1/GetMigrationJobRequest.php +++ b/Dms/src/V1/GetMigrationJobRequest.php @@ -20,7 +20,7 @@ class GetMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the migration job resource to get. Please see diff --git a/Dms/src/V1/GetPrivateConnectionRequest.php b/Dms/src/V1/GetPrivateConnectionRequest.php index 3b3d013701e4..18cba2337233 100644 --- a/Dms/src/V1/GetPrivateConnectionRequest.php +++ b/Dms/src/V1/GetPrivateConnectionRequest.php @@ -20,7 +20,7 @@ class GetPrivateConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the private connection to get. Please see diff --git a/Dms/src/V1/ImportMappingRulesRequest.php b/Dms/src/V1/ImportMappingRulesRequest.php index ccfa13bdcf4f..5801e1f227d2 100644 --- a/Dms/src/V1/ImportMappingRulesRequest.php +++ b/Dms/src/V1/ImportMappingRulesRequest.php @@ -22,13 +22,13 @@ class ImportMappingRulesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The format of the rules content file. * * Generated from protobuf field .google.cloud.clouddms.v1.ImportRulesFileFormat rules_format = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $rules_format = 0; + protected $rules_format = 0; /** * Required. One or more rules files. * @@ -41,7 +41,7 @@ class ImportMappingRulesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool auto_commit = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $auto_commit = false; + protected $auto_commit = false; /** * Constructor. diff --git a/Dms/src/V1/ImportMappingRulesRequest/RulesFile.php b/Dms/src/V1/ImportMappingRulesRequest/RulesFile.php index e7be0baa524e..da8fc9505e80 100644 --- a/Dms/src/V1/ImportMappingRulesRequest/RulesFile.php +++ b/Dms/src/V1/ImportMappingRulesRequest/RulesFile.php @@ -22,13 +22,13 @@ class RulesFile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string rules_source_filename = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $rules_source_filename = ''; + protected $rules_source_filename = ''; /** * Required. The text content of the rules that needs to be converted. * * Generated from protobuf field string rules_content = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $rules_content = ''; + protected $rules_content = ''; /** * Constructor. diff --git a/Dms/src/V1/IndexEntity.php b/Dms/src/V1/IndexEntity.php index 46a1bf694516..e57fa2563468 100644 --- a/Dms/src/V1/IndexEntity.php +++ b/Dms/src/V1/IndexEntity.php @@ -21,13 +21,13 @@ class IndexEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Type of index, for example B-TREE. * * Generated from protobuf field string type = 2; */ - private $type = ''; + protected $type = ''; /** * Table columns used as part of the Index, for example B-TREE index should * list the columns which constitutes the index. @@ -40,13 +40,13 @@ class IndexEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool unique = 4; */ - private $unique = false; + protected $unique = false; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 5; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/IntComparisonFilter.php b/Dms/src/V1/IntComparisonFilter.php index ee1d775d111a..90cca3605608 100644 --- a/Dms/src/V1/IntComparisonFilter.php +++ b/Dms/src/V1/IntComparisonFilter.php @@ -21,13 +21,13 @@ class IntComparisonFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.ValueComparison value_comparison = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $value_comparison = 0; + protected $value_comparison = 0; /** * Required. Integer compare value to be used * * Generated from protobuf field int64 value = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $value = 0; + protected $value = 0; /** * Constructor. diff --git a/Dms/src/V1/ListConnectionProfilesRequest.php b/Dms/src/V1/ListConnectionProfilesRequest.php index b8579f27310b..129b7894d2f9 100644 --- a/Dms/src/V1/ListConnectionProfilesRequest.php +++ b/Dms/src/V1/ListConnectionProfilesRequest.php @@ -20,7 +20,7 @@ class ListConnectionProfilesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of connection profiles to return. The service may return * fewer than this value. If unspecified, at most 50 connection profiles will @@ -29,7 +29,7 @@ class ListConnectionProfilesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A page token, received from a previous `ListConnectionProfiles` call. * Provide this to retrieve the subsequent page. @@ -38,7 +38,7 @@ class ListConnectionProfilesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * A filter expression that filters connection profiles listed in the * response. The expression must specify the field name, a comparison @@ -52,13 +52,13 @@ class ListConnectionProfilesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * A comma-separated list of fields to order results according to. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent which owns this collection of connection profiles. Please see diff --git a/Dms/src/V1/ListConnectionProfilesResponse.php b/Dms/src/V1/ListConnectionProfilesResponse.php index 7013a5a822bf..6e2ce3a68ecc 100644 --- a/Dms/src/V1/ListConnectionProfilesResponse.php +++ b/Dms/src/V1/ListConnectionProfilesResponse.php @@ -27,7 +27,7 @@ class ListConnectionProfilesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/Dms/src/V1/ListConversionWorkspacesRequest.php b/Dms/src/V1/ListConversionWorkspacesRequest.php index e76822d860d0..5658f4636425 100644 --- a/Dms/src/V1/ListConversionWorkspacesRequest.php +++ b/Dms/src/V1/ListConversionWorkspacesRequest.php @@ -20,14 +20,14 @@ class ListConversionWorkspacesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of conversion workspaces to return. The service may * return fewer than this value. If unspecified, at most 50 sets are returned. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The nextPageToken value received in the previous call to * conversionWorkspaces.list, used in the subsequent request to retrieve the @@ -37,7 +37,7 @@ class ListConversionWorkspacesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * A filter expression that filters conversion workspaces listed in the * response. The expression must specify the field name, a comparison @@ -51,7 +51,7 @@ class ListConversionWorkspacesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The parent which owns this collection of conversion workspaces. Please see diff --git a/Dms/src/V1/ListConversionWorkspacesResponse.php b/Dms/src/V1/ListConversionWorkspacesResponse.php index 29c120c58e86..1f507d38f97e 100644 --- a/Dms/src/V1/ListConversionWorkspacesResponse.php +++ b/Dms/src/V1/ListConversionWorkspacesResponse.php @@ -27,7 +27,7 @@ class ListConversionWorkspacesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/Dms/src/V1/ListMappingRulesRequest.php b/Dms/src/V1/ListMappingRulesRequest.php index d773b47d1b83..65ab2fa9d1c6 100644 --- a/Dms/src/V1/ListMappingRulesRequest.php +++ b/Dms/src/V1/ListMappingRulesRequest.php @@ -22,14 +22,14 @@ class ListMappingRulesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of rules to return. The service may return * fewer than this value. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The nextPageToken value received in the previous call to * mappingRules.list, used in the subsequent request to retrieve the next @@ -39,7 +39,7 @@ class ListMappingRulesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Name of the conversion workspace resource whose mapping rules are diff --git a/Dms/src/V1/ListMappingRulesResponse.php b/Dms/src/V1/ListMappingRulesResponse.php index e1d1a856cbca..970fd8c8578a 100644 --- a/Dms/src/V1/ListMappingRulesResponse.php +++ b/Dms/src/V1/ListMappingRulesResponse.php @@ -27,7 +27,7 @@ class ListMappingRulesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Dms/src/V1/ListMigrationJobsRequest.php b/Dms/src/V1/ListMigrationJobsRequest.php index 16369f43ccb5..84b342d686ba 100644 --- a/Dms/src/V1/ListMigrationJobsRequest.php +++ b/Dms/src/V1/ListMigrationJobsRequest.php @@ -20,7 +20,7 @@ class ListMigrationJobsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of migration jobs to return. The service may return * fewer than this value. If unspecified, at most 50 migration jobs will be @@ -29,7 +29,7 @@ class ListMigrationJobsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The nextPageToken value received in the previous call to * migrationJobs.list, used in the subsequent request to retrieve the next @@ -39,7 +39,7 @@ class ListMigrationJobsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * A filter expression that filters migration jobs listed in the response. * The expression must specify the field name, a comparison operator, and the @@ -53,14 +53,14 @@ class ListMigrationJobsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Sort the results based on the migration job name. * Valid values are: "name", "name asc", and "name desc". * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent which owns this collection of migrationJobs. Please see diff --git a/Dms/src/V1/ListMigrationJobsResponse.php b/Dms/src/V1/ListMigrationJobsResponse.php index 09f0c7e174a4..18a1ed93f77b 100644 --- a/Dms/src/V1/ListMigrationJobsResponse.php +++ b/Dms/src/V1/ListMigrationJobsResponse.php @@ -27,7 +27,7 @@ class ListMigrationJobsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/Dms/src/V1/ListPrivateConnectionsRequest.php b/Dms/src/V1/ListPrivateConnectionsRequest.php index 51c3dd1727b2..b1ff9cc01a51 100644 --- a/Dms/src/V1/ListPrivateConnectionsRequest.php +++ b/Dms/src/V1/ListPrivateConnectionsRequest.php @@ -21,7 +21,7 @@ class ListPrivateConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Maximum number of private connections to return. * If unspecified, at most 50 private connections that are returned. @@ -29,7 +29,7 @@ class ListPrivateConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Page token received from a previous `ListPrivateConnections` call. * Provide this to retrieve the subsequent page. @@ -39,7 +39,7 @@ class ListPrivateConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * A filter expression that filters private connections listed in the * response. The expression must specify the field name, a comparison @@ -50,13 +50,13 @@ class ListPrivateConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Order by fields for the result. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent that owns the collection of private connections. Please see diff --git a/Dms/src/V1/ListPrivateConnectionsResponse.php b/Dms/src/V1/ListPrivateConnectionsResponse.php index b748f53a6889..8631c97ed0b1 100644 --- a/Dms/src/V1/ListPrivateConnectionsResponse.php +++ b/Dms/src/V1/ListPrivateConnectionsResponse.php @@ -27,7 +27,7 @@ class ListPrivateConnectionsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/Dms/src/V1/MappingRule.php b/Dms/src/V1/MappingRule.php index d14eaa8c3f01..ff315cf24417 100644 --- a/Dms/src/V1/MappingRule.php +++ b/Dms/src/V1/MappingRule.php @@ -23,38 +23,38 @@ class MappingRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Optional. A human readable name * * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $display_name = ''; + protected $display_name = ''; /** * Optional. The mapping rule state * * Generated from protobuf field .google.cloud.clouddms.v1.MappingRule.State state = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $state = 0; + protected $state = 0; /** * Required. The rule scope * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntityType rule_scope = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $rule_scope = 0; + protected $rule_scope = 0; /** * Required. The rule filter * * Generated from protobuf field .google.cloud.clouddms.v1.MappingRuleFilter filter = 5 [(.google.api.field_behavior) = REQUIRED]; */ - private $filter = null; + protected $filter = null; /** * Required. The order in which the rule is applied. Lower order rules are * applied before higher value rules so they may end up being overridden. * * Generated from protobuf field int64 rule_order = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $rule_order = 0; + protected $rule_order = 0; /** * Output only. The revision ID of the mapping rule. * A new revision is committed whenever the mapping rule is changed in any @@ -62,13 +62,13 @@ class MappingRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string revision_id = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $revision_id = ''; + protected $revision_id = ''; /** * Output only. The timestamp that the revision was created. * * Generated from protobuf field .google.protobuf.Timestamp revision_create_time = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $revision_create_time = null; + protected $revision_create_time = null; protected $details; /** diff --git a/Dms/src/V1/MappingRuleFilter.php b/Dms/src/V1/MappingRuleFilter.php index 1df6a7166907..fdffdd682d5f 100644 --- a/Dms/src/V1/MappingRuleFilter.php +++ b/Dms/src/V1/MappingRuleFilter.php @@ -27,28 +27,28 @@ class MappingRuleFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent_entity = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $parent_entity = ''; + protected $parent_entity = ''; /** * Optional. The rule should be applied to entities whose non-qualified name * starts with the given prefix. * * Generated from protobuf field string entity_name_prefix = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $entity_name_prefix = ''; + protected $entity_name_prefix = ''; /** * Optional. The rule should be applied to entities whose non-qualified name * ends with the given suffix. * * Generated from protobuf field string entity_name_suffix = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $entity_name_suffix = ''; + protected $entity_name_suffix = ''; /** * Optional. The rule should be applied to entities whose non-qualified name * contains the given string. * * Generated from protobuf field string entity_name_contains = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $entity_name_contains = ''; + protected $entity_name_contains = ''; /** * Optional. The rule should be applied to specific entities defined by their * fully qualified names. diff --git a/Dms/src/V1/MaterializedViewEntity.php b/Dms/src/V1/MaterializedViewEntity.php index d5b0b5bc8ae1..9699528d1d6d 100644 --- a/Dms/src/V1/MaterializedViewEntity.php +++ b/Dms/src/V1/MaterializedViewEntity.php @@ -20,13 +20,13 @@ class MaterializedViewEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string sql_code = 1; */ - private $sql_code = ''; + protected $sql_code = ''; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 2; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/MigrationJob.php b/Dms/src/V1/MigrationJob.php index f316a63db900..559cec668c13 100644 --- a/Dms/src/V1/MigrationJob.php +++ b/Dms/src/V1/MigrationJob.php @@ -21,7 +21,7 @@ class MigrationJob extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. The timestamp when the migration job resource was created. * A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. @@ -29,7 +29,7 @@ class MigrationJob extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The timestamp when the migration job resource was last * updated. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. @@ -37,7 +37,7 @@ class MigrationJob extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * The resource labels for migration job to use to annotate any related * underlying resources such as Compute Engine VMs. An object containing a @@ -52,25 +52,25 @@ class MigrationJob extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 5; */ - private $display_name = ''; + protected $display_name = ''; /** * The current migration job state. * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob.State state = 6; */ - private $state = 0; + protected $state = 0; /** * Output only. The current migration job phase. * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob.Phase phase = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $phase = 0; + protected $phase = 0; /** * Required. The migration job type. * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob.Type type = 8 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = 0; + protected $type = 0; /** * The path to the dump file in Google Cloud Storage, * in the format: (gs://[BUCKET_NAME]/[OBJECT_NAME]). @@ -78,26 +78,26 @@ class MigrationJob extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string dump_path = 9; */ - private $dump_path = ''; + protected $dump_path = ''; /** * The initial dump flags. * This field and the "dump_path" field are mutually exclusive. * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob.DumpFlags dump_flags = 17; */ - private $dump_flags = null; + protected $dump_flags = null; /** * Required. The resource name (URI) of the source connection profile. * * Generated from protobuf field string source = 10 [(.google.api.field_behavior) = REQUIRED]; */ - private $source = ''; + protected $source = ''; /** * Required. The resource name (URI) of the destination connection profile. * * Generated from protobuf field string destination = 11 [(.google.api.field_behavior) = REQUIRED]; */ - private $destination = ''; + protected $destination = ''; /** * Output only. The duration of the migration job (in seconds). A duration in * seconds with up to nine fractional digits, terminated by 's'. Example: @@ -105,38 +105,38 @@ class MigrationJob extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration duration = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $duration = null; + protected $duration = null; /** * Output only. The error details in case of state FAILED. * * Generated from protobuf field .google.rpc.Status error = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $error = null; + protected $error = null; /** * The database engine type and provider of the source. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseType source_database = 14; */ - private $source_database = null; + protected $source_database = null; /** * The database engine type and provider of the destination. * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseType destination_database = 15; */ - private $destination_database = null; + protected $destination_database = null; /** * Output only. If the migration job is completed, the time when it was * completed. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * The conversion workspace used by the migration. * * Generated from protobuf field .google.cloud.clouddms.v1.ConversionWorkspaceInfo conversion_workspace = 18; */ - private $conversion_workspace = null; + protected $conversion_workspace = null; /** * This field can be used to select the entities to migrate as part of * the migration job. It uses AIP-160 notation to select a subset of the @@ -146,7 +146,7 @@ class MigrationJob extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 20; */ - private $filter = ''; + protected $filter = ''; /** * The CMEK (customer-managed encryption key) fully qualified key name used * for the migration job. @@ -162,14 +162,14 @@ class MigrationJob extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cmek_key_name = 21; */ - private $cmek_key_name = ''; + protected $cmek_key_name = ''; /** * Optional. Data dump parallelism settings used by the migration. * Currently applicable only for MySQL to Cloud SQL for MySQL migrations only. * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob.PerformanceConfig performance_config = 22 [(.google.api.field_behavior) = OPTIONAL]; */ - private $performance_config = null; + protected $performance_config = null; protected $connectivity; /** diff --git a/Dms/src/V1/MigrationJob/DumpFlag.php b/Dms/src/V1/MigrationJob/DumpFlag.php index 14844769bd83..d7e2e231fbd3 100644 --- a/Dms/src/V1/MigrationJob/DumpFlag.php +++ b/Dms/src/V1/MigrationJob/DumpFlag.php @@ -20,13 +20,13 @@ class DumpFlag extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The value of the flag. * * Generated from protobuf field string value = 2; */ - private $value = ''; + protected $value = ''; /** * Constructor. diff --git a/Dms/src/V1/MigrationJob/PerformanceConfig.php b/Dms/src/V1/MigrationJob/PerformanceConfig.php index adc55490ac53..a1fc0275b0d4 100644 --- a/Dms/src/V1/MigrationJob/PerformanceConfig.php +++ b/Dms/src/V1/MigrationJob/PerformanceConfig.php @@ -20,7 +20,7 @@ class PerformanceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob.PerformanceConfig.DumpParallelLevel dump_parallel_level = 1; */ - private $dump_parallel_level = 0; + protected $dump_parallel_level = 0; /** * Constructor. diff --git a/Dms/src/V1/MigrationJobVerificationError.php b/Dms/src/V1/MigrationJobVerificationError.php index 6ab50b73cab8..37f3d2e87393 100644 --- a/Dms/src/V1/MigrationJobVerificationError.php +++ b/Dms/src/V1/MigrationJobVerificationError.php @@ -20,20 +20,20 @@ class MigrationJobVerificationError extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJobVerificationError.ErrorCode error_code = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $error_code = 0; + protected $error_code = 0; /** * Output only. A formatted message with further details about the error and a * CTA. * * Generated from protobuf field string error_message = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $error_message = ''; + protected $error_message = ''; /** * Output only. A specific detailed error message, if supplied by the engine. * * Generated from protobuf field string error_detail_message = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $error_detail_message = ''; + protected $error_detail_message = ''; /** * Constructor. diff --git a/Dms/src/V1/MultiColumnDatatypeChange.php b/Dms/src/V1/MultiColumnDatatypeChange.php index a307d37a3393..92416ce4a3cc 100644 --- a/Dms/src/V1/MultiColumnDatatypeChange.php +++ b/Dms/src/V1/MultiColumnDatatypeChange.php @@ -29,34 +29,34 @@ class MultiColumnDatatypeChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_data_type_filter = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $source_data_type_filter = ''; + protected $source_data_type_filter = ''; /** * Required. New data type. * * Generated from protobuf field string new_data_type = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_data_type = ''; + protected $new_data_type = ''; /** * Optional. Column length - e.g. varchar (50) - if not specified and relevant * uses the source column length. * * Generated from protobuf field int64 override_length = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $override_length = 0; + protected $override_length = 0; /** * Optional. Column scale - when relevant - if not specified and relevant * uses the source column scale. * * Generated from protobuf field int32 override_scale = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $override_scale = 0; + protected $override_scale = 0; /** * Optional. Column precision - when relevant - if not specified and relevant * uses the source column precision. * * Generated from protobuf field int32 override_precision = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $override_precision = 0; + protected $override_precision = 0; /** * Optional. Column fractional seconds precision - used only for timestamp * based datatypes - if not specified and relevant uses the source column @@ -64,13 +64,13 @@ class MultiColumnDatatypeChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 override_fractional_seconds_precision = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $override_fractional_seconds_precision = 0; + protected $override_fractional_seconds_precision = 0; /** * Optional. Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 7 [(.google.api.field_behavior) = OPTIONAL]; */ - private $custom_features = null; + protected $custom_features = null; protected $source_filter; /** diff --git a/Dms/src/V1/MultiEntityRename.php b/Dms/src/V1/MultiEntityRename.php index e4d7fa704c64..4648b41e7ff7 100644 --- a/Dms/src/V1/MultiEntityRename.php +++ b/Dms/src/V1/MultiEntityRename.php @@ -28,7 +28,7 @@ class MultiEntityRename extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string new_name_pattern = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $new_name_pattern = ''; + protected $new_name_pattern = ''; /** * Optional. Additional transformation that can be done on the source entity * name before it is being used by the new_name_pattern, for example lower @@ -36,7 +36,7 @@ class MultiEntityRename extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.EntityNameTransformation source_name_transformation = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $source_name_transformation = 0; + protected $source_name_transformation = 0; /** * Constructor. diff --git a/Dms/src/V1/MySqlConnectionProfile.php b/Dms/src/V1/MySqlConnectionProfile.php index f8827bbb9a3e..2a697f4de4c7 100644 --- a/Dms/src/V1/MySqlConnectionProfile.php +++ b/Dms/src/V1/MySqlConnectionProfile.php @@ -20,13 +20,13 @@ class MySqlConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string host = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $host = ''; + protected $host = ''; /** * Required. The network port of the source MySQL database. * * Generated from protobuf field int32 port = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $port = 0; + protected $port = 0; /** * Required. The username that Database Migration Service will use to connect * to the database. The value is encrypted when stored in Database Migration @@ -34,7 +34,7 @@ class MySqlConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string username = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $username = ''; + protected $username = ''; /** * Required. Input only. The password for the user that Database Migration * Service will be using to connect to the database. This field is not @@ -43,26 +43,26 @@ class MySqlConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string password = 4 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = REQUIRED]; */ - private $password = ''; + protected $password = ''; /** * Output only. Indicates If this connection profile password is stored. * * Generated from protobuf field bool password_set = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $password_set = false; + protected $password_set = false; /** * SSL configuration for the destination to connect to the source database. * * Generated from protobuf field .google.cloud.clouddms.v1.SslConfig ssl = 6; */ - private $ssl = null; + protected $ssl = null; /** * If the source is a Cloud SQL database, use this field to * provide the Cloud SQL instance ID of the source. * * Generated from protobuf field string cloud_sql_id = 7; */ - private $cloud_sql_id = ''; + protected $cloud_sql_id = ''; /** * Constructor. diff --git a/Dms/src/V1/OperationMetadata.php b/Dms/src/V1/OperationMetadata.php index 1a60c5fafff8..f74ea1e4e426 100644 --- a/Dms/src/V1/OperationMetadata.php +++ b/Dms/src/V1/OperationMetadata.php @@ -20,31 +20,31 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. Server-defined resource path for the target of the operation. * * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $target = ''; + protected $target = ''; /** * Output only. Name of the verb executed by the operation. * * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $verb = ''; + protected $verb = ''; /** * Output only. Human-readable status of the operation, if any. * * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $status_message = ''; + protected $status_message = ''; /** * Output only. Identifies whether the user has requested cancellation * of the operation. Operations that have successfully been cancelled @@ -54,13 +54,13 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $requested_cancellation = false; + protected $requested_cancellation = false; /** * Output only. API version used to start the operation. * * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $api_version = ''; + protected $api_version = ''; /** * Constructor. diff --git a/Dms/src/V1/OracleConnectionProfile.php b/Dms/src/V1/OracleConnectionProfile.php index 5a168a626df4..d0bfde4ac56d 100644 --- a/Dms/src/V1/OracleConnectionProfile.php +++ b/Dms/src/V1/OracleConnectionProfile.php @@ -21,13 +21,13 @@ class OracleConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string host = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $host = ''; + protected $host = ''; /** * Required. The network port of the source Oracle database. * * Generated from protobuf field int32 port = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $port = 0; + protected $port = 0; /** * Required. The username that Database Migration Service will use to connect * to the database. The value is encrypted when stored in Database Migration @@ -35,7 +35,7 @@ class OracleConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string username = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $username = ''; + protected $username = ''; /** * Required. Input only. The password for the user that Database Migration * Service will be using to connect to the database. This field is not @@ -44,19 +44,19 @@ class OracleConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string password = 4 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = REQUIRED]; */ - private $password = ''; + protected $password = ''; /** * Output only. Indicates whether a new password is included in the request. * * Generated from protobuf field bool password_set = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $password_set = false; + protected $password_set = false; /** * Required. Database service for the Oracle connection. * * Generated from protobuf field string database_service = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $database_service = ''; + protected $database_service = ''; /** * SSL configuration for the connection to the source Oracle database. * * Only `SERVER_ONLY` configuration is supported for Oracle SSL. @@ -64,7 +64,7 @@ class OracleConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.SslConfig ssl = 7; */ - private $ssl = null; + protected $ssl = null; protected $connectivity; /** diff --git a/Dms/src/V1/PackageEntity.php b/Dms/src/V1/PackageEntity.php index cdb330d8e439..bd46aed6c8ac 100644 --- a/Dms/src/V1/PackageEntity.php +++ b/Dms/src/V1/PackageEntity.php @@ -20,20 +20,20 @@ class PackageEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string package_sql_code = 1; */ - private $package_sql_code = ''; + protected $package_sql_code = ''; /** * The SQL code which creates the package body. If the package specification * has cursors or subprograms, then the package body is mandatory. * * Generated from protobuf field string package_body = 2; */ - private $package_body = ''; + protected $package_body = ''; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 3; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/PostgreSqlConnectionProfile.php b/Dms/src/V1/PostgreSqlConnectionProfile.php index b4e6aade6e00..1bea81a9193e 100644 --- a/Dms/src/V1/PostgreSqlConnectionProfile.php +++ b/Dms/src/V1/PostgreSqlConnectionProfile.php @@ -21,13 +21,13 @@ class PostgreSqlConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string host = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $host = ''; + protected $host = ''; /** * Required. The network port of the source PostgreSQL database. * * Generated from protobuf field int32 port = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $port = 0; + protected $port = 0; /** * Required. The username that Database Migration Service will use to connect * to the database. The value is encrypted when stored in Database Migration @@ -35,7 +35,7 @@ class PostgreSqlConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string username = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $username = ''; + protected $username = ''; /** * Required. Input only. The password for the user that Database Migration * Service will be using to connect to the database. This field is not @@ -44,33 +44,33 @@ class PostgreSqlConnectionProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string password = 4 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = REQUIRED]; */ - private $password = ''; + protected $password = ''; /** * Output only. Indicates If this connection profile password is stored. * * Generated from protobuf field bool password_set = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $password_set = false; + protected $password_set = false; /** * SSL configuration for the destination to connect to the source database. * * Generated from protobuf field .google.cloud.clouddms.v1.SslConfig ssl = 6; */ - private $ssl = null; + protected $ssl = null; /** * If the source is a Cloud SQL database, use this field to * provide the Cloud SQL instance ID of the source. * * Generated from protobuf field string cloud_sql_id = 7; */ - private $cloud_sql_id = ''; + protected $cloud_sql_id = ''; /** * Output only. If the source is a Cloud SQL database, this field indicates * the network architecture it's associated with. * * Generated from protobuf field .google.cloud.clouddms.v1.NetworkArchitecture network_architecture = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $network_architecture = 0; + protected $network_architecture = 0; protected $connectivity; /** diff --git a/Dms/src/V1/PrivateConnection.php b/Dms/src/V1/PrivateConnection.php index acdcb5e5aca4..ba828e9cedf6 100644 --- a/Dms/src/V1/PrivateConnection.php +++ b/Dms/src/V1/PrivateConnection.php @@ -21,19 +21,19 @@ class PrivateConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. The create time of the resource. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The last update time of the resource. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * The resource labels for private connections to use to annotate any related * underlying resources such as Compute Engine VMs. An object containing a @@ -48,19 +48,19 @@ class PrivateConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 5; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. The state of the private connection. * * Generated from protobuf field .google.cloud.clouddms.v1.PrivateConnection.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The error details in case of state FAILED. * * Generated from protobuf field .google.rpc.Status error = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $error = null; + protected $error = null; protected $connectivity; /** diff --git a/Dms/src/V1/PrivateConnectivity.php b/Dms/src/V1/PrivateConnectivity.php index b06f9ee16a79..83118e357071 100644 --- a/Dms/src/V1/PrivateConnectivity.php +++ b/Dms/src/V1/PrivateConnectivity.php @@ -20,7 +20,7 @@ class PrivateConnectivity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string private_connection = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $private_connection = ''; + protected $private_connection = ''; /** * Constructor. diff --git a/Dms/src/V1/PrivateServiceConnectConnectivity.php b/Dms/src/V1/PrivateServiceConnectConnectivity.php index 50bb34033700..559fb9442270 100644 --- a/Dms/src/V1/PrivateServiceConnectConnectivity.php +++ b/Dms/src/V1/PrivateServiceConnectConnectivity.php @@ -23,7 +23,7 @@ class PrivateServiceConnectConnectivity extends \Google\Protobuf\Internal\Messag * * Generated from protobuf field string service_attachment = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $service_attachment = ''; + protected $service_attachment = ''; /** * Constructor. diff --git a/Dms/src/V1/PromoteMigrationJobRequest.php b/Dms/src/V1/PromoteMigrationJobRequest.php index ff9c729fea1b..79ce30fb44ac 100644 --- a/Dms/src/V1/PromoteMigrationJobRequest.php +++ b/Dms/src/V1/PromoteMigrationJobRequest.php @@ -20,7 +20,7 @@ class PromoteMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/Dms/src/V1/RestartMigrationJobRequest.php b/Dms/src/V1/RestartMigrationJobRequest.php index d7c731a90f4a..2afab9962628 100644 --- a/Dms/src/V1/RestartMigrationJobRequest.php +++ b/Dms/src/V1/RestartMigrationJobRequest.php @@ -20,14 +20,14 @@ class RestartMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. Restart the migration job without running prior configuration * verification. Defaults to `false`. * * Generated from protobuf field bool skip_validation = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $skip_validation = false; + protected $skip_validation = false; /** * Constructor. diff --git a/Dms/src/V1/ResumeMigrationJobRequest.php b/Dms/src/V1/ResumeMigrationJobRequest.php index 97f2e162b4e8..9b03e9cf4f2f 100644 --- a/Dms/src/V1/ResumeMigrationJobRequest.php +++ b/Dms/src/V1/ResumeMigrationJobRequest.php @@ -20,7 +20,7 @@ class ResumeMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/Dms/src/V1/ReverseSshConnectivity.php b/Dms/src/V1/ReverseSshConnectivity.php index 24481f96121d..671c5e8f65f4 100644 --- a/Dms/src/V1/ReverseSshConnectivity.php +++ b/Dms/src/V1/ReverseSshConnectivity.php @@ -26,27 +26,27 @@ class ReverseSshConnectivity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vm_ip = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $vm_ip = ''; + protected $vm_ip = ''; /** * Required. The forwarding port of the virtual machine (Compute Engine) used * as the bastion server for the SSH tunnel. * * Generated from protobuf field int32 vm_port = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $vm_port = 0; + protected $vm_port = 0; /** * The name of the virtual machine (Compute Engine) used as the bastion server * for the SSH tunnel. * * Generated from protobuf field string vm = 3; */ - private $vm = ''; + protected $vm = ''; /** * The name of the VPC to peer with the Cloud SQL private network. * * Generated from protobuf field string vpc = 4; */ - private $vpc = ''; + protected $vpc = ''; /** * Constructor. diff --git a/Dms/src/V1/RollbackConversionWorkspaceRequest.php b/Dms/src/V1/RollbackConversionWorkspaceRequest.php index d0da6e922150..777cb5db0053 100644 --- a/Dms/src/V1/RollbackConversionWorkspaceRequest.php +++ b/Dms/src/V1/RollbackConversionWorkspaceRequest.php @@ -20,7 +20,7 @@ class RollbackConversionWorkspaceRequest extends \Google\Protobuf\Internal\Messa * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/Dms/src/V1/RoundToScale.php b/Dms/src/V1/RoundToScale.php index 12d37247c11d..c0c579b02cb0 100644 --- a/Dms/src/V1/RoundToScale.php +++ b/Dms/src/V1/RoundToScale.php @@ -22,7 +22,7 @@ class RoundToScale extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 scale = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $scale = 0; + protected $scale = 0; /** * Constructor. diff --git a/Dms/src/V1/SchemaEntity.php b/Dms/src/V1/SchemaEntity.php index 36f32bbcbc87..2db1398af1f2 100644 --- a/Dms/src/V1/SchemaEntity.php +++ b/Dms/src/V1/SchemaEntity.php @@ -24,7 +24,7 @@ class SchemaEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct custom_features = 1; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/SearchBackgroundJobsRequest.php b/Dms/src/V1/SearchBackgroundJobsRequest.php index f837605ccf0f..6be9319f1514 100644 --- a/Dms/src/V1/SearchBackgroundJobsRequest.php +++ b/Dms/src/V1/SearchBackgroundJobsRequest.php @@ -22,13 +22,13 @@ class SearchBackgroundJobsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string conversion_workspace = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $conversion_workspace = ''; + protected $conversion_workspace = ''; /** * Optional. Whether or not to return just the most recent job per job type, * * Generated from protobuf field bool return_most_recent_per_job_type = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $return_most_recent_per_job_type = false; + protected $return_most_recent_per_job_type = false; /** * Optional. The maximum number of jobs to return. The service may return * fewer than this value. If unspecified, at most 100 jobs are @@ -37,14 +37,14 @@ class SearchBackgroundJobsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 max_size = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $max_size = 0; + protected $max_size = 0; /** * Optional. If provided, only returns jobs that completed until (not * including) the given timestamp. * * Generated from protobuf field .google.protobuf.Timestamp completed_until_time = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $completed_until_time = null; + protected $completed_until_time = null; /** * Constructor. diff --git a/Dms/src/V1/SeedConversionWorkspaceRequest.php b/Dms/src/V1/SeedConversionWorkspaceRequest.php index a0af1b550550..fddd1daff8da 100644 --- a/Dms/src/V1/SeedConversionWorkspaceRequest.php +++ b/Dms/src/V1/SeedConversionWorkspaceRequest.php @@ -22,14 +22,14 @@ class SeedConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Should the conversion workspace be committed automatically after the * seed operation. * * Generated from protobuf field bool auto_commit = 2; */ - private $auto_commit = false; + protected $auto_commit = false; protected $seed_from; /** diff --git a/Dms/src/V1/SequenceEntity.php b/Dms/src/V1/SequenceEntity.php index 3380c18f4263..4d01f802642f 100644 --- a/Dms/src/V1/SequenceEntity.php +++ b/Dms/src/V1/SequenceEntity.php @@ -20,46 +20,46 @@ class SequenceEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 increment = 1; */ - private $increment = 0; + protected $increment = 0; /** * Start number for the sequence represented as bytes to accommodate large. * numbers * * Generated from protobuf field bytes start_value = 2; */ - private $start_value = ''; + protected $start_value = ''; /** * Maximum number for the sequence represented as bytes to accommodate large. * numbers * * Generated from protobuf field bytes max_value = 3; */ - private $max_value = ''; + protected $max_value = ''; /** * Minimum number for the sequence represented as bytes to accommodate large. * numbers * * Generated from protobuf field bytes min_value = 4; */ - private $min_value = ''; + protected $min_value = ''; /** * Indicates whether the sequence value should cycle through. * * Generated from protobuf field bool cycle = 5; */ - private $cycle = false; + protected $cycle = false; /** * Indicates number of entries to cache / precreate. * * Generated from protobuf field int64 cache = 6; */ - private $cache = 0; + protected $cache = 0; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 7; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/SetTablePrimaryKey.php b/Dms/src/V1/SetTablePrimaryKey.php index 1ac1b797adc2..a4ba97bf64ca 100644 --- a/Dms/src/V1/SetTablePrimaryKey.php +++ b/Dms/src/V1/SetTablePrimaryKey.php @@ -30,7 +30,7 @@ class SetTablePrimaryKey extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string primary_key = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $primary_key = ''; + protected $primary_key = ''; /** * Constructor. diff --git a/Dms/src/V1/SingleColumnChange.php b/Dms/src/V1/SingleColumnChange.php index b453b792f86a..2c76f2562071 100644 --- a/Dms/src/V1/SingleColumnChange.php +++ b/Dms/src/V1/SingleColumnChange.php @@ -25,81 +25,81 @@ class SingleColumnChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string data_type = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $data_type = ''; + protected $data_type = ''; /** * Optional. Charset override - instead of table level charset. * * Generated from protobuf field string charset = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $charset = ''; + protected $charset = ''; /** * Optional. Collation override - instead of table level collation. * * Generated from protobuf field string collation = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $collation = ''; + protected $collation = ''; /** * Optional. Column length - e.g. 50 as in varchar (50) - when relevant. * * Generated from protobuf field int64 length = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $length = 0; + protected $length = 0; /** * Optional. Column precision - e.g. 8 as in double (8,2) - when relevant. * * Generated from protobuf field int32 precision = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $precision = 0; + protected $precision = 0; /** * Optional. Column scale - e.g. 2 as in double (8,2) - when relevant. * * Generated from protobuf field int32 scale = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $scale = 0; + protected $scale = 0; /** * Optional. Column fractional seconds precision - e.g. 2 as in timestamp (2) * - when relevant. * * Generated from protobuf field int32 fractional_seconds_precision = 7 [(.google.api.field_behavior) = OPTIONAL]; */ - private $fractional_seconds_precision = 0; + protected $fractional_seconds_precision = 0; /** * Optional. Is the column of array type. * * Generated from protobuf field bool array = 8 [(.google.api.field_behavior) = OPTIONAL]; */ - private $array = false; + protected $array = false; /** * Optional. The length of the array, only relevant if the column type is an * array. * * Generated from protobuf field int32 array_length = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - private $array_length = 0; + protected $array_length = 0; /** * Optional. Is the column nullable. * * Generated from protobuf field bool nullable = 10 [(.google.api.field_behavior) = OPTIONAL]; */ - private $nullable = false; + protected $nullable = false; /** * Optional. Is the column auto-generated/identity. * * Generated from protobuf field bool auto_generated = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $auto_generated = false; + protected $auto_generated = false; /** * Optional. Is the column a UDT (User-defined Type). * * Generated from protobuf field bool udt = 12 [(.google.api.field_behavior) = OPTIONAL]; */ - private $udt = false; + protected $udt = false; /** * Optional. Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 13 [(.google.api.field_behavior) = OPTIONAL]; */ - private $custom_features = null; + protected $custom_features = null; /** * Optional. Specifies the list of values allowed in the column. * @@ -111,7 +111,7 @@ class SingleColumnChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string comment = 15 [(.google.api.field_behavior) = OPTIONAL]; */ - private $comment = ''; + protected $comment = ''; /** * Constructor. diff --git a/Dms/src/V1/SingleEntityRename.php b/Dms/src/V1/SingleEntityRename.php index 95f94bf2b7f2..6dc3c4092dfe 100644 --- a/Dms/src/V1/SingleEntityRename.php +++ b/Dms/src/V1/SingleEntityRename.php @@ -25,7 +25,7 @@ class SingleEntityRename extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string new_name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_name = ''; + protected $new_name = ''; /** * Constructor. diff --git a/Dms/src/V1/SinglePackageChange.php b/Dms/src/V1/SinglePackageChange.php index 6aededce97d5..af7735877533 100644 --- a/Dms/src/V1/SinglePackageChange.php +++ b/Dms/src/V1/SinglePackageChange.php @@ -23,13 +23,13 @@ class SinglePackageChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string package_description = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $package_description = ''; + protected $package_description = ''; /** * Optional. Sql code for package body * * Generated from protobuf field string package_body = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $package_body = ''; + protected $package_body = ''; /** * Constructor. diff --git a/Dms/src/V1/SourceNumericFilter.php b/Dms/src/V1/SourceNumericFilter.php index bc0f64f8dd29..d2e473a45590 100644 --- a/Dms/src/V1/SourceNumericFilter.php +++ b/Dms/src/V1/SourceNumericFilter.php @@ -21,35 +21,35 @@ class SourceNumericFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 source_min_scale_filter = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $source_min_scale_filter = 0; + protected $source_min_scale_filter = 0; /** * Optional. The filter will match columns with scale smaller than or equal to * this number. * * Generated from protobuf field int32 source_max_scale_filter = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $source_max_scale_filter = 0; + protected $source_max_scale_filter = 0; /** * Optional. The filter will match columns with precision greater than or * equal to this number. * * Generated from protobuf field int32 source_min_precision_filter = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $source_min_precision_filter = 0; + protected $source_min_precision_filter = 0; /** * Optional. The filter will match columns with precision smaller than or * equal to this number. * * Generated from protobuf field int32 source_max_precision_filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $source_max_precision_filter = 0; + protected $source_max_precision_filter = 0; /** * Required. Enum to set the option defining the datatypes numeric filter has * to be applied to * * Generated from protobuf field .google.cloud.clouddms.v1.NumericFilterOption numeric_filter_option = 5 [(.google.api.field_behavior) = REQUIRED]; */ - private $numeric_filter_option = 0; + protected $numeric_filter_option = 0; /** * Constructor. diff --git a/Dms/src/V1/SourceSqlChange.php b/Dms/src/V1/SourceSqlChange.php index 9130aea31e7f..0c5c5c21cd10 100644 --- a/Dms/src/V1/SourceSqlChange.php +++ b/Dms/src/V1/SourceSqlChange.php @@ -23,7 +23,7 @@ class SourceSqlChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string sql_code = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $sql_code = ''; + protected $sql_code = ''; /** * Constructor. diff --git a/Dms/src/V1/SourceTextFilter.php b/Dms/src/V1/SourceTextFilter.php index 455ed13b4596..ed0126ea98a1 100644 --- a/Dms/src/V1/SourceTextFilter.php +++ b/Dms/src/V1/SourceTextFilter.php @@ -21,14 +21,14 @@ class SourceTextFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 source_min_length_filter = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $source_min_length_filter = 0; + protected $source_min_length_filter = 0; /** * Optional. The filter will match columns with length smaller than or equal * to this number. * * Generated from protobuf field int64 source_max_length_filter = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $source_max_length_filter = 0; + protected $source_max_length_filter = 0; /** * Constructor. diff --git a/Dms/src/V1/SqlAclEntry.php b/Dms/src/V1/SqlAclEntry.php index 6e0af315a9c7..0cb8a536c2fd 100644 --- a/Dms/src/V1/SqlAclEntry.php +++ b/Dms/src/V1/SqlAclEntry.php @@ -20,13 +20,13 @@ class SqlAclEntry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string value = 1; */ - private $value = ''; + protected $value = ''; /** * A label to identify this entry. * * Generated from protobuf field string label = 3; */ - private $label = ''; + protected $label = ''; protected $expiration; /** diff --git a/Dms/src/V1/SqlIpConfig.php b/Dms/src/V1/SqlIpConfig.php index 5182ef1d8269..52dc2ce60d41 100644 --- a/Dms/src/V1/SqlIpConfig.php +++ b/Dms/src/V1/SqlIpConfig.php @@ -20,7 +20,7 @@ class SqlIpConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.BoolValue enable_ipv4 = 1; */ - private $enable_ipv4 = null; + protected $enable_ipv4 = null; /** * The resource link for the VPC network from which the Cloud SQL instance is * accessible for private IP. For example, @@ -29,7 +29,7 @@ class SqlIpConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string private_network = 2; */ - private $private_network = ''; + protected $private_network = ''; /** * Optional. The name of the allocated IP address range for the private IP * Cloud SQL instance. This name refers to an already allocated IP range @@ -40,13 +40,13 @@ class SqlIpConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string allocated_ip_range = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $allocated_ip_range = ''; + protected $allocated_ip_range = ''; /** * Whether SSL connections over IP should be enforced or not. * * Generated from protobuf field .google.protobuf.BoolValue require_ssl = 3; */ - private $require_ssl = null; + protected $require_ssl = null; /** * The list of external networks that are allowed to connect to the instance * using the IP. See @@ -120,7 +120,7 @@ public function clearEnableIpv4() * Generated from protobuf field .google.protobuf.BoolValue enable_ipv4 = 1; * @return bool|null */ - public function getEnableIpv4Value() + public function getEnableIpv4Unwrapped() { return $this->readWrapperValue("enable_ipv4"); } @@ -149,7 +149,7 @@ public function setEnableIpv4($var) * @param bool|null $var * @return $this */ - public function setEnableIpv4Value($var) + public function setEnableIpv4Unwrapped($var) { $this->writeWrapperValue("enable_ipv4", $var); return $this;} @@ -251,7 +251,7 @@ public function clearRequireSsl() * Generated from protobuf field .google.protobuf.BoolValue require_ssl = 3; * @return bool|null */ - public function getRequireSslValue() + public function getRequireSslUnwrapped() { return $this->readWrapperValue("require_ssl"); } @@ -280,7 +280,7 @@ public function setRequireSsl($var) * @param bool|null $var * @return $this */ - public function setRequireSslValue($var) + public function setRequireSslUnwrapped($var) { $this->writeWrapperValue("require_ssl", $var); return $this;} diff --git a/Dms/src/V1/SshScript.php b/Dms/src/V1/SshScript.php index 6e034741d5df..72cc6a31eb25 100644 --- a/Dms/src/V1/SshScript.php +++ b/Dms/src/V1/SshScript.php @@ -20,7 +20,7 @@ class SshScript extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string script = 1; */ - private $script = ''; + protected $script = ''; /** * Constructor. diff --git a/Dms/src/V1/SslConfig.php b/Dms/src/V1/SslConfig.php index e49fad83e177..a0e2a68a8120 100644 --- a/Dms/src/V1/SslConfig.php +++ b/Dms/src/V1/SslConfig.php @@ -21,7 +21,7 @@ class SslConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.SslConfig.SslType type = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $type = 0; + protected $type = 0; /** * Input only. The unencrypted PKCS#1 or PKCS#8 PEM-encoded private key * associated with the Client Certificate. If this field is used then the @@ -29,7 +29,7 @@ class SslConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string client_key = 2 [(.google.api.field_behavior) = INPUT_ONLY]; */ - private $client_key = ''; + protected $client_key = ''; /** * Input only. The x509 PEM-encoded certificate that will be used by the * replica to authenticate against the source database server.If this field is @@ -37,7 +37,7 @@ class SslConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string client_certificate = 3 [(.google.api.field_behavior) = INPUT_ONLY]; */ - private $client_certificate = ''; + protected $client_certificate = ''; /** * Required. Input only. The x509 PEM-encoded certificate of the CA that * signed the source database server's certificate. The replica will use this @@ -45,7 +45,7 @@ class SslConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string ca_certificate = 4 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = REQUIRED]; */ - private $ca_certificate = ''; + protected $ca_certificate = ''; /** * Constructor. diff --git a/Dms/src/V1/StartMigrationJobRequest.php b/Dms/src/V1/StartMigrationJobRequest.php index 71483446e48a..252c30242eb4 100644 --- a/Dms/src/V1/StartMigrationJobRequest.php +++ b/Dms/src/V1/StartMigrationJobRequest.php @@ -20,14 +20,14 @@ class StartMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. Start the migration job without running prior configuration * verification. Defaults to `false`. * * Generated from protobuf field bool skip_validation = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $skip_validation = false; + protected $skip_validation = false; /** * Constructor. diff --git a/Dms/src/V1/StopMigrationJobRequest.php b/Dms/src/V1/StopMigrationJobRequest.php index 8f3030fdfbd3..f2ed8e986d80 100644 --- a/Dms/src/V1/StopMigrationJobRequest.php +++ b/Dms/src/V1/StopMigrationJobRequest.php @@ -20,7 +20,7 @@ class StopMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/Dms/src/V1/StoredProcedureEntity.php b/Dms/src/V1/StoredProcedureEntity.php index f2b277c0a736..b5f386e5fbc3 100644 --- a/Dms/src/V1/StoredProcedureEntity.php +++ b/Dms/src/V1/StoredProcedureEntity.php @@ -20,13 +20,13 @@ class StoredProcedureEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string sql_code = 1; */ - private $sql_code = ''; + protected $sql_code = ''; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 2; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/SynonymEntity.php b/Dms/src/V1/SynonymEntity.php index 94ab43a9ec68..a419ccfecbc4 100644 --- a/Dms/src/V1/SynonymEntity.php +++ b/Dms/src/V1/SynonymEntity.php @@ -20,20 +20,20 @@ class SynonymEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_entity = 1; */ - private $source_entity = ''; + protected $source_entity = ''; /** * The type of the entity for which the synonym is being created * (usually a table or a sequence). * * Generated from protobuf field .google.cloud.clouddms.v1.DatabaseEntityType source_type = 2; */ - private $source_type = 0; + protected $source_type = 0; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 3; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/TableEntity.php b/Dms/src/V1/TableEntity.php index 2bbf9b42ef09..27333c21059a 100644 --- a/Dms/src/V1/TableEntity.php +++ b/Dms/src/V1/TableEntity.php @@ -44,13 +44,13 @@ class TableEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct custom_features = 5; */ - private $custom_features = null; + protected $custom_features = null; /** * Comment associated with the table. * * Generated from protobuf field string comment = 6; */ - private $comment = ''; + protected $comment = ''; /** * Constructor. diff --git a/Dms/src/V1/TcpProxyScript.php b/Dms/src/V1/TcpProxyScript.php index 91a884f73f99..abbbdf60fd0a 100644 --- a/Dms/src/V1/TcpProxyScript.php +++ b/Dms/src/V1/TcpProxyScript.php @@ -20,7 +20,7 @@ class TcpProxyScript extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string script = 1; */ - private $script = ''; + protected $script = ''; /** * Constructor. diff --git a/Dms/src/V1/TriggerEntity.php b/Dms/src/V1/TriggerEntity.php index 354711a611f2..675977b01d6e 100644 --- a/Dms/src/V1/TriggerEntity.php +++ b/Dms/src/V1/TriggerEntity.php @@ -21,7 +21,7 @@ class TriggerEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The DML, DDL, or database events that fire the trigger, for example * INSERT, UPDATE. @@ -35,19 +35,19 @@ class TriggerEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string trigger_type = 3; */ - private $trigger_type = ''; + protected $trigger_type = ''; /** * The SQL code which creates the trigger. * * Generated from protobuf field string sql_code = 4; */ - private $sql_code = ''; + protected $sql_code = ''; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 5; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/UDTEntity.php b/Dms/src/V1/UDTEntity.php index cbe5c0c0eb4e..12e7cacfb5e8 100644 --- a/Dms/src/V1/UDTEntity.php +++ b/Dms/src/V1/UDTEntity.php @@ -20,19 +20,19 @@ class UDTEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string udt_sql_code = 1; */ - private $udt_sql_code = ''; + protected $udt_sql_code = ''; /** * The SQL code which creates the udt body. * * Generated from protobuf field string udt_body = 2; */ - private $udt_body = ''; + protected $udt_body = ''; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 3; */ - private $custom_features = null; + protected $custom_features = null; /** * Constructor. diff --git a/Dms/src/V1/UpdateConnectionProfileRequest.php b/Dms/src/V1/UpdateConnectionProfileRequest.php index 9d2dcdf2c121..1106c8de3524 100644 --- a/Dms/src/V1/UpdateConnectionProfileRequest.php +++ b/Dms/src/V1/UpdateConnectionProfileRequest.php @@ -21,13 +21,13 @@ class UpdateConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. The connection profile parameters to update. * * Generated from protobuf field .google.cloud.clouddms.v1.ConnectionProfile connection_profile = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $connection_profile = null; + protected $connection_profile = null; /** * Optional. A unique ID used to identify the request. If the server receives * two requests with the same ID, then the second request is ignored. @@ -37,7 +37,7 @@ class UpdateConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. Only validate the connection profile, but don't update any * resources. The default is false. Only supported for Oracle connection @@ -45,7 +45,7 @@ class UpdateConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * Optional. Update the connection profile without validating it. * The default is false. @@ -53,7 +53,7 @@ class UpdateConnectionProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool skip_validation = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $skip_validation = false; + protected $skip_validation = false; /** * @param \Google\Cloud\CloudDms\V1\ConnectionProfile $connectionProfile Required. The connection profile parameters to update. diff --git a/Dms/src/V1/UpdateConversionWorkspaceRequest.php b/Dms/src/V1/UpdateConversionWorkspaceRequest.php index ee6c16cad806..54adf9dc9abd 100644 --- a/Dms/src/V1/UpdateConversionWorkspaceRequest.php +++ b/Dms/src/V1/UpdateConversionWorkspaceRequest.php @@ -21,13 +21,13 @@ class UpdateConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. The conversion workspace parameters to update. * * Generated from protobuf field .google.cloud.clouddms.v1.ConversionWorkspace conversion_workspace = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $conversion_workspace = null; + protected $conversion_workspace = null; /** * A unique ID used to identify the request. If the server receives two * requests with the same ID, then the second request is ignored. @@ -37,7 +37,7 @@ class UpdateConversionWorkspaceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3; */ - private $request_id = ''; + protected $request_id = ''; /** * @param \Google\Cloud\CloudDms\V1\ConversionWorkspace $conversionWorkspace Required. The conversion workspace parameters to update. diff --git a/Dms/src/V1/UpdateMigrationJobRequest.php b/Dms/src/V1/UpdateMigrationJobRequest.php index 1c05b631b918..ecdc85c837c0 100644 --- a/Dms/src/V1/UpdateMigrationJobRequest.php +++ b/Dms/src/V1/UpdateMigrationJobRequest.php @@ -21,13 +21,13 @@ class UpdateMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. The migration job parameters to update. * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob migration_job = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $migration_job = null; + protected $migration_job = null; /** * A unique ID used to identify the request. If the server receives two * requests with the same ID, then the second request is ignored. @@ -37,7 +37,7 @@ class UpdateMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3; */ - private $request_id = ''; + protected $request_id = ''; /** * @param \Google\Cloud\CloudDms\V1\MigrationJob $migrationJob Required. The migration job parameters to update. diff --git a/Dms/src/V1/ValueListFilter.php b/Dms/src/V1/ValueListFilter.php index 64781e469312..53b14d2575ad 100644 --- a/Dms/src/V1/ValueListFilter.php +++ b/Dms/src/V1/ValueListFilter.php @@ -21,7 +21,7 @@ class ValueListFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.clouddms.v1.ValuePresentInList value_present_list = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $value_present_list = 0; + protected $value_present_list = 0; /** * Required. The list to be used to filter by * @@ -34,7 +34,7 @@ class ValueListFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool ignore_case = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $ignore_case = false; + protected $ignore_case = false; /** * Constructor. diff --git a/Dms/src/V1/VerifyMigrationJobRequest.php b/Dms/src/V1/VerifyMigrationJobRequest.php index e6796099b2ec..20e265badfec 100644 --- a/Dms/src/V1/VerifyMigrationJobRequest.php +++ b/Dms/src/V1/VerifyMigrationJobRequest.php @@ -20,21 +20,21 @@ class VerifyMigrationJobRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. Field mask is used to specify the changed fields to be verified. * It will not update the migration job. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $update_mask = null; + protected $update_mask = null; /** * Optional. The changed migration job parameters to verify. * It will not update the migration job. * * Generated from protobuf field .google.cloud.clouddms.v1.MigrationJob migration_job = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $migration_job = null; + protected $migration_job = null; /** * Constructor. diff --git a/Dms/src/V1/ViewEntity.php b/Dms/src/V1/ViewEntity.php index 15d54899e01b..362151e3a315 100644 --- a/Dms/src/V1/ViewEntity.php +++ b/Dms/src/V1/ViewEntity.php @@ -20,13 +20,13 @@ class ViewEntity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string sql_code = 1; */ - private $sql_code = ''; + protected $sql_code = ''; /** * Custom engine specific features. * * Generated from protobuf field .google.protobuf.Struct custom_features = 2; */ - private $custom_features = null; + protected $custom_features = null; /** * View constraints. * diff --git a/Dms/src/V1/VmCreationConfig.php b/Dms/src/V1/VmCreationConfig.php index 162151239c6f..60420cb71902 100644 --- a/Dms/src/V1/VmCreationConfig.php +++ b/Dms/src/V1/VmCreationConfig.php @@ -20,19 +20,19 @@ class VmCreationConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vm_machine_type = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $vm_machine_type = ''; + protected $vm_machine_type = ''; /** * The Google Cloud Platform zone to create the VM in. * * Generated from protobuf field string vm_zone = 2; */ - private $vm_zone = ''; + protected $vm_zone = ''; /** * The subnet name the vm needs to be created in. * * Generated from protobuf field string subnet = 3; */ - private $subnet = ''; + protected $subnet = ''; /** * Constructor. diff --git a/Dms/src/V1/VmSelectionConfig.php b/Dms/src/V1/VmSelectionConfig.php index 35a290714de9..656f3ef6ec3e 100644 --- a/Dms/src/V1/VmSelectionConfig.php +++ b/Dms/src/V1/VmSelectionConfig.php @@ -20,7 +20,7 @@ class VmSelectionConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vm_zone = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $vm_zone = ''; + protected $vm_zone = ''; /** * Constructor. diff --git a/Dms/src/V1/VpcPeeringConfig.php b/Dms/src/V1/VpcPeeringConfig.php index 87d80161ca7f..a5596d1b8ef3 100644 --- a/Dms/src/V1/VpcPeeringConfig.php +++ b/Dms/src/V1/VpcPeeringConfig.php @@ -22,13 +22,13 @@ class VpcPeeringConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vpc_name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $vpc_name = ''; + protected $vpc_name = ''; /** * Required. A free subnet for peering. (CIDR of /29) * * Generated from protobuf field string subnet = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $subnet = ''; + protected $subnet = ''; /** * Constructor. diff --git a/Dms/src/V1/VpcPeeringConnectivity.php b/Dms/src/V1/VpcPeeringConnectivity.php index f3bf57580a04..8e48bbc4c1e2 100644 --- a/Dms/src/V1/VpcPeeringConnectivity.php +++ b/Dms/src/V1/VpcPeeringConnectivity.php @@ -22,7 +22,7 @@ class VpcPeeringConnectivity extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vpc = 1; */ - private $vpc = ''; + protected $vpc = ''; /** * Constructor. diff --git a/Dms/tests/Unit/V1/Client/DataMigrationServiceClientTest.php b/Dms/tests/Unit/V1/Client/DataMigrationServiceClientTest.php index 92942a9a1e8f..be59e4e42d2c 100644 --- a/Dms/tests/Unit/V1/Client/DataMigrationServiceClientTest.php +++ b/Dms/tests/Unit/V1/Client/DataMigrationServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return DataMigrationServiceClient */ @@ -166,8 +168,7 @@ public function applyConversionWorkspaceTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new ApplyConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new ApplyConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->applyConversionWorkspace($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -177,7 +178,10 @@ public function applyConversionWorkspaceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/ApplyConversionWorkspace', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/ApplyConversionWorkspace', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -223,17 +227,19 @@ public function applyConversionWorkspaceExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new ApplyConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new ApplyConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->applyConversionWorkspace($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -295,8 +301,7 @@ public function commitConversionWorkspaceTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new CommitConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new CommitConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->commitConversionWorkspace($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -306,7 +311,10 @@ public function commitConversionWorkspaceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/CommitConversionWorkspace', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/CommitConversionWorkspace', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -352,17 +360,19 @@ public function commitConversionWorkspaceExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new CommitConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new CommitConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->commitConversionWorkspace($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -432,7 +442,10 @@ public function convertConversionWorkspaceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/ConvertConversionWorkspace', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/ConvertConversionWorkspace', + $actualApiFuncCall + ); $expectedOperationsRequestObject = new GetOperationRequest(); $expectedOperationsRequestObject->setName('operations/convertConversionWorkspaceTest'); $response->pollUntilComplete([ @@ -476,12 +489,15 @@ public function convertConversionWorkspaceExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new ConvertConversionWorkspaceRequest(); $response = $gapicClient->convertConversionWorkspace($request); @@ -606,12 +622,15 @@ public function createConnectionProfileExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -709,7 +728,10 @@ public function createConversionWorkspaceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/CreateConversionWorkspace', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/CreateConversionWorkspace', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getConversionWorkspaceId(); @@ -759,12 +781,15 @@ public function createConversionWorkspaceExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -868,12 +893,15 @@ public function createMappingRuleExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); @@ -1018,12 +1046,15 @@ public function createMigrationJobExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -1161,12 +1192,15 @@ public function createPrivateConnectionExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -1229,8 +1263,7 @@ public function deleteConnectionProfileTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - $request = (new DeleteConnectionProfileRequest()) - ->setName($formattedName); + $request = (new DeleteConnectionProfileRequest())->setName($formattedName); $response = $gapicClient->deleteConnectionProfile($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1286,17 +1319,19 @@ public function deleteConnectionProfileExceptionTest() $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); + $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->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - $request = (new DeleteConnectionProfileRequest()) - ->setName($formattedName); + $request = (new DeleteConnectionProfileRequest())->setName($formattedName); $response = $gapicClient->deleteConnectionProfile($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1350,8 +1385,7 @@ public function deleteConversionWorkspaceTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new DeleteConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new DeleteConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->deleteConversionWorkspace($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1361,7 +1395,10 @@ public function deleteConversionWorkspaceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/DeleteConversionWorkspace', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/DeleteConversionWorkspace', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -1407,17 +1444,19 @@ public function deleteConversionWorkspaceExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new DeleteConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new DeleteConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->deleteConversionWorkspace($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1453,8 +1492,7 @@ public function deleteMappingRuleTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new DeleteMappingRuleRequest()) - ->setName($formattedName); + $request = (new DeleteMappingRuleRequest())->setName($formattedName); $gapicClient->deleteMappingRule($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -1477,17 +1515,19 @@ public function deleteMappingRuleExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new DeleteMappingRuleRequest()) - ->setName($formattedName); + $request = (new DeleteMappingRuleRequest())->setName($formattedName); try { $gapicClient->deleteMappingRule($request); // If the $gapicClient method call did not throw, fail the test @@ -1532,8 +1572,7 @@ public function deleteMigrationJobTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - $request = (new DeleteMigrationJobRequest()) - ->setName($formattedName); + $request = (new DeleteMigrationJobRequest())->setName($formattedName); $response = $gapicClient->deleteMigrationJob($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1589,17 +1628,19 @@ public function deleteMigrationJobExceptionTest() $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); + $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->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - $request = (new DeleteMigrationJobRequest()) - ->setName($formattedName); + $request = (new DeleteMigrationJobRequest())->setName($formattedName); $response = $gapicClient->deleteMigrationJob($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1653,8 +1694,7 @@ public function deletePrivateConnectionTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - $request = (new DeletePrivateConnectionRequest()) - ->setName($formattedName); + $request = (new DeletePrivateConnectionRequest())->setName($formattedName); $response = $gapicClient->deletePrivateConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1710,17 +1750,19 @@ public function deletePrivateConnectionExceptionTest() $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); + $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->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - $request = (new DeletePrivateConnectionRequest()) - ->setName($formattedName); + $request = (new DeletePrivateConnectionRequest())->setName($formattedName); $response = $gapicClient->deletePrivateConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1755,16 +1797,24 @@ public function describeConversionWorkspaceRevisionsTest() $expectedResponse = new DescribeConversionWorkspaceRevisionsResponse(); $transport->addResponse($expectedResponse); // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new DescribeConversionWorkspaceRevisionsRequest()) - ->setConversionWorkspace($formattedConversionWorkspace); + $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName( + '[PROJECT]', + '[LOCATION]', + '[CONVERSION_WORKSPACE]' + ); + $request = (new DescribeConversionWorkspaceRevisionsRequest())->setConversionWorkspace( + $formattedConversionWorkspace + ); $response = $gapicClient->describeConversionWorkspaceRevisions($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.clouddms.v1.DataMigrationService/DescribeConversionWorkspaceRevisions', $actualFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/DescribeConversionWorkspaceRevisions', + $actualFuncCall + ); $actualValue = $actualRequestObject->getConversionWorkspace(); $this->assertProtobufEquals($formattedConversionWorkspace, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1781,17 +1831,25 @@ public function describeConversionWorkspaceRevisionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new DescribeConversionWorkspaceRevisionsRequest()) - ->setConversionWorkspace($formattedConversionWorkspace); + $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName( + '[PROJECT]', + '[LOCATION]', + '[CONVERSION_WORKSPACE]' + ); + $request = (new DescribeConversionWorkspaceRevisionsRequest())->setConversionWorkspace( + $formattedConversionWorkspace + ); try { $gapicClient->describeConversionWorkspaceRevisions($request); // If the $gapicClient method call did not throw, fail the test @@ -1816,17 +1874,18 @@ public function describeDatabaseEntitiesTest() // Mock response $nextPageToken = ''; $databaseEntitiesElement = new DatabaseEntity(); - $databaseEntities = [ - $databaseEntitiesElement, - ]; + $databaseEntities = [$databaseEntitiesElement]; $expectedResponse = new DescribeDatabaseEntitiesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setDatabaseEntities($databaseEntities); $transport->addResponse($expectedResponse); // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new DescribeDatabaseEntitiesRequest()) - ->setConversionWorkspace($formattedConversionWorkspace); + $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName( + '[PROJECT]', + '[LOCATION]', + '[CONVERSION_WORKSPACE]' + ); + $request = (new DescribeDatabaseEntitiesRequest())->setConversionWorkspace($formattedConversionWorkspace); $response = $gapicClient->describeDatabaseEntities($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1853,17 +1912,23 @@ public function describeDatabaseEntitiesExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new DescribeDatabaseEntitiesRequest()) - ->setConversionWorkspace($formattedConversionWorkspace); + $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName( + '[PROJECT]', + '[LOCATION]', + '[CONVERSION_WORKSPACE]' + ); + $request = (new DescribeDatabaseEntitiesRequest())->setConversionWorkspace($formattedConversionWorkspace); try { $gapicClient->describeDatabaseEntities($request); // If the $gapicClient method call did not throw, fail the test @@ -1888,17 +1953,14 @@ public function fetchStaticIpsTest() // Mock response $nextPageToken = ''; $staticIpsElement = 'staticIpsElement2078370200'; - $staticIps = [ - $staticIpsElement, - ]; + $staticIps = [$staticIpsElement]; $expectedResponse = new FetchStaticIpsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setStaticIps($staticIps); $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new FetchStaticIpsRequest()) - ->setName($formattedName); + $request = (new FetchStaticIpsRequest())->setName($formattedName); $response = $gapicClient->fetchStaticIps($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1925,17 +1987,19 @@ public function fetchStaticIpsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new FetchStaticIpsRequest()) - ->setName($formattedName); + $request = (new FetchStaticIpsRequest())->setName($formattedName); try { $gapicClient->fetchStaticIps($request); // If the $gapicClient method call did not throw, fail the test @@ -1964,8 +2028,7 @@ public function generateSshScriptTest() $transport->addResponse($expectedResponse); // Mock request $vm = 'vm3767'; - $request = (new GenerateSshScriptRequest()) - ->setVm($vm); + $request = (new GenerateSshScriptRequest())->setVm($vm); $response = $gapicClient->generateSshScript($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1989,17 +2052,19 @@ public function generateSshScriptExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $vm = 'vm3767'; - $request = (new GenerateSshScriptRequest()) - ->setVm($vm); + $request = (new GenerateSshScriptRequest())->setVm($vm); try { $gapicClient->generateSshScript($request); // If the $gapicClient method call did not throw, fail the test @@ -2061,12 +2126,15 @@ public function generateTcpProxyScriptExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $vmName = 'vmName562937619'; @@ -2106,8 +2174,7 @@ public function getConnectionProfileTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - $request = (new GetConnectionProfileRequest()) - ->setName($formattedName); + $request = (new GetConnectionProfileRequest())->setName($formattedName); $response = $gapicClient->getConnectionProfile($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2131,17 +2198,19 @@ public function getConnectionProfileExceptionTest() $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); + $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->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - $request = (new GetConnectionProfileRequest()) - ->setName($formattedName); + $request = (new GetConnectionProfileRequest())->setName($formattedName); try { $gapicClient->getConnectionProfile($request); // If the $gapicClient method call did not throw, fail the test @@ -2176,8 +2245,7 @@ public function getConversionWorkspaceTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new GetConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new GetConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->getConversionWorkspace($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2201,17 +2269,19 @@ public function getConversionWorkspaceExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new GetConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new GetConversionWorkspaceRequest())->setName($formattedName); try { $gapicClient->getConversionWorkspace($request); // If the $gapicClient method call did not throw, fail the test @@ -2245,9 +2315,13 @@ public function getMappingRuleTest() $expectedResponse->setRevisionId($revisionId); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->mappingRuleName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]', '[MAPPING_RULE]'); - $request = (new GetMappingRuleRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->mappingRuleName( + '[PROJECT]', + '[LOCATION]', + '[CONVERSION_WORKSPACE]', + '[MAPPING_RULE]' + ); + $request = (new GetMappingRuleRequest())->setName($formattedName); $response = $gapicClient->getMappingRule($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2271,17 +2345,24 @@ public function getMappingRuleExceptionTest() $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); + $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->mappingRuleName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]', '[MAPPING_RULE]'); - $request = (new GetMappingRuleRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->mappingRuleName( + '[PROJECT]', + '[LOCATION]', + '[CONVERSION_WORKSPACE]', + '[MAPPING_RULE]' + ); + $request = (new GetMappingRuleRequest())->setName($formattedName); try { $gapicClient->getMappingRule($request); // If the $gapicClient method call did not throw, fail the test @@ -2322,8 +2403,7 @@ public function getMigrationJobTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - $request = (new GetMigrationJobRequest()) - ->setName($formattedName); + $request = (new GetMigrationJobRequest())->setName($formattedName); $response = $gapicClient->getMigrationJob($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2347,17 +2427,19 @@ public function getMigrationJobExceptionTest() $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); + $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->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - $request = (new GetMigrationJobRequest()) - ->setName($formattedName); + $request = (new GetMigrationJobRequest())->setName($formattedName); try { $gapicClient->getMigrationJob($request); // If the $gapicClient method call did not throw, fail the test @@ -2388,8 +2470,7 @@ public function getPrivateConnectionTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - $request = (new GetPrivateConnectionRequest()) - ->setName($formattedName); + $request = (new GetPrivateConnectionRequest())->setName($formattedName); $response = $gapicClient->getPrivateConnection($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2413,17 +2494,19 @@ public function getPrivateConnectionExceptionTest() $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); + $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->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - $request = (new GetPrivateConnectionRequest()) - ->setName($formattedName); + $request = (new GetPrivateConnectionRequest())->setName($formattedName); try { $gapicClient->getPrivateConnection($request); // If the $gapicClient method call did not throw, fail the test @@ -2476,8 +2559,7 @@ public function importMappingRulesTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new ImportMappingRulesRequest()) - ->setParent($formattedParent); + $request = (new ImportMappingRulesRequest())->setParent($formattedParent); $response = $gapicClient->importMappingRules($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -2533,17 +2615,19 @@ public function importMappingRulesExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new ImportMappingRulesRequest()) - ->setParent($formattedParent); + $request = (new ImportMappingRulesRequest())->setParent($formattedParent); $response = $gapicClient->importMappingRules($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -2577,17 +2661,14 @@ public function listConnectionProfilesTest() // Mock response $nextPageToken = ''; $connectionProfilesElement = new ConnectionProfile(); - $connectionProfiles = [ - $connectionProfilesElement, - ]; + $connectionProfiles = [$connectionProfilesElement]; $expectedResponse = new ListConnectionProfilesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setConnectionProfiles($connectionProfiles); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListConnectionProfilesRequest()) - ->setParent($formattedParent); + $request = (new ListConnectionProfilesRequest())->setParent($formattedParent); $response = $gapicClient->listConnectionProfiles($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2614,17 +2695,19 @@ public function listConnectionProfilesExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListConnectionProfilesRequest()) - ->setParent($formattedParent); + $request = (new ListConnectionProfilesRequest())->setParent($formattedParent); try { $gapicClient->listConnectionProfiles($request); // If the $gapicClient method call did not throw, fail the test @@ -2649,17 +2732,14 @@ public function listConversionWorkspacesTest() // Mock response $nextPageToken = ''; $conversionWorkspacesElement = new ConversionWorkspace(); - $conversionWorkspaces = [ - $conversionWorkspacesElement, - ]; + $conversionWorkspaces = [$conversionWorkspacesElement]; $expectedResponse = new ListConversionWorkspacesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setConversionWorkspaces($conversionWorkspaces); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListConversionWorkspacesRequest()) - ->setParent($formattedParent); + $request = (new ListConversionWorkspacesRequest())->setParent($formattedParent); $response = $gapicClient->listConversionWorkspaces($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2686,17 +2766,19 @@ public function listConversionWorkspacesExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListConversionWorkspacesRequest()) - ->setParent($formattedParent); + $request = (new ListConversionWorkspacesRequest())->setParent($formattedParent); try { $gapicClient->listConversionWorkspaces($request); // If the $gapicClient method call did not throw, fail the test @@ -2721,17 +2803,14 @@ public function listMappingRulesTest() // Mock response $nextPageToken = ''; $mappingRulesElement = new MappingRule(); - $mappingRules = [ - $mappingRulesElement, - ]; + $mappingRules = [$mappingRulesElement]; $expectedResponse = new ListMappingRulesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setMappingRules($mappingRules); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new ListMappingRulesRequest()) - ->setParent($formattedParent); + $request = (new ListMappingRulesRequest())->setParent($formattedParent); $response = $gapicClient->listMappingRules($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2758,17 +2837,19 @@ public function listMappingRulesExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new ListMappingRulesRequest()) - ->setParent($formattedParent); + $request = (new ListMappingRulesRequest())->setParent($formattedParent); try { $gapicClient->listMappingRules($request); // If the $gapicClient method call did not throw, fail the test @@ -2793,17 +2874,14 @@ public function listMigrationJobsTest() // Mock response $nextPageToken = ''; $migrationJobsElement = new MigrationJob(); - $migrationJobs = [ - $migrationJobsElement, - ]; + $migrationJobs = [$migrationJobsElement]; $expectedResponse = new ListMigrationJobsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setMigrationJobs($migrationJobs); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListMigrationJobsRequest()) - ->setParent($formattedParent); + $request = (new ListMigrationJobsRequest())->setParent($formattedParent); $response = $gapicClient->listMigrationJobs($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2830,17 +2908,19 @@ public function listMigrationJobsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListMigrationJobsRequest()) - ->setParent($formattedParent); + $request = (new ListMigrationJobsRequest())->setParent($formattedParent); try { $gapicClient->listMigrationJobs($request); // If the $gapicClient method call did not throw, fail the test @@ -2865,17 +2945,14 @@ public function listPrivateConnectionsTest() // Mock response $nextPageToken = ''; $privateConnectionsElement = new PrivateConnection(); - $privateConnections = [ - $privateConnectionsElement, - ]; + $privateConnections = [$privateConnectionsElement]; $expectedResponse = new ListPrivateConnectionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setPrivateConnections($privateConnections); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListPrivateConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListPrivateConnectionsRequest())->setParent($formattedParent); $response = $gapicClient->listPrivateConnections($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2902,17 +2979,19 @@ public function listPrivateConnectionsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListPrivateConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListPrivateConnectionsRequest())->setParent($formattedParent); try { $gapicClient->listPrivateConnections($request); // If the $gapicClient method call did not throw, fail the test @@ -3023,12 +3102,15 @@ public function promoteMigrationJobExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new PromoteMigrationJobRequest(); $response = $gapicClient->promoteMigrationJob($request); @@ -3150,12 +3232,15 @@ public function restartMigrationJobExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new RestartMigrationJobRequest(); $response = $gapicClient->restartMigrationJob($request); @@ -3277,12 +3362,15 @@ public function resumeMigrationJobExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new ResumeMigrationJobRequest(); $response = $gapicClient->resumeMigrationJob($request); @@ -3346,8 +3434,7 @@ public function rollbackConversionWorkspaceTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new RollbackConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new RollbackConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->rollbackConversionWorkspace($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3357,7 +3444,10 @@ public function rollbackConversionWorkspaceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/RollbackConversionWorkspace', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/RollbackConversionWorkspace', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -3403,17 +3493,19 @@ public function rollbackConversionWorkspaceExceptionTest() $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); + $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new RollbackConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new RollbackConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->rollbackConversionWorkspace($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3448,9 +3540,12 @@ public function searchBackgroundJobsTest() $expectedResponse = new SearchBackgroundJobsResponse(); $transport->addResponse($expectedResponse); // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new SearchBackgroundJobsRequest()) - ->setConversionWorkspace($formattedConversionWorkspace); + $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName( + '[PROJECT]', + '[LOCATION]', + '[CONVERSION_WORKSPACE]' + ); + $request = (new SearchBackgroundJobsRequest())->setConversionWorkspace($formattedConversionWorkspace); $response = $gapicClient->searchBackgroundJobs($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -3474,17 +3569,23 @@ public function searchBackgroundJobsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new SearchBackgroundJobsRequest()) - ->setConversionWorkspace($formattedConversionWorkspace); + $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName( + '[PROJECT]', + '[LOCATION]', + '[CONVERSION_WORKSPACE]' + ); + $request = (new SearchBackgroundJobsRequest())->setConversionWorkspace($formattedConversionWorkspace); try { $gapicClient->searchBackgroundJobs($request); // If the $gapicClient method call did not throw, fail the test @@ -3589,12 +3690,15 @@ public function seedConversionWorkspaceExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new SeedConversionWorkspaceRequest(); $response = $gapicClient->seedConversionWorkspace($request); @@ -3716,12 +3820,15 @@ public function startMigrationJobExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new StartMigrationJobRequest(); $response = $gapicClient->startMigrationJob($request); @@ -3843,12 +3950,15 @@ public function stopMigrationJobExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new StopMigrationJobRequest(); $response = $gapicClient->stopMigrationJob($request); @@ -3969,12 +4079,15 @@ public function updateConnectionProfileExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $updateMask = new FieldMask(); @@ -4068,7 +4181,10 @@ public function updateConversionWorkspaceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/UpdateConversionWorkspace', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/UpdateConversionWorkspace', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getUpdateMask(); $this->assertProtobufEquals($updateMask, $actualValue); $actualValue = $actualApiRequestObject->getConversionWorkspace(); @@ -4116,12 +4232,15 @@ public function updateConversionWorkspaceExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $updateMask = new FieldMask(); @@ -4215,9 +4334,7 @@ public function updateMigrationJobTest() $migrationJob->setSource($migrationJobSource); $migrationJobDestination = 'migrationJobDestination814598015'; $migrationJob->setDestination($migrationJobDestination); - $request = (new UpdateMigrationJobRequest()) - ->setUpdateMask($updateMask) - ->setMigrationJob($migrationJob); + $request = (new UpdateMigrationJobRequest())->setUpdateMask($updateMask)->setMigrationJob($migrationJob); $response = $gapicClient->updateMigrationJob($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -4275,12 +4392,15 @@ public function updateMigrationJobExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $updateMask = new FieldMask(); @@ -4291,9 +4411,7 @@ public function updateMigrationJobExceptionTest() $migrationJob->setSource($migrationJobSource); $migrationJobDestination = 'migrationJobDestination814598015'; $migrationJob->setDestination($migrationJobDestination); - $request = (new UpdateMigrationJobRequest()) - ->setUpdateMask($updateMask) - ->setMigrationJob($migrationJob); + $request = (new UpdateMigrationJobRequest())->setUpdateMask($updateMask)->setMigrationJob($migrationJob); $response = $gapicClient->updateMigrationJob($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -4413,12 +4531,15 @@ public function verifyMigrationJobExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new VerifyMigrationJobRequest(); $response = $gapicClient->verifyMigrationJob($request); @@ -4482,8 +4603,7 @@ public function applyConversionWorkspaceAsyncTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $request = (new ApplyConversionWorkspaceRequest()) - ->setName($formattedName); + $request = (new ApplyConversionWorkspaceRequest())->setName($formattedName); $response = $gapicClient->applyConversionWorkspaceAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -4493,7 +4613,10 @@ public function applyConversionWorkspaceAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/ApplyConversionWorkspace', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.clouddms.v1.DataMigrationService/ApplyConversionWorkspace', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); diff --git a/Dms/tests/Unit/V1/DataMigrationServiceClientTest.php b/Dms/tests/Unit/V1/DataMigrationServiceClientTest.php deleted file mode 100644 index 43bf3b93238c..000000000000 --- a/Dms/tests/Unit/V1/DataMigrationServiceClientTest.php +++ /dev/null @@ -1,4226 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return DataMigrationServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new DataMigrationServiceClient($options); - } - - /** @test */ - public function applyConversionWorkspaceTest() - { - $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/applyConversionWorkspaceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name2); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/applyConversionWorkspaceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->applyConversionWorkspace($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.clouddms.v1.DataMigrationService/ApplyConversionWorkspace', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/applyConversionWorkspaceTest'); - $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 applyConversionWorkspaceExceptionTest() - { - $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/applyConversionWorkspaceTest'); - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->applyConversionWorkspace($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/applyConversionWorkspaceTest'); - 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 commitConversionWorkspaceTest() - { - $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/commitConversionWorkspaceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name2); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/commitConversionWorkspaceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->commitConversionWorkspace($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.clouddms.v1.DataMigrationService/CommitConversionWorkspace', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/commitConversionWorkspaceTest'); - $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 commitConversionWorkspaceExceptionTest() - { - $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/commitConversionWorkspaceTest'); - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->commitConversionWorkspace($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/commitConversionWorkspaceTest'); - 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 convertConversionWorkspaceTest() - { - $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/convertConversionWorkspaceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name2); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/convertConversionWorkspaceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->convertConversionWorkspace(); - $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.clouddms.v1.DataMigrationService/ConvertConversionWorkspace', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/convertConversionWorkspaceTest'); - $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 convertConversionWorkspaceExceptionTest() - { - $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/convertConversionWorkspaceTest'); - $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); - $response = $gapicClient->convertConversionWorkspace(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/convertConversionWorkspaceTest'); - 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 createConnectionProfileTest() - { - $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/createConnectionProfileTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConnectionProfile(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createConnectionProfileTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $connectionProfileId = 'connectionProfileId1179884402'; - $connectionProfile = new ConnectionProfile(); - $response = $gapicClient->createConnectionProfile($formattedParent, $connectionProfileId, $connectionProfile); - $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.clouddms.v1.DataMigrationService/CreateConnectionProfile', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getConnectionProfileId(); - $this->assertProtobufEquals($connectionProfileId, $actualValue); - $actualValue = $actualApiRequestObject->getConnectionProfile(); - $this->assertProtobufEquals($connectionProfile, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createConnectionProfileTest'); - $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 createConnectionProfileExceptionTest() - { - $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/createConnectionProfileTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $connectionProfileId = 'connectionProfileId1179884402'; - $connectionProfile = new ConnectionProfile(); - $response = $gapicClient->createConnectionProfile($formattedParent, $connectionProfileId, $connectionProfile); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createConnectionProfileTest'); - 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 createConversionWorkspaceTest() - { - $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/createConversionWorkspaceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createConversionWorkspaceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $conversionWorkspaceId = 'conversionWorkspaceId-2047649394'; - $conversionWorkspace = new ConversionWorkspace(); - $conversionWorkspaceSource = new DatabaseEngineInfo(); - $sourceEngine = DatabaseEngine::DATABASE_ENGINE_UNSPECIFIED; - $conversionWorkspaceSource->setEngine($sourceEngine); - $sourceVersion = 'sourceVersion446171197'; - $conversionWorkspaceSource->setVersion($sourceVersion); - $conversionWorkspace->setSource($conversionWorkspaceSource); - $conversionWorkspaceDestination = new DatabaseEngineInfo(); - $destinationEngine = DatabaseEngine::DATABASE_ENGINE_UNSPECIFIED; - $conversionWorkspaceDestination->setEngine($destinationEngine); - $destinationVersion = 'destinationVersion-1058839318'; - $conversionWorkspaceDestination->setVersion($destinationVersion); - $conversionWorkspace->setDestination($conversionWorkspaceDestination); - $response = $gapicClient->createConversionWorkspace($formattedParent, $conversionWorkspaceId, $conversionWorkspace); - $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.clouddms.v1.DataMigrationService/CreateConversionWorkspace', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getConversionWorkspaceId(); - $this->assertProtobufEquals($conversionWorkspaceId, $actualValue); - $actualValue = $actualApiRequestObject->getConversionWorkspace(); - $this->assertProtobufEquals($conversionWorkspace, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createConversionWorkspaceTest'); - $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 createConversionWorkspaceExceptionTest() - { - $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/createConversionWorkspaceTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $conversionWorkspaceId = 'conversionWorkspaceId-2047649394'; - $conversionWorkspace = new ConversionWorkspace(); - $conversionWorkspaceSource = new DatabaseEngineInfo(); - $sourceEngine = DatabaseEngine::DATABASE_ENGINE_UNSPECIFIED; - $conversionWorkspaceSource->setEngine($sourceEngine); - $sourceVersion = 'sourceVersion446171197'; - $conversionWorkspaceSource->setVersion($sourceVersion); - $conversionWorkspace->setSource($conversionWorkspaceSource); - $conversionWorkspaceDestination = new DatabaseEngineInfo(); - $destinationEngine = DatabaseEngine::DATABASE_ENGINE_UNSPECIFIED; - $conversionWorkspaceDestination->setEngine($destinationEngine); - $destinationVersion = 'destinationVersion-1058839318'; - $conversionWorkspaceDestination->setVersion($destinationVersion); - $conversionWorkspace->setDestination($conversionWorkspaceDestination); - $response = $gapicClient->createConversionWorkspace($formattedParent, $conversionWorkspaceId, $conversionWorkspace); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createConversionWorkspaceTest'); - 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 createMappingRuleTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $ruleOrder = 432188341; - $revisionId = 'revisionId513861631'; - $expectedResponse = new MappingRule(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setRuleOrder($ruleOrder); - $expectedResponse->setRevisionId($revisionId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $mappingRuleId = 'mappingRuleId675527373'; - $mappingRule = new MappingRule(); - $mappingRuleRuleScope = DatabaseEntityType::DATABASE_ENTITY_TYPE_UNSPECIFIED; - $mappingRule->setRuleScope($mappingRuleRuleScope); - $mappingRuleFilter = new MappingRuleFilter(); - $mappingRule->setFilter($mappingRuleFilter); - $mappingRuleRuleOrder = 294717464; - $mappingRule->setRuleOrder($mappingRuleRuleOrder); - $response = $gapicClient->createMappingRule($formattedParent, $mappingRuleId, $mappingRule); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/CreateMappingRule', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getMappingRuleId(); - $this->assertProtobufEquals($mappingRuleId, $actualValue); - $actualValue = $actualRequestObject->getMappingRule(); - $this->assertProtobufEquals($mappingRule, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createMappingRuleExceptionTest() - { - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $mappingRuleId = 'mappingRuleId675527373'; - $mappingRule = new MappingRule(); - $mappingRuleRuleScope = DatabaseEntityType::DATABASE_ENTITY_TYPE_UNSPECIFIED; - $mappingRule->setRuleScope($mappingRuleRuleScope); - $mappingRuleFilter = new MappingRuleFilter(); - $mappingRule->setFilter($mappingRuleFilter); - $mappingRuleRuleOrder = 294717464; - $mappingRule->setRuleOrder($mappingRuleRuleOrder); - try { - $gapicClient->createMappingRule($formattedParent, $mappingRuleId, $mappingRule); - // 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 createMigrationJobTest() - { - $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/createMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $migrationJobId = 'migrationJobId-641178002'; - $migrationJob = new MigrationJob(); - $migrationJobType = Type::TYPE_UNSPECIFIED; - $migrationJob->setType($migrationJobType); - $migrationJobSource = 'migrationJobSource-1632714230'; - $migrationJob->setSource($migrationJobSource); - $migrationJobDestination = 'migrationJobDestination814598015'; - $migrationJob->setDestination($migrationJobDestination); - $response = $gapicClient->createMigrationJob($formattedParent, $migrationJobId, $migrationJob); - $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.clouddms.v1.DataMigrationService/CreateMigrationJob', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getMigrationJobId(); - $this->assertProtobufEquals($migrationJobId, $actualValue); - $actualValue = $actualApiRequestObject->getMigrationJob(); - $this->assertProtobufEquals($migrationJob, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createMigrationJobTest'); - $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 createMigrationJobExceptionTest() - { - $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/createMigrationJobTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $migrationJobId = 'migrationJobId-641178002'; - $migrationJob = new MigrationJob(); - $migrationJobType = Type::TYPE_UNSPECIFIED; - $migrationJob->setType($migrationJobType); - $migrationJobSource = 'migrationJobSource-1632714230'; - $migrationJob->setSource($migrationJobSource); - $migrationJobDestination = 'migrationJobDestination814598015'; - $migrationJob->setDestination($migrationJobDestination); - $response = $gapicClient->createMigrationJob($formattedParent, $migrationJobId, $migrationJob); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createMigrationJobTest'); - 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 createPrivateConnectionTest() - { - $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/createPrivateConnectionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $expectedResponse = new PrivateConnection(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createPrivateConnectionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $privateConnectionId = 'privateConnectionId-1948601248'; - $privateConnection = new PrivateConnection(); - $response = $gapicClient->createPrivateConnection($formattedParent, $privateConnectionId, $privateConnection); - $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.clouddms.v1.DataMigrationService/CreatePrivateConnection', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getPrivateConnectionId(); - $this->assertProtobufEquals($privateConnectionId, $actualValue); - $actualValue = $actualApiRequestObject->getPrivateConnection(); - $this->assertProtobufEquals($privateConnection, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createPrivateConnectionTest'); - $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 createPrivateConnectionExceptionTest() - { - $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/createPrivateConnectionTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $privateConnectionId = 'privateConnectionId-1948601248'; - $privateConnection = new PrivateConnection(); - $response = $gapicClient->createPrivateConnection($formattedParent, $privateConnectionId, $privateConnection); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createPrivateConnectionTest'); - 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 deleteConnectionProfileTest() - { - $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/deleteConnectionProfileTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteConnectionProfileTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - $response = $gapicClient->deleteConnectionProfile($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.clouddms.v1.DataMigrationService/DeleteConnectionProfile', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteConnectionProfileTest'); - $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 deleteConnectionProfileExceptionTest() - { - $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/deleteConnectionProfileTest'); - $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->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - $response = $gapicClient->deleteConnectionProfile($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteConnectionProfileTest'); - 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 deleteConversionWorkspaceTest() - { - $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/deleteConversionWorkspaceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteConversionWorkspaceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->deleteConversionWorkspace($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.clouddms.v1.DataMigrationService/DeleteConversionWorkspace', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteConversionWorkspaceTest'); - $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 deleteConversionWorkspaceExceptionTest() - { - $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/deleteConversionWorkspaceTest'); - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->deleteConversionWorkspace($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteConversionWorkspaceTest'); - 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 deleteMappingRuleTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $gapicClient->deleteMappingRule($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/DeleteMappingRule', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteMappingRuleExceptionTest() - { - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - try { - $gapicClient->deleteMappingRule($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 deleteMigrationJobTest() - { - $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/deleteMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - $response = $gapicClient->deleteMigrationJob($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.clouddms.v1.DataMigrationService/DeleteMigrationJob', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteMigrationJobTest'); - $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 deleteMigrationJobExceptionTest() - { - $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/deleteMigrationJobTest'); - $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->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - $response = $gapicClient->deleteMigrationJob($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteMigrationJobTest'); - 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 deletePrivateConnectionTest() - { - $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/deletePrivateConnectionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deletePrivateConnectionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - $response = $gapicClient->deletePrivateConnection($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.clouddms.v1.DataMigrationService/DeletePrivateConnection', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deletePrivateConnectionTest'); - $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 deletePrivateConnectionExceptionTest() - { - $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/deletePrivateConnectionTest'); - $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->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - $response = $gapicClient->deletePrivateConnection($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deletePrivateConnectionTest'); - 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 describeConversionWorkspaceRevisionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new DescribeConversionWorkspaceRevisionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->describeConversionWorkspaceRevisions($formattedConversionWorkspace); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/DescribeConversionWorkspaceRevisions', $actualFuncCall); - $actualValue = $actualRequestObject->getConversionWorkspace(); - $this->assertProtobufEquals($formattedConversionWorkspace, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function describeConversionWorkspaceRevisionsExceptionTest() - { - $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 - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - try { - $gapicClient->describeConversionWorkspaceRevisions($formattedConversionWorkspace); - // 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 describeDatabaseEntitiesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $databaseEntitiesElement = new DatabaseEntity(); - $databaseEntities = [ - $databaseEntitiesElement, - ]; - $expectedResponse = new DescribeDatabaseEntitiesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setDatabaseEntities($databaseEntities); - $transport->addResponse($expectedResponse); - // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->describeDatabaseEntities($formattedConversionWorkspace); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getDatabaseEntities()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/DescribeDatabaseEntities', $actualFuncCall); - $actualValue = $actualRequestObject->getConversionWorkspace(); - $this->assertProtobufEquals($formattedConversionWorkspace, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function describeDatabaseEntitiesExceptionTest() - { - $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 - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - try { - $gapicClient->describeDatabaseEntities($formattedConversionWorkspace); - // 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 fetchStaticIpsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $staticIpsElement = 'staticIpsElement2078370200'; - $staticIps = [ - $staticIpsElement, - ]; - $expectedResponse = new FetchStaticIpsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setStaticIps($staticIps); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->fetchStaticIps($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getStaticIps()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/FetchStaticIps', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function fetchStaticIpsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->fetchStaticIps($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 generateSshScriptTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $script = 'script-907685685'; - $expectedResponse = new SshScript(); - $expectedResponse->setScript($script); - $transport->addResponse($expectedResponse); - // Mock request - $vm = 'vm3767'; - $response = $gapicClient->generateSshScript($vm); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/GenerateSshScript', $actualFuncCall); - $actualValue = $actualRequestObject->getVm(); - $this->assertProtobufEquals($vm, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function generateSshScriptExceptionTest() - { - $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 - $vm = 'vm3767'; - try { - $gapicClient->generateSshScript($vm); - // 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 generateTcpProxyScriptTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $script = 'script-907685685'; - $expectedResponse = new TcpProxyScript(); - $expectedResponse->setScript($script); - $transport->addResponse($expectedResponse); - // Mock request - $vmName = 'vmName562937619'; - $vmMachineType = 'vmMachineType-2033986374'; - $vmSubnet = 'vmSubnet-21527067'; - $response = $gapicClient->generateTcpProxyScript($vmName, $vmMachineType, $vmSubnet); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/GenerateTcpProxyScript', $actualFuncCall); - $actualValue = $actualRequestObject->getVmName(); - $this->assertProtobufEquals($vmName, $actualValue); - $actualValue = $actualRequestObject->getVmMachineType(); - $this->assertProtobufEquals($vmMachineType, $actualValue); - $actualValue = $actualRequestObject->getVmSubnet(); - $this->assertProtobufEquals($vmSubnet, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function generateTcpProxyScriptExceptionTest() - { - $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 - $vmName = 'vmName562937619'; - $vmMachineType = 'vmMachineType-2033986374'; - $vmSubnet = 'vmSubnet-21527067'; - try { - $gapicClient->generateTcpProxyScript($vmName, $vmMachineType, $vmSubnet); - // 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 getConnectionProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConnectionProfile(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - $response = $gapicClient->getConnectionProfile($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.clouddms.v1.DataMigrationService/GetConnectionProfile', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getConnectionProfileExceptionTest() - { - $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->connectionProfileName('[PROJECT]', '[LOCATION]', '[CONNECTION_PROFILE]'); - try { - $gapicClient->getConnectionProfile($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 getConversionWorkspaceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name2); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->getConversionWorkspace($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.clouddms.v1.DataMigrationService/GetConversionWorkspace', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getConversionWorkspaceExceptionTest() - { - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - try { - $gapicClient->getConversionWorkspace($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 getMappingRuleTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $ruleOrder = 432188341; - $revisionId = 'revisionId513861631'; - $expectedResponse = new MappingRule(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setRuleOrder($ruleOrder); - $expectedResponse->setRevisionId($revisionId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->mappingRuleName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]', '[MAPPING_RULE]'); - $response = $gapicClient->getMappingRule($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.clouddms.v1.DataMigrationService/GetMappingRule', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getMappingRuleExceptionTest() - { - $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->mappingRuleName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]', '[MAPPING_RULE]'); - try { - $gapicClient->getMappingRule($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 getMigrationJobTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - $response = $gapicClient->getMigrationJob($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.clouddms.v1.DataMigrationService/GetMigrationJob', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getMigrationJobExceptionTest() - { - $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->migrationJobName('[PROJECT]', '[LOCATION]', '[MIGRATION_JOB]'); - try { - $gapicClient->getMigrationJob($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 getPrivateConnectionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $expectedResponse = new PrivateConnection(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - $response = $gapicClient->getPrivateConnection($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.clouddms.v1.DataMigrationService/GetPrivateConnection', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getPrivateConnectionExceptionTest() - { - $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->privateConnectionName('[PROJECT]', '[LOCATION]', '[PRIVATE_CONNECTION]'); - try { - $gapicClient->getPrivateConnection($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 importMappingRulesTest() - { - $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/importMappingRulesTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/importMappingRulesTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->importMappingRules($formattedParent); - $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.clouddms.v1.DataMigrationService/ImportMappingRules', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/importMappingRulesTest'); - $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 importMappingRulesExceptionTest() - { - $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/importMappingRulesTest'); - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->importMappingRules($formattedParent); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/importMappingRulesTest'); - 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 listConnectionProfilesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $connectionProfilesElement = new ConnectionProfile(); - $connectionProfiles = [ - $connectionProfilesElement, - ]; - $expectedResponse = new ListConnectionProfilesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setConnectionProfiles($connectionProfiles); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listConnectionProfiles($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getConnectionProfiles()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/ListConnectionProfiles', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listConnectionProfilesExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listConnectionProfiles($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 listConversionWorkspacesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $conversionWorkspacesElement = new ConversionWorkspace(); - $conversionWorkspaces = [ - $conversionWorkspacesElement, - ]; - $expectedResponse = new ListConversionWorkspacesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setConversionWorkspaces($conversionWorkspaces); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listConversionWorkspaces($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getConversionWorkspaces()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/ListConversionWorkspaces', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listConversionWorkspacesExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listConversionWorkspaces($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 listMappingRulesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $mappingRulesElement = new MappingRule(); - $mappingRules = [ - $mappingRulesElement, - ]; - $expectedResponse = new ListMappingRulesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setMappingRules($mappingRules); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->listMappingRules($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getMappingRules()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/ListMappingRules', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listMappingRulesExceptionTest() - { - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - try { - $gapicClient->listMappingRules($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 listMigrationJobsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $migrationJobsElement = new MigrationJob(); - $migrationJobs = [ - $migrationJobsElement, - ]; - $expectedResponse = new ListMigrationJobsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setMigrationJobs($migrationJobs); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listMigrationJobs($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getMigrationJobs()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/ListMigrationJobs', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listMigrationJobsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listMigrationJobs($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 listPrivateConnectionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $privateConnectionsElement = new PrivateConnection(); - $privateConnections = [ - $privateConnectionsElement, - ]; - $expectedResponse = new ListPrivateConnectionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setPrivateConnections($privateConnections); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listPrivateConnections($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getPrivateConnections()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/ListPrivateConnections', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listPrivateConnectionsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listPrivateConnections($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 promoteMigrationJobTest() - { - $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/promoteMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/promoteMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->promoteMigrationJob(); - $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.clouddms.v1.DataMigrationService/PromoteMigrationJob', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/promoteMigrationJobTest'); - $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 promoteMigrationJobExceptionTest() - { - $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/promoteMigrationJobTest'); - $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); - $response = $gapicClient->promoteMigrationJob(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/promoteMigrationJobTest'); - 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 restartMigrationJobTest() - { - $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/restartMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/restartMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->restartMigrationJob(); - $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.clouddms.v1.DataMigrationService/RestartMigrationJob', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/restartMigrationJobTest'); - $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 restartMigrationJobExceptionTest() - { - $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/restartMigrationJobTest'); - $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); - $response = $gapicClient->restartMigrationJob(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/restartMigrationJobTest'); - 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 resumeMigrationJobTest() - { - $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/resumeMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/resumeMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->resumeMigrationJob(); - $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.clouddms.v1.DataMigrationService/ResumeMigrationJob', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/resumeMigrationJobTest'); - $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 resumeMigrationJobExceptionTest() - { - $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/resumeMigrationJobTest'); - $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); - $response = $gapicClient->resumeMigrationJob(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/resumeMigrationJobTest'); - 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 rollbackConversionWorkspaceTest() - { - $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/rollbackConversionWorkspaceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name2); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/rollbackConversionWorkspaceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->rollbackConversionWorkspace($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.clouddms.v1.DataMigrationService/RollbackConversionWorkspace', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/rollbackConversionWorkspaceTest'); - $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 rollbackConversionWorkspaceExceptionTest() - { - $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/rollbackConversionWorkspaceTest'); - $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->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->rollbackConversionWorkspace($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/rollbackConversionWorkspaceTest'); - 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 searchBackgroundJobsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new SearchBackgroundJobsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - $response = $gapicClient->searchBackgroundJobs($formattedConversionWorkspace); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.clouddms.v1.DataMigrationService/SearchBackgroundJobs', $actualFuncCall); - $actualValue = $actualRequestObject->getConversionWorkspace(); - $this->assertProtobufEquals($formattedConversionWorkspace, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function searchBackgroundJobsExceptionTest() - { - $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 - $formattedConversionWorkspace = $gapicClient->conversionWorkspaceName('[PROJECT]', '[LOCATION]', '[CONVERSION_WORKSPACE]'); - try { - $gapicClient->searchBackgroundJobs($formattedConversionWorkspace); - // 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 seedConversionWorkspaceTest() - { - $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/seedConversionWorkspaceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name2); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/seedConversionWorkspaceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->seedConversionWorkspace(); - $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.clouddms.v1.DataMigrationService/SeedConversionWorkspace', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/seedConversionWorkspaceTest'); - $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 seedConversionWorkspaceExceptionTest() - { - $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/seedConversionWorkspaceTest'); - $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); - $response = $gapicClient->seedConversionWorkspace(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/seedConversionWorkspaceTest'); - 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 startMigrationJobTest() - { - $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/startMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/startMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->startMigrationJob(); - $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.clouddms.v1.DataMigrationService/StartMigrationJob', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/startMigrationJobTest'); - $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 startMigrationJobExceptionTest() - { - $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/startMigrationJobTest'); - $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); - $response = $gapicClient->startMigrationJob(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/startMigrationJobTest'); - 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 stopMigrationJobTest() - { - $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/stopMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/stopMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->stopMigrationJob(); - $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.clouddms.v1.DataMigrationService/StopMigrationJob', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/stopMigrationJobTest'); - $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 stopMigrationJobExceptionTest() - { - $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/stopMigrationJobTest'); - $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); - $response = $gapicClient->stopMigrationJob(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/stopMigrationJobTest'); - 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 updateConnectionProfileTest() - { - $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/updateConnectionProfileTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConnectionProfile(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateConnectionProfileTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $connectionProfile = new ConnectionProfile(); - $response = $gapicClient->updateConnectionProfile($updateMask, $connectionProfile); - $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.clouddms.v1.DataMigrationService/UpdateConnectionProfile', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getConnectionProfile(); - $this->assertProtobufEquals($connectionProfile, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateConnectionProfileTest'); - $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 updateConnectionProfileExceptionTest() - { - $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/updateConnectionProfileTest'); - $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 - $updateMask = new FieldMask(); - $connectionProfile = new ConnectionProfile(); - $response = $gapicClient->updateConnectionProfile($updateMask, $connectionProfile); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateConnectionProfileTest'); - 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 updateConversionWorkspaceTest() - { - $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/updateConversionWorkspaceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $hasUncommittedChanges = true; - $latestCommitId = 'latestCommitId-492063125'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ConversionWorkspace(); - $expectedResponse->setName($name); - $expectedResponse->setHasUncommittedChanges($hasUncommittedChanges); - $expectedResponse->setLatestCommitId($latestCommitId); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateConversionWorkspaceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $conversionWorkspace = new ConversionWorkspace(); - $conversionWorkspaceSource = new DatabaseEngineInfo(); - $sourceEngine = DatabaseEngine::DATABASE_ENGINE_UNSPECIFIED; - $conversionWorkspaceSource->setEngine($sourceEngine); - $sourceVersion = 'sourceVersion446171197'; - $conversionWorkspaceSource->setVersion($sourceVersion); - $conversionWorkspace->setSource($conversionWorkspaceSource); - $conversionWorkspaceDestination = new DatabaseEngineInfo(); - $destinationEngine = DatabaseEngine::DATABASE_ENGINE_UNSPECIFIED; - $conversionWorkspaceDestination->setEngine($destinationEngine); - $destinationVersion = 'destinationVersion-1058839318'; - $conversionWorkspaceDestination->setVersion($destinationVersion); - $conversionWorkspace->setDestination($conversionWorkspaceDestination); - $response = $gapicClient->updateConversionWorkspace($updateMask, $conversionWorkspace); - $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.clouddms.v1.DataMigrationService/UpdateConversionWorkspace', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getConversionWorkspace(); - $this->assertProtobufEquals($conversionWorkspace, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateConversionWorkspaceTest'); - $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 updateConversionWorkspaceExceptionTest() - { - $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/updateConversionWorkspaceTest'); - $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 - $updateMask = new FieldMask(); - $conversionWorkspace = new ConversionWorkspace(); - $conversionWorkspaceSource = new DatabaseEngineInfo(); - $sourceEngine = DatabaseEngine::DATABASE_ENGINE_UNSPECIFIED; - $conversionWorkspaceSource->setEngine($sourceEngine); - $sourceVersion = 'sourceVersion446171197'; - $conversionWorkspaceSource->setVersion($sourceVersion); - $conversionWorkspace->setSource($conversionWorkspaceSource); - $conversionWorkspaceDestination = new DatabaseEngineInfo(); - $destinationEngine = DatabaseEngine::DATABASE_ENGINE_UNSPECIFIED; - $conversionWorkspaceDestination->setEngine($destinationEngine); - $destinationVersion = 'destinationVersion-1058839318'; - $conversionWorkspaceDestination->setVersion($destinationVersion); - $conversionWorkspace->setDestination($conversionWorkspaceDestination); - $response = $gapicClient->updateConversionWorkspace($updateMask, $conversionWorkspace); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateConversionWorkspaceTest'); - 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 updateMigrationJobTest() - { - $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/updateMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $migrationJob = new MigrationJob(); - $migrationJobType = Type::TYPE_UNSPECIFIED; - $migrationJob->setType($migrationJobType); - $migrationJobSource = 'migrationJobSource-1632714230'; - $migrationJob->setSource($migrationJobSource); - $migrationJobDestination = 'migrationJobDestination814598015'; - $migrationJob->setDestination($migrationJobDestination); - $response = $gapicClient->updateMigrationJob($updateMask, $migrationJob); - $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.clouddms.v1.DataMigrationService/UpdateMigrationJob', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getMigrationJob(); - $this->assertProtobufEquals($migrationJob, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateMigrationJobTest'); - $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 updateMigrationJobExceptionTest() - { - $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/updateMigrationJobTest'); - $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 - $updateMask = new FieldMask(); - $migrationJob = new MigrationJob(); - $migrationJobType = Type::TYPE_UNSPECIFIED; - $migrationJob->setType($migrationJobType); - $migrationJobSource = 'migrationJobSource-1632714230'; - $migrationJob->setSource($migrationJobSource); - $migrationJobDestination = 'migrationJobDestination814598015'; - $migrationJob->setDestination($migrationJobDestination); - $response = $gapicClient->updateMigrationJob($updateMask, $migrationJob); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateMigrationJobTest'); - 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 verifyMigrationJobTest() - { - $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/verifyMigrationJobTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $dumpPath = 'dumpPath-1355154544'; - $source = 'source-896505829'; - $destination = 'destination-1429847026'; - $filter = 'filter-1274492040'; - $cmekKeyName = 'cmekKeyName2138875194'; - $expectedResponse = new MigrationJob(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDumpPath($dumpPath); - $expectedResponse->setSource($source); - $expectedResponse->setDestination($destination); - $expectedResponse->setFilter($filter); - $expectedResponse->setCmekKeyName($cmekKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/verifyMigrationJobTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->verifyMigrationJob(); - $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.clouddms.v1.DataMigrationService/VerifyMigrationJob', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/verifyMigrationJobTest'); - $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 verifyMigrationJobExceptionTest() - { - $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/verifyMigrationJobTest'); - $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); - $response = $gapicClient->verifyMigrationJob(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/verifyMigrationJobTest'); - 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()); - } -} diff --git a/Eventarc/owlbot.py b/Eventarc/owlbot.py index 4aa3e8f7253b..24a596b18b8b 100644 --- a/Eventarc/owlbot.py +++ b/Eventarc/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,32 +41,6 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - # format generated clients subprocess.run([ 'npm', @@ -82,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/Eventarc/src/V1/Channel.php b/Eventarc/src/V1/Channel.php index f0fbdada5e06..79707cee439b 100644 --- a/Eventarc/src/V1/Channel.php +++ b/Eventarc/src/V1/Channel.php @@ -25,7 +25,7 @@ class Channel extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. Server assigned unique identifier for the channel. The value * is a UUID4 string and guaranteed to remain unchanged until the resource is @@ -33,19 +33,19 @@ class Channel extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Output only. The creation time. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The last-modified time. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * The name of the event provider (e.g. Eventarc SaaS partner) associated * with the channel. This provider will be granted permissions to publish @@ -54,20 +54,20 @@ class Channel extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string provider = 7; */ - private $provider = ''; + protected $provider = ''; /** * Output only. The state of a Channel. * * Generated from protobuf field .google.cloud.eventarc.v1.Channel.State state = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The activation token for the channel. The token must be used * by the provider to register the channel for publishing. * * Generated from protobuf field string activation_token = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $activation_token = ''; + protected $activation_token = ''; /** * Optional. Resource name of a KMS crypto key (managed by the user) used to * encrypt/decrypt their event data. @@ -76,7 +76,7 @@ class Channel extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string crypto_key_name = 11 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $crypto_key_name = ''; + protected $crypto_key_name = ''; protected $transport; /** diff --git a/Eventarc/src/V1/ChannelConnection.php b/Eventarc/src/V1/ChannelConnection.php index 489b7a1e6e37..1478f29772d9 100644 --- a/Eventarc/src/V1/ChannelConnection.php +++ b/Eventarc/src/V1/ChannelConnection.php @@ -23,14 +23,14 @@ class ChannelConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. Server assigned ID of the resource. * The server guarantees uniqueness and immutability until deleted. * * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Required. The name of the connected subscriber Channel. * This is a weak reference to avoid cross project and cross accounts @@ -39,19 +39,19 @@ class ChannelConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string channel = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $channel = ''; + protected $channel = ''; /** * Output only. The creation time. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The last-modified time. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Input only. Activation token for the channel. The token will be used * during the creation of ChannelConnection to bind the channel with the @@ -59,7 +59,7 @@ class ChannelConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string activation_token = 8 [(.google.api.field_behavior) = INPUT_ONLY]; */ - private $activation_token = ''; + protected $activation_token = ''; /** * Constructor. diff --git a/Eventarc/src/V1/Client/EventarcClient.php b/Eventarc/src/V1/Client/EventarcClient.php index c60418a5571c..75f4c4a1bc56 100644 --- a/Eventarc/src/V1/Client/EventarcClient.php +++ b/Eventarc/src/V1/Client/EventarcClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a channel * resource. @@ -522,8 +541,10 @@ public function createChannel(CreateChannelRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function createChannelConnection(CreateChannelConnectionRequest $request, array $callOptions = []): OperationResponse - { + public function createChannelConnection( + CreateChannelConnectionRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CreateChannelConnection', $request, $callOptions)->wait(); } @@ -600,8 +621,10 @@ public function deleteChannel(DeleteChannelRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function deleteChannelConnection(DeleteChannelConnectionRequest $request, array $callOptions = []): OperationResponse - { + public function deleteChannelConnection( + DeleteChannelConnectionRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('DeleteChannelConnection', $request, $callOptions)->wait(); } @@ -678,8 +701,10 @@ public function getChannel(GetChannelRequest $request, array $callOptions = []): * * @throws ApiException Thrown if the API call fails. */ - public function getChannelConnection(GetChannelConnectionRequest $request, array $callOptions = []): ChannelConnection - { + public function getChannelConnection( + GetChannelConnectionRequest $request, + array $callOptions = [] + ): ChannelConnection { return $this->startApiCall('GetChannelConnection', $request, $callOptions)->wait(); } @@ -704,8 +729,10 @@ public function getChannelConnection(GetChannelConnectionRequest $request, array * * @throws ApiException Thrown if the API call fails. */ - public function getGoogleChannelConfig(GetGoogleChannelConfigRequest $request, array $callOptions = []): GoogleChannelConfig - { + public function getGoogleChannelConfig( + GetGoogleChannelConfigRequest $request, + array $callOptions = [] + ): GoogleChannelConfig { return $this->startApiCall('GetGoogleChannelConfig', $request, $callOptions)->wait(); } @@ -782,8 +809,10 @@ public function getTrigger(GetTriggerRequest $request, array $callOptions = []): * * @throws ApiException Thrown if the API call fails. */ - public function listChannelConnections(ListChannelConnectionsRequest $request, array $callOptions = []): PagedListResponse - { + public function listChannelConnections( + ListChannelConnectionsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListChannelConnections', $request, $callOptions); } @@ -912,8 +941,10 @@ public function updateChannel(UpdateChannelRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function updateGoogleChannelConfig(UpdateGoogleChannelConfigRequest $request, array $callOptions = []): GoogleChannelConfig - { + public function updateGoogleChannelConfig( + UpdateGoogleChannelConfigRequest $request, + array $callOptions = [] + ): GoogleChannelConfig { return $this->startApiCall('UpdateGoogleChannelConfig', $request, $callOptions)->wait(); } @@ -1079,8 +1110,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Eventarc/src/V1/CloudRun.php b/Eventarc/src/V1/CloudRun.php index 9f9bda09a10d..9594f339c5fc 100644 --- a/Eventarc/src/V1/CloudRun.php +++ b/Eventarc/src/V1/CloudRun.php @@ -23,7 +23,7 @@ class CloudRun extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string service = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $service = ''; + protected $service = ''; /** * Optional. The relative path on the Cloud Run service the events should be sent to. * The value must conform to the definition of a URI path segment (section 3.3 @@ -31,13 +31,13 @@ class CloudRun extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string path = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $path = ''; + protected $path = ''; /** * Required. The region the Cloud Run service is deployed in. * * Generated from protobuf field string region = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $region = ''; + protected $region = ''; /** * Constructor. diff --git a/Eventarc/src/V1/CreateChannelConnectionRequest.php b/Eventarc/src/V1/CreateChannelConnectionRequest.php index 35fdec46cbd3..db746856ae6a 100644 --- a/Eventarc/src/V1/CreateChannelConnectionRequest.php +++ b/Eventarc/src/V1/CreateChannelConnectionRequest.php @@ -20,19 +20,19 @@ class CreateChannelConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. Channel connection to create. * * Generated from protobuf field .google.cloud.eventarc.v1.ChannelConnection channel_connection = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $channel_connection = null; + protected $channel_connection = null; /** * Required. The user-provided ID to be assigned to the channel connection. * * Generated from protobuf field string channel_connection_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $channel_connection_id = ''; + protected $channel_connection_id = ''; /** * @param string $parent Required. The parent collection in which to add this channel connection. Please see diff --git a/Eventarc/src/V1/CreateChannelRequest.php b/Eventarc/src/V1/CreateChannelRequest.php index dd9da01ea96d..6e7d042f16ca 100644 --- a/Eventarc/src/V1/CreateChannelRequest.php +++ b/Eventarc/src/V1/CreateChannelRequest.php @@ -20,26 +20,26 @@ class CreateChannelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The channel to create. * * Generated from protobuf field .google.cloud.eventarc.v1.Channel channel = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $channel = null; + protected $channel = null; /** * Required. The user-provided ID to be assigned to the channel. * * Generated from protobuf field string channel_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $channel_id = ''; + protected $channel_id = ''; /** * Required. If set, validate the request and preview the review, but do not * post it. * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $parent Required. The parent collection in which to add this channel. Please see diff --git a/Eventarc/src/V1/CreateTriggerRequest.php b/Eventarc/src/V1/CreateTriggerRequest.php index 1dacc15d73ad..96788a4152fa 100644 --- a/Eventarc/src/V1/CreateTriggerRequest.php +++ b/Eventarc/src/V1/CreateTriggerRequest.php @@ -20,26 +20,26 @@ class CreateTriggerRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The trigger to create. * * Generated from protobuf field .google.cloud.eventarc.v1.Trigger trigger = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $trigger = null; + protected $trigger = null; /** * Required. The user-provided ID to be assigned to the trigger. * * Generated from protobuf field string trigger_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $trigger_id = ''; + protected $trigger_id = ''; /** * Required. If set, validate the request and preview the review, but do not * post it. * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $parent Required. The parent collection in which to add this trigger. Please see diff --git a/Eventarc/src/V1/DeleteChannelConnectionRequest.php b/Eventarc/src/V1/DeleteChannelConnectionRequest.php index 145d4d718d23..a4809ebcf693 100644 --- a/Eventarc/src/V1/DeleteChannelConnectionRequest.php +++ b/Eventarc/src/V1/DeleteChannelConnectionRequest.php @@ -20,7 +20,7 @@ class DeleteChannelConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the channel connection to delete. Please see diff --git a/Eventarc/src/V1/DeleteChannelRequest.php b/Eventarc/src/V1/DeleteChannelRequest.php index 35c455e73796..30b84491f7e6 100644 --- a/Eventarc/src/V1/DeleteChannelRequest.php +++ b/Eventarc/src/V1/DeleteChannelRequest.php @@ -20,14 +20,14 @@ class DeleteChannelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. If set, validate the request and preview the review, but do not * post it. * * Generated from protobuf field bool validate_only = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $name Required. The name of the channel to be deleted. Please see diff --git a/Eventarc/src/V1/DeleteTriggerRequest.php b/Eventarc/src/V1/DeleteTriggerRequest.php index 398b8e9416c1..830d69a020f1 100644 --- a/Eventarc/src/V1/DeleteTriggerRequest.php +++ b/Eventarc/src/V1/DeleteTriggerRequest.php @@ -20,28 +20,28 @@ class DeleteTriggerRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * If provided, the trigger will only be deleted if the etag matches the * current etag on the resource. * * Generated from protobuf field string etag = 2; */ - private $etag = ''; + protected $etag = ''; /** * If set to true, and the trigger is not found, the request will succeed * but no action will be taken on the server. * * Generated from protobuf field bool allow_missing = 3; */ - private $allow_missing = false; + protected $allow_missing = false; /** * Required. If set, validate the request and preview the review, but do not * post it. * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $name Required. The name of the trigger to be deleted. Please see diff --git a/Eventarc/src/V1/EventFilter.php b/Eventarc/src/V1/EventFilter.php index 19f937aa6be6..f4f75630fc18 100644 --- a/Eventarc/src/V1/EventFilter.php +++ b/Eventarc/src/V1/EventFilter.php @@ -22,13 +22,13 @@ class EventFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string attribute = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $attribute = ''; + protected $attribute = ''; /** * Required. The value for the attribute. * * Generated from protobuf field string value = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $value = ''; + protected $value = ''; /** * Optional. The operator used for matching the events with the value of the * filter. If not specified, only events that have an exact key-value pair @@ -37,7 +37,7 @@ class EventFilter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string operator = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $operator = ''; + protected $operator = ''; /** * Constructor. diff --git a/Eventarc/src/V1/EventType.php b/Eventarc/src/V1/EventType.php index 59c106786c72..67e92e6f24f7 100644 --- a/Eventarc/src/V1/EventType.php +++ b/Eventarc/src/V1/EventType.php @@ -25,14 +25,14 @@ class EventType extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string type = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $type = ''; + protected $type = ''; /** * Output only. Human friendly description of what the event type is about. * For example "Bucket created in Cloud Storage". * * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $description = ''; + protected $description = ''; /** * Output only. Filtering attributes for the event type. * @@ -46,7 +46,7 @@ class EventType extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string event_schema_uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $event_schema_uri = ''; + protected $event_schema_uri = ''; /** * Constructor. diff --git a/Eventarc/src/V1/EventarcClient.php b/Eventarc/src/V1/EventarcClient.php deleted file mode 100644 index 8302cfb3fc34..000000000000 --- a/Eventarc/src/V1/EventarcClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string attribute = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $attribute = ''; + protected $attribute = ''; /** * Output only. Description of the purpose of the attribute. * * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $description = ''; + protected $description = ''; /** * Output only. If true, the triggers for this provider should always specify a filter * on these attributes. Trigger creation will fail otherwise. * * Generated from protobuf field bool required = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $required = false; + protected $required = false; /** * Output only. If true, the attribute accepts matching expressions in the Eventarc * PathPattern format. * * Generated from protobuf field bool path_pattern_supported = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $path_pattern_supported = false; + protected $path_pattern_supported = false; /** * Constructor. diff --git a/Eventarc/src/V1/GKE.php b/Eventarc/src/V1/GKE.php index 8de280a26506..205d41d90ddc 100644 --- a/Eventarc/src/V1/GKE.php +++ b/Eventarc/src/V1/GKE.php @@ -21,7 +21,7 @@ class GKE extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cluster = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $cluster = ''; + protected $cluster = ''; /** * Required. The name of the Google Compute Engine in which the cluster resides, which * can either be compute zone (for example, us-central1-a) for the zonal @@ -29,19 +29,19 @@ class GKE extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string location = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $location = ''; + protected $location = ''; /** * Required. The namespace the GKE service is running in. * * Generated from protobuf field string namespace = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $namespace = ''; + protected $namespace = ''; /** * Required. Name of the GKE service. * * Generated from protobuf field string service = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $service = ''; + protected $service = ''; /** * Optional. The relative path on the GKE service the events should be sent to. * The value must conform to the definition of a URI path segment (section 3.3 @@ -49,7 +49,7 @@ class GKE extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string path = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $path = ''; + protected $path = ''; /** * Constructor. diff --git a/Eventarc/src/V1/Gapic/EventarcGapicClient.php b/Eventarc/src/V1/Gapic/EventarcGapicClient.php deleted file mode 100644 index e80ecf72148c..000000000000 --- a/Eventarc/src/V1/Gapic/EventarcGapicClient.php +++ /dev/null @@ -1,2352 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $channel = new Channel(); - * $channelId = 'channel_id'; - * $validateOnly = false; - * $operationResponse = $eventarcClient->createChannel($formattedParent, $channel, $channelId, $validateOnly); - * $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 = $eventarcClient->createChannel($formattedParent, $channel, $channelId, $validateOnly); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'createChannel'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Eventarc\V1\Client\EventarcClient}. - */ -class EventarcGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.eventarc.v1.Eventarc'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'eventarc.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'eventarc.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $channelNameTemplate; - - private static $channelConnectionNameTemplate; - - private static $cloudFunctionNameTemplate; - - private static $cryptoKeyNameTemplate; - - private static $googleChannelConfigNameTemplate; - - private static $locationNameTemplate; - - private static $providerNameTemplate; - - private static $serviceAccountNameTemplate; - - private static $triggerNameTemplate; - - private static $workflowNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getChannelNameTemplate() - { - if (self::$channelNameTemplate == null) { - self::$channelNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/channels/{channel}' - ); - } - - return self::$channelNameTemplate; - } - - private static function getChannelConnectionNameTemplate() - { - if (self::$channelConnectionNameTemplate == null) { - self::$channelConnectionNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/channelConnections/{channel_connection}' - ); - } - - return self::$channelConnectionNameTemplate; - } - - private static function getCloudFunctionNameTemplate() - { - if (self::$cloudFunctionNameTemplate == null) { - self::$cloudFunctionNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/functions/{function}' - ); - } - - return self::$cloudFunctionNameTemplate; - } - - private static function getCryptoKeyNameTemplate() - { - if (self::$cryptoKeyNameTemplate == null) { - self::$cryptoKeyNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' - ); - } - - return self::$cryptoKeyNameTemplate; - } - - private static function getGoogleChannelConfigNameTemplate() - { - if (self::$googleChannelConfigNameTemplate == null) { - self::$googleChannelConfigNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/googleChannelConfig' - ); - } - - return self::$googleChannelConfigNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getProviderNameTemplate() - { - if (self::$providerNameTemplate == null) { - self::$providerNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/providers/{provider}' - ); - } - - return self::$providerNameTemplate; - } - - private static function getServiceAccountNameTemplate() - { - if (self::$serviceAccountNameTemplate == null) { - self::$serviceAccountNameTemplate = new PathTemplate( - 'projects/{project}/serviceAccounts/{service_account}' - ); - } - - return self::$serviceAccountNameTemplate; - } - - private static function getTriggerNameTemplate() - { - if (self::$triggerNameTemplate == null) { - self::$triggerNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/triggers/{trigger}' - ); - } - - return self::$triggerNameTemplate; - } - - private static function getWorkflowNameTemplate() - { - if (self::$workflowNameTemplate == null) { - self::$workflowNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}' - ); - } - - return self::$workflowNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'channel' => self::getChannelNameTemplate(), - 'channelConnection' => self::getChannelConnectionNameTemplate(), - 'cloudFunction' => self::getCloudFunctionNameTemplate(), - 'cryptoKey' => self::getCryptoKeyNameTemplate(), - 'googleChannelConfig' => self::getGoogleChannelConfigNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'provider' => self::getProviderNameTemplate(), - 'serviceAccount' => self::getServiceAccountNameTemplate(), - 'trigger' => self::getTriggerNameTemplate(), - 'workflow' => self::getWorkflowNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location, $channel) - { - return self::getChannelNameTemplate()->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( - $project, - $location, - $channelConnection - ) { - return self::getChannelConnectionNameTemplate()->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($project, $location, $function) - { - return self::getCloudFunctionNameTemplate()->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( - $project, - $location, - $keyRing, - $cryptoKey - ) { - return self::getCryptoKeyNameTemplate()->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($project, $location) - { - return self::getGoogleChannelConfigNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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($project, $location, $provider) - { - return self::getProviderNameTemplate()->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($project, $serviceAccount) - { - return self::getServiceAccountNameTemplate()->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($project, $location, $trigger) - { - return self::getTriggerNameTemplate()->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($project, $location, $workflow) - { - return self::getWorkflowNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Create a new channel in a particular project and location. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedParent = $eventarcClient->locationName('[PROJECT]', '[LOCATION]'); - * $channel = new Channel(); - * $channelId = 'channel_id'; - * $validateOnly = false; - * $operationResponse = $eventarcClient->createChannel($formattedParent, $channel, $channelId, $validateOnly); - * $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 = $eventarcClient->createChannel($formattedParent, $channel, $channelId, $validateOnly); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'createChannel'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent collection in which to add this channel. - * @param Channel $channel Required. The channel to create. - * @param string $channelId Required. The user-provided ID to be assigned to the channel. - * @param bool $validateOnly Required. If set, validate the request and preview the review, but do not - * post it. - * @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 createChannel( - $parent, - $channel, - $channelId, - $validateOnly, - array $optionalArgs = [] - ) { - $request = new CreateChannelRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setChannel($channel); - $request->setChannelId($channelId); - $request->setValidateOnly($validateOnly); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateChannel', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Create a new ChannelConnection in a particular project and location. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedParent = $eventarcClient->locationName('[PROJECT]', '[LOCATION]'); - * $channelConnection = new ChannelConnection(); - * $channelConnectionId = 'channel_connection_id'; - * $operationResponse = $eventarcClient->createChannelConnection($formattedParent, $channelConnection, $channelConnectionId); - * $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 = $eventarcClient->createChannelConnection($formattedParent, $channelConnection, $channelConnectionId); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'createChannelConnection'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent collection in which to add this channel connection. - * @param ChannelConnection $channelConnection Required. Channel connection to create. - * @param string $channelConnectionId Required. The user-provided ID to be assigned to the channel connection. - * @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 createChannelConnection( - $parent, - $channelConnection, - $channelConnectionId, - array $optionalArgs = [] - ) { - $request = new CreateChannelConnectionRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setChannelConnection($channelConnection); - $request->setChannelConnectionId($channelConnectionId); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateChannelConnection', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Create a new trigger in a particular project and location. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedParent = $eventarcClient->locationName('[PROJECT]', '[LOCATION]'); - * $trigger = new Trigger(); - * $triggerId = 'trigger_id'; - * $validateOnly = false; - * $operationResponse = $eventarcClient->createTrigger($formattedParent, $trigger, $triggerId, $validateOnly); - * $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 = $eventarcClient->createTrigger($formattedParent, $trigger, $triggerId, $validateOnly); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'createTrigger'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent collection in which to add this trigger. - * @param Trigger $trigger Required. The trigger to create. - * @param string $triggerId Required. The user-provided ID to be assigned to the trigger. - * @param bool $validateOnly Required. If set, validate the request and preview the review, but do not - * post it. - * @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 createTrigger( - $parent, - $trigger, - $triggerId, - $validateOnly, - array $optionalArgs = [] - ) { - $request = new CreateTriggerRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTrigger($trigger); - $request->setTriggerId($triggerId); - $request->setValidateOnly($validateOnly); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateTrigger', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Delete a single channel. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedName = $eventarcClient->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - * $validateOnly = false; - * $operationResponse = $eventarcClient->deleteChannel($formattedName, $validateOnly); - * $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 = $eventarcClient->deleteChannel($formattedName, $validateOnly); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'deleteChannel'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the channel to be deleted. - * @param bool $validateOnly Required. If set, validate the request and preview the review, but do not - * post it. - * @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 deleteChannel( - $name, - $validateOnly, - array $optionalArgs = [] - ) { - $request = new DeleteChannelRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setValidateOnly($validateOnly); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteChannel', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Delete a single ChannelConnection. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedName = $eventarcClient->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - * $operationResponse = $eventarcClient->deleteChannelConnection($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 = $eventarcClient->deleteChannelConnection($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'deleteChannelConnection'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the channel connection to delete. - * @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 deleteChannelConnection($name, array $optionalArgs = []) - { - $request = new DeleteChannelConnectionRequest(); - $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( - 'DeleteChannelConnection', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Delete a single trigger. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedName = $eventarcClient->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); - * $validateOnly = false; - * $operationResponse = $eventarcClient->deleteTrigger($formattedName, $validateOnly); - * $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 = $eventarcClient->deleteTrigger($formattedName, $validateOnly); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'deleteTrigger'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the trigger to be deleted. - * @param bool $validateOnly Required. If set, validate the request and preview the review, but do not - * post it. - * @param array $optionalArgs { - * Optional. - * - * @type string $etag - * If provided, the trigger will only be deleted if the etag matches the - * current etag on the resource. - * @type bool $allowMissing - * If set to true, and the trigger is not found, the request will succeed - * but no action will be taken on the server. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deleteTrigger( - $name, - $validateOnly, - array $optionalArgs = [] - ) { - $request = new DeleteTriggerRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setValidateOnly($validateOnly); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['etag'])) { - $request->setEtag($optionalArgs['etag']); - } - - if (isset($optionalArgs['allowMissing'])) { - $request->setAllowMissing($optionalArgs['allowMissing']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteTrigger', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Get a single Channel. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedName = $eventarcClient->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - * $response = $eventarcClient->getChannel($formattedName); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the channel to get. - * @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\Eventarc\V1\Channel - * - * @throws ApiException if the remote call fails - */ - public function getChannel($name, array $optionalArgs = []) - { - $request = new GetChannelRequest(); - $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( - 'GetChannel', - Channel::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get a single ChannelConnection. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedName = $eventarcClient->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - * $response = $eventarcClient->getChannelConnection($formattedName); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the channel connection to get. - * @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\Eventarc\V1\ChannelConnection - * - * @throws ApiException if the remote call fails - */ - public function getChannelConnection($name, array $optionalArgs = []) - { - $request = new GetChannelConnectionRequest(); - $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( - 'GetChannelConnection', - ChannelConnection::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get a GoogleChannelConfig - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedName = $eventarcClient->googleChannelConfigName('[PROJECT]', '[LOCATION]'); - * $response = $eventarcClient->getGoogleChannelConfig($formattedName); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the config to get. - * @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\Eventarc\V1\GoogleChannelConfig - * - * @throws ApiException if the remote call fails - */ - public function getGoogleChannelConfig($name, array $optionalArgs = []) - { - $request = new GetGoogleChannelConfigRequest(); - $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( - 'GetGoogleChannelConfig', - GoogleChannelConfig::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get a single Provider. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedName = $eventarcClient->providerName('[PROJECT]', '[LOCATION]', '[PROVIDER]'); - * $response = $eventarcClient->getProvider($formattedName); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the provider to get. - * @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\Eventarc\V1\Provider - * - * @throws ApiException if the remote call fails - */ - public function getProvider($name, array $optionalArgs = []) - { - $request = new GetProviderRequest(); - $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( - 'GetProvider', - Provider::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get a single trigger. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedName = $eventarcClient->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); - * $response = $eventarcClient->getTrigger($formattedName); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the trigger to get. - * @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\Eventarc\V1\Trigger - * - * @throws ApiException if the remote call fails - */ - public function getTrigger($name, array $optionalArgs = []) - { - $request = new GetTriggerRequest(); - $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( - 'GetTrigger', - Trigger::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * List channel connections. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedParent = $eventarcClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $eventarcClient->listChannelConnections($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $eventarcClient->listChannelConnections($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent collection from which to list channel connections. - * @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 listChannelConnections($parent, array $optionalArgs = []) - { - $request = new ListChannelConnectionsRequest(); - $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( - 'ListChannelConnections', - $optionalArgs, - ListChannelConnectionsResponse::class, - $request - ); - } - - /** - * List channels. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedParent = $eventarcClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $eventarcClient->listChannels($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $eventarcClient->listChannels($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent collection to list channels on. - * @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 string $orderBy - * The sorting order of the resources returned. Value should be a - * comma-separated list of fields. The default sorting order is ascending. To - * specify descending order for a field, append a `desc` suffix; for example: - * `name desc, channel_id`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listChannels($parent, array $optionalArgs = []) - { - $request = new ListChannelsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - 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( - 'ListChannels', - $optionalArgs, - ListChannelsResponse::class, - $request - ); - } - - /** - * List providers. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedParent = $eventarcClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $eventarcClient->listProviders($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $eventarcClient->listProviders($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent of the provider to get. - * @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 string $orderBy - * The sorting order of the resources returned. Value should be a - * comma-separated list of fields. The default sorting oder is ascending. To - * specify descending order for a field, append a `desc` suffix; for example: - * `name desc, _id`. - * @type string $filter - * The filter field that the list request will filter on. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listProviders($parent, array $optionalArgs = []) - { - $request = new ListProvidersRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListProviders', - $optionalArgs, - ListProvidersResponse::class, - $request - ); - } - - /** - * List triggers. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $formattedParent = $eventarcClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $eventarcClient->listTriggers($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $eventarcClient->listTriggers($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent collection to list triggers on. - * @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 string $orderBy - * The sorting order of the resources returned. Value should be a - * comma-separated list of fields. The default sorting order is ascending. To - * specify descending order for a field, append a `desc` suffix; for example: - * `name desc, trigger_id`. - * @type string $filter - * Filter field. Used to filter the Triggers to be listed. Possible filters - * are described in https://google.aip.dev/160. For example, using - * "?filter=destination:gke" would list only Triggers with a gke destination. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listTriggers($parent, array $optionalArgs = []) - { - $request = new ListTriggersRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListTriggers', - $optionalArgs, - ListTriggersResponse::class, - $request - ); - } - - /** - * Update a single channel. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $validateOnly = false; - * $operationResponse = $eventarcClient->updateChannel($validateOnly); - * $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 = $eventarcClient->updateChannel($validateOnly); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'updateChannel'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param bool $validateOnly Required. If set, validate the request and preview the review, but do not - * post it. - * @param array $optionalArgs { - * Optional. - * - * @type Channel $channel - * The channel to be updated. - * @type FieldMask $updateMask - * The fields to be updated; only fields explicitly provided are updated. - * If no field mask is provided, all provided fields in the request are - * updated. To update all fields, provide a field mask of "*". - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 updateChannel($validateOnly, array $optionalArgs = []) - { - $request = new UpdateChannelRequest(); - $requestParamHeaders = []; - $request->setValidateOnly($validateOnly); - if (isset($optionalArgs['channel'])) { - $request->setChannel($optionalArgs['channel']); - } - - 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->startOperationsCall( - 'UpdateChannel', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Update a single GoogleChannelConfig - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $googleChannelConfig = new GoogleChannelConfig(); - * $response = $eventarcClient->updateGoogleChannelConfig($googleChannelConfig); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param GoogleChannelConfig $googleChannelConfig Required. The config to be updated. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The fields to be updated; only fields explicitly provided are updated. - * If no field mask is provided, all provided fields in the request are - * updated. To update all fields, provide a field mask of "*". - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Eventarc\V1\GoogleChannelConfig - * - * @throws ApiException if the remote call fails - */ - public function updateGoogleChannelConfig( - $googleChannelConfig, - array $optionalArgs = [] - ) { - $request = new UpdateGoogleChannelConfigRequest(); - $requestParamHeaders = []; - $request->setGoogleChannelConfig($googleChannelConfig); - $requestParamHeaders[ - 'google_channel_config.name' - ] = $googleChannelConfig->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( - 'UpdateGoogleChannelConfig', - GoogleChannelConfig::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Update a single trigger. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $validateOnly = false; - * $operationResponse = $eventarcClient->updateTrigger($validateOnly); - * $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 = $eventarcClient->updateTrigger($validateOnly); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $eventarcClient->resumeOperation($operationName, 'updateTrigger'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param bool $validateOnly Required. If set, validate the request and preview the review, but do not - * post it. - * @param array $optionalArgs { - * Optional. - * - * @type Trigger $trigger - * The trigger to be updated. - * @type FieldMask $updateMask - * The fields to be updated; only fields explicitly provided are updated. - * If no field mask is provided, all provided fields in the request are - * updated. To update all fields, provide a field mask of "*". - * @type bool $allowMissing - * If set to true, and the trigger is not found, a new trigger will be - * created. In this situation, `update_mask` is ignored. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 updateTrigger($validateOnly, array $optionalArgs = []) - { - $request = new UpdateTriggerRequest(); - $requestParamHeaders = []; - $request->setValidateOnly($validateOnly); - if (isset($optionalArgs['trigger'])) { - $request->setTrigger($optionalArgs['trigger']); - } - - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - if (isset($optionalArgs['allowMissing'])) { - $request->setAllowMissing($optionalArgs['allowMissing']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateTrigger', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $response = $eventarcClient->getLocation(); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $eventarcClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $eventarcClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * 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 RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $resource = 'resource'; - * $response = $eventarcClient->getIamPolicy($resource); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $eventarcClient->setIamPolicy($resource, $policy); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->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. - * - * Sample code: - * ``` - * $eventarcClient = new EventarcClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $eventarcClient->testIamPermissions($resource, $permissions); - * } finally { - * $eventarcClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/Eventarc/src/V1/GetChannelConnectionRequest.php b/Eventarc/src/V1/GetChannelConnectionRequest.php index aa783119456a..dc8ea1280ac5 100644 --- a/Eventarc/src/V1/GetChannelConnectionRequest.php +++ b/Eventarc/src/V1/GetChannelConnectionRequest.php @@ -20,7 +20,7 @@ class GetChannelConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the channel connection to get. Please see diff --git a/Eventarc/src/V1/GetChannelRequest.php b/Eventarc/src/V1/GetChannelRequest.php index 127fd9be3f19..c80223e28726 100644 --- a/Eventarc/src/V1/GetChannelRequest.php +++ b/Eventarc/src/V1/GetChannelRequest.php @@ -20,7 +20,7 @@ class GetChannelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the channel to get. Please see diff --git a/Eventarc/src/V1/GetGoogleChannelConfigRequest.php b/Eventarc/src/V1/GetGoogleChannelConfigRequest.php index ba67f9cdb9d4..38ddbd0ee06e 100644 --- a/Eventarc/src/V1/GetGoogleChannelConfigRequest.php +++ b/Eventarc/src/V1/GetGoogleChannelConfigRequest.php @@ -20,7 +20,7 @@ class GetGoogleChannelConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the config to get. Please see diff --git a/Eventarc/src/V1/GetProviderRequest.php b/Eventarc/src/V1/GetProviderRequest.php index 1a333b74ad52..57173d9b151d 100644 --- a/Eventarc/src/V1/GetProviderRequest.php +++ b/Eventarc/src/V1/GetProviderRequest.php @@ -20,7 +20,7 @@ class GetProviderRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the provider to get. Please see diff --git a/Eventarc/src/V1/GetTriggerRequest.php b/Eventarc/src/V1/GetTriggerRequest.php index 50471827c8b5..6345f521d820 100644 --- a/Eventarc/src/V1/GetTriggerRequest.php +++ b/Eventarc/src/V1/GetTriggerRequest.php @@ -20,7 +20,7 @@ class GetTriggerRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the trigger to get. Please see diff --git a/Eventarc/src/V1/GoogleChannelConfig.php b/Eventarc/src/V1/GoogleChannelConfig.php index 97cb3873151e..e0d2872ce2b3 100644 --- a/Eventarc/src/V1/GoogleChannelConfig.php +++ b/Eventarc/src/V1/GoogleChannelConfig.php @@ -25,13 +25,13 @@ class GoogleChannelConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. The last-modified time. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional. Resource name of a KMS crypto key (managed by the user) used to * encrypt/decrypt their event data. @@ -40,7 +40,7 @@ class GoogleChannelConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string crypto_key_name = 7 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $crypto_key_name = ''; + protected $crypto_key_name = ''; /** * Constructor. diff --git a/Eventarc/src/V1/ListChannelConnectionsRequest.php b/Eventarc/src/V1/ListChannelConnectionsRequest.php index 8dc9a24bf117..806e2e2ddffe 100644 --- a/Eventarc/src/V1/ListChannelConnectionsRequest.php +++ b/Eventarc/src/V1/ListChannelConnectionsRequest.php @@ -20,14 +20,14 @@ class ListChannelConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of channel connections to return on each page. * Note: The service may send fewer responses. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token; provide the value from the `next_page_token` field in a * previous `ListChannelConnections` call to retrieve the subsequent page. @@ -36,7 +36,7 @@ class ListChannelConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The parent collection from which to list channel connections. Please see diff --git a/Eventarc/src/V1/ListChannelConnectionsResponse.php b/Eventarc/src/V1/ListChannelConnectionsResponse.php index 4e1cb36ecba0..9659eb7acb7a 100644 --- a/Eventarc/src/V1/ListChannelConnectionsResponse.php +++ b/Eventarc/src/V1/ListChannelConnectionsResponse.php @@ -29,7 +29,7 @@ class ListChannelConnectionsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Unreachable resources, if any. * diff --git a/Eventarc/src/V1/ListChannelsRequest.php b/Eventarc/src/V1/ListChannelsRequest.php index c54d8ea72d10..bed6e9976240 100644 --- a/Eventarc/src/V1/ListChannelsRequest.php +++ b/Eventarc/src/V1/ListChannelsRequest.php @@ -20,14 +20,14 @@ class ListChannelsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of channels to return on each page. * Note: The service may send fewer. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token; provide the value from the `next_page_token` field in a * previous `ListChannels` call to retrieve the subsequent page. @@ -36,7 +36,7 @@ class ListChannelsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * The sorting order of the resources returned. Value should be a * comma-separated list of fields. The default sorting order is ascending. To @@ -45,7 +45,7 @@ class ListChannelsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 4; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent collection to list channels on. Please see diff --git a/Eventarc/src/V1/ListChannelsResponse.php b/Eventarc/src/V1/ListChannelsResponse.php index f2f9105eaad1..7706916cd782 100644 --- a/Eventarc/src/V1/ListChannelsResponse.php +++ b/Eventarc/src/V1/ListChannelsResponse.php @@ -27,7 +27,7 @@ class ListChannelsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Unreachable resources, if any. * diff --git a/Eventarc/src/V1/ListProvidersRequest.php b/Eventarc/src/V1/ListProvidersRequest.php index 4636d558d9c6..e95fa3d2cde7 100644 --- a/Eventarc/src/V1/ListProvidersRequest.php +++ b/Eventarc/src/V1/ListProvidersRequest.php @@ -20,13 +20,13 @@ class ListProvidersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of providers to return on each page. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token; provide the value from the `next_page_token` field in a * previous `ListProviders` call to retrieve the subsequent page. @@ -35,7 +35,7 @@ class ListProvidersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * The sorting order of the resources returned. Value should be a * comma-separated list of fields. The default sorting oder is ascending. To @@ -44,13 +44,13 @@ class ListProvidersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 4; */ - private $order_by = ''; + protected $order_by = ''; /** * The filter field that the list request will filter on. * * Generated from protobuf field string filter = 5; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The parent of the provider to get. Please see diff --git a/Eventarc/src/V1/ListProvidersResponse.php b/Eventarc/src/V1/ListProvidersResponse.php index 5b7fc6a2f0a5..d1bf4a8f1e6b 100644 --- a/Eventarc/src/V1/ListProvidersResponse.php +++ b/Eventarc/src/V1/ListProvidersResponse.php @@ -27,7 +27,7 @@ class ListProvidersResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Unreachable resources, if any. * diff --git a/Eventarc/src/V1/ListTriggersRequest.php b/Eventarc/src/V1/ListTriggersRequest.php index 6dbd121f0abc..822bf71ff9c0 100644 --- a/Eventarc/src/V1/ListTriggersRequest.php +++ b/Eventarc/src/V1/ListTriggersRequest.php @@ -20,14 +20,14 @@ class ListTriggersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of triggers to return on each page. * Note: The service may send fewer. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token; provide the value from the `next_page_token` field in a * previous `ListTriggers` call to retrieve the subsequent page. @@ -36,7 +36,7 @@ class ListTriggersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * The sorting order of the resources returned. Value should be a * comma-separated list of fields. The default sorting order is ascending. To @@ -45,7 +45,7 @@ class ListTriggersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 4; */ - private $order_by = ''; + protected $order_by = ''; /** * Filter field. Used to filter the Triggers to be listed. Possible filters * are described in https://google.aip.dev/160. For example, using @@ -53,7 +53,7 @@ class ListTriggersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 5; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The parent collection to list triggers on. Please see diff --git a/Eventarc/src/V1/ListTriggersResponse.php b/Eventarc/src/V1/ListTriggersResponse.php index 30934cfab4c7..ee71a58af28b 100644 --- a/Eventarc/src/V1/ListTriggersResponse.php +++ b/Eventarc/src/V1/ListTriggersResponse.php @@ -27,7 +27,7 @@ class ListTriggersResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Unreachable resources, if any. * diff --git a/Eventarc/src/V1/OperationMetadata.php b/Eventarc/src/V1/OperationMetadata.php index a2efd6844085..5e68aca2f8c3 100644 --- a/Eventarc/src/V1/OperationMetadata.php +++ b/Eventarc/src/V1/OperationMetadata.php @@ -20,31 +20,31 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. Server-defined resource path for the target of the operation. * * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $target = ''; + protected $target = ''; /** * Output only. Name of the verb executed by the operation. * * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $verb = ''; + protected $verb = ''; /** * Output only. Human-readable status of the operation, if any. * * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $status_message = ''; + protected $status_message = ''; /** * Output only. Identifies whether the user has requested cancellation * of the operation. Operations that have successfully been cancelled @@ -53,13 +53,13 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $requested_cancellation = false; + protected $requested_cancellation = false; /** * Output only. API version used to start the operation. * * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $api_version = ''; + protected $api_version = ''; /** * Constructor. diff --git a/Eventarc/src/V1/Provider.php b/Eventarc/src/V1/Provider.php index 2a40e64e5279..2cab34dc5b9d 100644 --- a/Eventarc/src/V1/Provider.php +++ b/Eventarc/src/V1/Provider.php @@ -21,13 +21,13 @@ class Provider extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Output only. Human friendly name for the Provider. For example "Cloud Storage". * * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. Event types for this provider. * diff --git a/Eventarc/src/V1/Pubsub.php b/Eventarc/src/V1/Pubsub.php index b3313e3e6e2f..438692870f62 100644 --- a/Eventarc/src/V1/Pubsub.php +++ b/Eventarc/src/V1/Pubsub.php @@ -25,7 +25,7 @@ class Pubsub extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string topic = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $topic = ''; + protected $topic = ''; /** * Output only. The name of the Pub/Sub subscription created and managed by Eventarc * as a transport for the event delivery. Format: @@ -33,7 +33,7 @@ class Pubsub extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string subscription = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $subscription = ''; + protected $subscription = ''; /** * Constructor. diff --git a/Eventarc/src/V1/StateCondition.php b/Eventarc/src/V1/StateCondition.php index be340350a243..3c68f4ea51cd 100644 --- a/Eventarc/src/V1/StateCondition.php +++ b/Eventarc/src/V1/StateCondition.php @@ -20,13 +20,13 @@ class StateCondition extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.rpc.Code code = 1; */ - private $code = 0; + protected $code = 0; /** * Human-readable message. * * Generated from protobuf field string message = 2; */ - private $message = ''; + protected $message = ''; /** * Constructor. diff --git a/Eventarc/src/V1/Trigger.php b/Eventarc/src/V1/Trigger.php index 37c1d1e8441e..144b812b9f05 100644 --- a/Eventarc/src/V1/Trigger.php +++ b/Eventarc/src/V1/Trigger.php @@ -22,26 +22,26 @@ class Trigger extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. Server-assigned unique identifier for the trigger. The value is a UUID4 * string and guaranteed to remain unchanged until the resource is deleted. * * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Output only. The creation time. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The last-modified time. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Required. Unordered list. The list of filters that applies to event attributes. Only events that * match all the provided filters are sent to the destination. @@ -65,13 +65,13 @@ class Trigger extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string service_account = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $service_account = ''; + protected $service_account = ''; /** * Required. Destination specifies where the events should be sent to. * * Generated from protobuf field .google.cloud.eventarc.v1.Destination destination = 10 [(.google.api.field_behavior) = REQUIRED]; */ - private $destination = null; + protected $destination = null; /** * Optional. To deliver messages, Eventarc might use other GCP * products as a transport intermediary. This field contains a reference to @@ -80,7 +80,7 @@ class Trigger extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.eventarc.v1.Transport transport = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $transport = null; + protected $transport = null; /** * Optional. User labels attached to the triggers that can be used to group resources. * @@ -94,7 +94,7 @@ class Trigger extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string channel = 13 [(.google.api.field_behavior) = OPTIONAL]; */ - private $channel = ''; + protected $channel = ''; /** * Output only. The reason(s) why a trigger is in FAILED state. * @@ -108,7 +108,7 @@ class Trigger extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 99 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $etag = ''; + protected $etag = ''; /** * Constructor. diff --git a/Eventarc/src/V1/UpdateChannelRequest.php b/Eventarc/src/V1/UpdateChannelRequest.php index 4e061a3c4b92..ebfe981eb675 100644 --- a/Eventarc/src/V1/UpdateChannelRequest.php +++ b/Eventarc/src/V1/UpdateChannelRequest.php @@ -20,7 +20,7 @@ class UpdateChannelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.eventarc.v1.Channel channel = 1; */ - private $channel = null; + protected $channel = null; /** * The fields to be updated; only fields explicitly provided are updated. * If no field mask is provided, all provided fields in the request are @@ -28,14 +28,14 @@ class UpdateChannelRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. If set, validate the request and preview the review, but do not * post it. * * Generated from protobuf field bool validate_only = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param \Google\Cloud\Eventarc\V1\Channel $channel The channel to be updated. diff --git a/Eventarc/src/V1/UpdateGoogleChannelConfigRequest.php b/Eventarc/src/V1/UpdateGoogleChannelConfigRequest.php index 1ec85a764a18..86a9f6b4dfdf 100644 --- a/Eventarc/src/V1/UpdateGoogleChannelConfigRequest.php +++ b/Eventarc/src/V1/UpdateGoogleChannelConfigRequest.php @@ -20,7 +20,7 @@ class UpdateGoogleChannelConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.eventarc.v1.GoogleChannelConfig google_channel_config = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $google_channel_config = null; + protected $google_channel_config = null; /** * The fields to be updated; only fields explicitly provided are updated. * If no field mask is provided, all provided fields in the request are @@ -28,7 +28,7 @@ class UpdateGoogleChannelConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\Eventarc\V1\GoogleChannelConfig $googleChannelConfig Required. The config to be updated. diff --git a/Eventarc/src/V1/UpdateTriggerRequest.php b/Eventarc/src/V1/UpdateTriggerRequest.php index b4e4fcec6d99..0063f4cb5469 100644 --- a/Eventarc/src/V1/UpdateTriggerRequest.php +++ b/Eventarc/src/V1/UpdateTriggerRequest.php @@ -20,7 +20,7 @@ class UpdateTriggerRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.eventarc.v1.Trigger trigger = 1; */ - private $trigger = null; + protected $trigger = null; /** * The fields to be updated; only fields explicitly provided are updated. * If no field mask is provided, all provided fields in the request are @@ -28,21 +28,21 @@ class UpdateTriggerRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * If set to true, and the trigger is not found, a new trigger will be * created. In this situation, `update_mask` is ignored. * * Generated from protobuf field bool allow_missing = 3; */ - private $allow_missing = false; + protected $allow_missing = false; /** * Required. If set, validate the request and preview the review, but do not * post it. * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param \Google\Cloud\Eventarc\V1\Trigger $trigger The trigger to be updated. diff --git a/Eventarc/tests/Unit/V1/Client/EventarcClientTest.php b/Eventarc/tests/Unit/V1/Client/EventarcClientTest.php index aa3e7e140c4d..78e8f4bee9df 100644 --- a/Eventarc/tests/Unit/V1/Client/EventarcClientTest.php +++ b/Eventarc/tests/Unit/V1/Client/EventarcClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return EventarcClient */ @@ -213,12 +215,15 @@ public function createChannelExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -362,12 +367,15 @@ public function createChannelConnectionExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -519,12 +527,15 @@ public function createTriggerExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -608,9 +619,7 @@ public function deleteChannelTest() // Mock request $formattedName = $gapicClient->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); $validateOnly = false; - $request = (new DeleteChannelRequest()) - ->setName($formattedName) - ->setValidateOnly($validateOnly); + $request = (new DeleteChannelRequest())->setName($formattedName)->setValidateOnly($validateOnly); $response = $gapicClient->deleteChannel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -668,19 +677,20 @@ public function deleteChannelExceptionTest() $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); + $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->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); $validateOnly = false; - $request = (new DeleteChannelRequest()) - ->setName($formattedName) - ->setValidateOnly($validateOnly); + $request = (new DeleteChannelRequest())->setName($formattedName)->setValidateOnly($validateOnly); $response = $gapicClient->deleteChannel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -742,8 +752,7 @@ public function deleteChannelConnectionTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - $request = (new DeleteChannelConnectionRequest()) - ->setName($formattedName); + $request = (new DeleteChannelConnectionRequest())->setName($formattedName); $response = $gapicClient->deleteChannelConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -799,17 +808,19 @@ public function deleteChannelConnectionExceptionTest() $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); + $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->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - $request = (new DeleteChannelConnectionRequest()) - ->setName($formattedName); + $request = (new DeleteChannelConnectionRequest())->setName($formattedName); $response = $gapicClient->deleteChannelConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -874,9 +885,7 @@ public function deleteTriggerTest() // Mock request $formattedName = $gapicClient->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); $validateOnly = false; - $request = (new DeleteTriggerRequest()) - ->setName($formattedName) - ->setValidateOnly($validateOnly); + $request = (new DeleteTriggerRequest())->setName($formattedName)->setValidateOnly($validateOnly); $response = $gapicClient->deleteTrigger($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -934,19 +943,20 @@ public function deleteTriggerExceptionTest() $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); + $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->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); $validateOnly = false; - $request = (new DeleteTriggerRequest()) - ->setName($formattedName) - ->setValidateOnly($validateOnly); + $request = (new DeleteTriggerRequest())->setName($formattedName)->setValidateOnly($validateOnly); $response = $gapicClient->deleteTrigger($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -994,8 +1004,7 @@ public function getChannelTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - $request = (new GetChannelRequest()) - ->setName($formattedName); + $request = (new GetChannelRequest())->setName($formattedName); $response = $gapicClient->getChannel($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1019,17 +1028,19 @@ public function getChannelExceptionTest() $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); + $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->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - $request = (new GetChannelRequest()) - ->setName($formattedName); + $request = (new GetChannelRequest())->setName($formattedName); try { $gapicClient->getChannel($request); // If the $gapicClient method call did not throw, fail the test @@ -1064,8 +1075,7 @@ public function getChannelConnectionTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - $request = (new GetChannelConnectionRequest()) - ->setName($formattedName); + $request = (new GetChannelConnectionRequest())->setName($formattedName); $response = $gapicClient->getChannelConnection($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1089,17 +1099,19 @@ public function getChannelConnectionExceptionTest() $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); + $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->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - $request = (new GetChannelConnectionRequest()) - ->setName($formattedName); + $request = (new GetChannelConnectionRequest())->setName($formattedName); try { $gapicClient->getChannelConnection($request); // If the $gapicClient method call did not throw, fail the test @@ -1130,8 +1142,7 @@ public function getGoogleChannelConfigTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->googleChannelConfigName('[PROJECT]', '[LOCATION]'); - $request = (new GetGoogleChannelConfigRequest()) - ->setName($formattedName); + $request = (new GetGoogleChannelConfigRequest())->setName($formattedName); $response = $gapicClient->getGoogleChannelConfig($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1155,17 +1166,19 @@ public function getGoogleChannelConfigExceptionTest() $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); + $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->googleChannelConfigName('[PROJECT]', '[LOCATION]'); - $request = (new GetGoogleChannelConfigRequest()) - ->setName($formattedName); + $request = (new GetGoogleChannelConfigRequest())->setName($formattedName); try { $gapicClient->getGoogleChannelConfig($request); // If the $gapicClient method call did not throw, fail the test @@ -1196,8 +1209,7 @@ public function getProviderTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->providerName('[PROJECT]', '[LOCATION]', '[PROVIDER]'); - $request = (new GetProviderRequest()) - ->setName($formattedName); + $request = (new GetProviderRequest())->setName($formattedName); $response = $gapicClient->getProvider($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1221,17 +1233,19 @@ public function getProviderExceptionTest() $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); + $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->providerName('[PROJECT]', '[LOCATION]', '[PROVIDER]'); - $request = (new GetProviderRequest()) - ->setName($formattedName); + $request = (new GetProviderRequest())->setName($formattedName); try { $gapicClient->getProvider($request); // If the $gapicClient method call did not throw, fail the test @@ -1268,8 +1282,7 @@ public function getTriggerTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); - $request = (new GetTriggerRequest()) - ->setName($formattedName); + $request = (new GetTriggerRequest())->setName($formattedName); $response = $gapicClient->getTrigger($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1293,17 +1306,19 @@ public function getTriggerExceptionTest() $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); + $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->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); - $request = (new GetTriggerRequest()) - ->setName($formattedName); + $request = (new GetTriggerRequest())->setName($formattedName); try { $gapicClient->getTrigger($request); // If the $gapicClient method call did not throw, fail the test @@ -1328,17 +1343,14 @@ public function listChannelConnectionsTest() // Mock response $nextPageToken = ''; $channelConnectionsElement = new ChannelConnection(); - $channelConnections = [ - $channelConnectionsElement, - ]; + $channelConnections = [$channelConnectionsElement]; $expectedResponse = new ListChannelConnectionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setChannelConnections($channelConnections); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListChannelConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListChannelConnectionsRequest())->setParent($formattedParent); $response = $gapicClient->listChannelConnections($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1365,17 +1377,19 @@ public function listChannelConnectionsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListChannelConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListChannelConnectionsRequest())->setParent($formattedParent); try { $gapicClient->listChannelConnections($request); // If the $gapicClient method call did not throw, fail the test @@ -1400,17 +1414,14 @@ public function listChannelsTest() // Mock response $nextPageToken = ''; $channelsElement = new Channel(); - $channels = [ - $channelsElement, - ]; + $channels = [$channelsElement]; $expectedResponse = new ListChannelsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setChannels($channels); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListChannelsRequest()) - ->setParent($formattedParent); + $request = (new ListChannelsRequest())->setParent($formattedParent); $response = $gapicClient->listChannels($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1437,17 +1448,19 @@ public function listChannelsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListChannelsRequest()) - ->setParent($formattedParent); + $request = (new ListChannelsRequest())->setParent($formattedParent); try { $gapicClient->listChannels($request); // If the $gapicClient method call did not throw, fail the test @@ -1472,17 +1485,14 @@ public function listProvidersTest() // Mock response $nextPageToken = ''; $providersElement = new Provider(); - $providers = [ - $providersElement, - ]; + $providers = [$providersElement]; $expectedResponse = new ListProvidersResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setProviders($providers); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListProvidersRequest()) - ->setParent($formattedParent); + $request = (new ListProvidersRequest())->setParent($formattedParent); $response = $gapicClient->listProviders($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1509,17 +1519,19 @@ public function listProvidersExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListProvidersRequest()) - ->setParent($formattedParent); + $request = (new ListProvidersRequest())->setParent($formattedParent); try { $gapicClient->listProviders($request); // If the $gapicClient method call did not throw, fail the test @@ -1544,17 +1556,14 @@ public function listTriggersTest() // Mock response $nextPageToken = ''; $triggersElement = new Trigger(); - $triggers = [ - $triggersElement, - ]; + $triggers = [$triggersElement]; $expectedResponse = new ListTriggersResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setTriggers($triggers); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListTriggersRequest()) - ->setParent($formattedParent); + $request = (new ListTriggersRequest())->setParent($formattedParent); $response = $gapicClient->listTriggers($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1581,17 +1590,19 @@ public function listTriggersExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListTriggersRequest()) - ->setParent($formattedParent); + $request = (new ListTriggersRequest())->setParent($formattedParent); try { $gapicClient->listTriggers($request); // If the $gapicClient method call did not throw, fail the test @@ -1648,8 +1659,7 @@ public function updateChannelTest() $operationsTransport->addResponse($completeOperation); // Mock request $validateOnly = false; - $request = (new UpdateChannelRequest()) - ->setValidateOnly($validateOnly); + $request = (new UpdateChannelRequest())->setValidateOnly($validateOnly); $response = $gapicClient->updateChannel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1705,17 +1715,19 @@ public function updateChannelExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $validateOnly = false; - $request = (new UpdateChannelRequest()) - ->setValidateOnly($validateOnly); + $request = (new UpdateChannelRequest())->setValidateOnly($validateOnly); $response = $gapicClient->updateChannel($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1757,8 +1769,7 @@ public function updateGoogleChannelConfigTest() $googleChannelConfig = new GoogleChannelConfig(); $googleChannelConfigName = 'googleChannelConfigName-13357801'; $googleChannelConfig->setName($googleChannelConfigName); - $request = (new UpdateGoogleChannelConfigRequest()) - ->setGoogleChannelConfig($googleChannelConfig); + $request = (new UpdateGoogleChannelConfigRequest())->setGoogleChannelConfig($googleChannelConfig); $response = $gapicClient->updateGoogleChannelConfig($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1782,19 +1793,21 @@ public function updateGoogleChannelConfigExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $googleChannelConfig = new GoogleChannelConfig(); $googleChannelConfigName = 'googleChannelConfigName-13357801'; $googleChannelConfig->setName($googleChannelConfigName); - $request = (new UpdateGoogleChannelConfigRequest()) - ->setGoogleChannelConfig($googleChannelConfig); + $request = (new UpdateGoogleChannelConfigRequest())->setGoogleChannelConfig($googleChannelConfig); try { $gapicClient->updateGoogleChannelConfig($request); // If the $gapicClient method call did not throw, fail the test @@ -1849,8 +1862,7 @@ public function updateTriggerTest() $operationsTransport->addResponse($completeOperation); // Mock request $validateOnly = false; - $request = (new UpdateTriggerRequest()) - ->setValidateOnly($validateOnly); + $request = (new UpdateTriggerRequest())->setValidateOnly($validateOnly); $response = $gapicClient->updateTrigger($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1906,17 +1918,19 @@ public function updateTriggerExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $validateOnly = false; - $request = (new UpdateTriggerRequest()) - ->setValidateOnly($validateOnly); + $request = (new UpdateTriggerRequest())->setValidateOnly($validateOnly); $response = $gapicClient->updateTrigger($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1978,12 +1992,15 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -2010,9 +2027,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -2042,12 +2057,15 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -2080,8 +2098,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2105,17 +2122,19 @@ public function getIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -2147,9 +2166,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2175,19 +2192,20 @@ public function setIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -2215,9 +2233,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2243,19 +2259,20 @@ public function testIamPermissionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test diff --git a/Eventarc/tests/Unit/V1/EventarcClientTest.php b/Eventarc/tests/Unit/V1/EventarcClientTest.php deleted file mode 100644 index a170f45873a7..000000000000 --- a/Eventarc/tests/Unit/V1/EventarcClientTest.php +++ /dev/null @@ -1,2136 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return EventarcClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new EventarcClient($options); - } - - /** @test */ - public function createChannelTest() - { - $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/createChannelTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $uid = 'uid115792'; - $provider = 'provider-987494927'; - $pubsubTopic = 'pubsubTopic-338126829'; - $activationToken = 'activationToken1250030992'; - $cryptoKeyName = 'cryptoKeyName-184663511'; - $expectedResponse = new Channel(); - $expectedResponse->setName($name); - $expectedResponse->setUid($uid); - $expectedResponse->setProvider($provider); - $expectedResponse->setPubsubTopic($pubsubTopic); - $expectedResponse->setActivationToken($activationToken); - $expectedResponse->setCryptoKeyName($cryptoKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createChannelTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $channel = new Channel(); - $channelName = 'channelName273953326'; - $channel->setName($channelName); - $channelId = 'channelId-1930808873'; - $validateOnly = false; - $response = $gapicClient->createChannel($formattedParent, $channel, $channelId, $validateOnly); - $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.eventarc.v1.Eventarc/CreateChannel', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getChannel(); - $this->assertProtobufEquals($channel, $actualValue); - $actualValue = $actualApiRequestObject->getChannelId(); - $this->assertProtobufEquals($channelId, $actualValue); - $actualValue = $actualApiRequestObject->getValidateOnly(); - $this->assertProtobufEquals($validateOnly, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createChannelTest'); - $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 createChannelExceptionTest() - { - $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/createChannelTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $channel = new Channel(); - $channelName = 'channelName273953326'; - $channel->setName($channelName); - $channelId = 'channelId-1930808873'; - $validateOnly = false; - $response = $gapicClient->createChannel($formattedParent, $channel, $channelId, $validateOnly); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createChannelTest'); - 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 createChannelConnectionTest() - { - $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/createChannelConnectionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $uid = 'uid115792'; - $channel = 'channel738950403'; - $activationToken = 'activationToken1250030992'; - $expectedResponse = new ChannelConnection(); - $expectedResponse->setName($name); - $expectedResponse->setUid($uid); - $expectedResponse->setChannel($channel); - $expectedResponse->setActivationToken($activationToken); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createChannelConnectionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $channelConnection = new ChannelConnection(); - $channelConnectionName = 'channelConnectionName-46623124'; - $channelConnection->setName($channelConnectionName); - $channelConnectionChannel = $gapicClient->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - $channelConnection->setChannel($channelConnectionChannel); - $channelConnectionId = 'channelConnectionId-1611273248'; - $response = $gapicClient->createChannelConnection($formattedParent, $channelConnection, $channelConnectionId); - $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.eventarc.v1.Eventarc/CreateChannelConnection', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getChannelConnection(); - $this->assertProtobufEquals($channelConnection, $actualValue); - $actualValue = $actualApiRequestObject->getChannelConnectionId(); - $this->assertProtobufEquals($channelConnectionId, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createChannelConnectionTest'); - $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 createChannelConnectionExceptionTest() - { - $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/createChannelConnectionTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $channelConnection = new ChannelConnection(); - $channelConnectionName = 'channelConnectionName-46623124'; - $channelConnection->setName($channelConnectionName); - $channelConnectionChannel = $gapicClient->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - $channelConnection->setChannel($channelConnectionChannel); - $channelConnectionId = 'channelConnectionId-1611273248'; - $response = $gapicClient->createChannelConnection($formattedParent, $channelConnection, $channelConnectionId); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createChannelConnectionTest'); - 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 createTriggerTest() - { - $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/createTriggerTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $uid = 'uid115792'; - $serviceAccount = 'serviceAccount-1948028253'; - $channel = 'channel738950403'; - $etag = 'etag3123477'; - $expectedResponse = new Trigger(); - $expectedResponse->setName($name); - $expectedResponse->setUid($uid); - $expectedResponse->setServiceAccount($serviceAccount); - $expectedResponse->setChannel($channel); - $expectedResponse->setEtag($etag); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createTriggerTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $trigger = new Trigger(); - $triggerName = 'triggerName-681138077'; - $trigger->setName($triggerName); - $triggerEventFilters = []; - $trigger->setEventFilters($triggerEventFilters); - $triggerDestination = new Destination(); - $trigger->setDestination($triggerDestination); - $triggerId = 'triggerId1363517698'; - $validateOnly = false; - $response = $gapicClient->createTrigger($formattedParent, $trigger, $triggerId, $validateOnly); - $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.eventarc.v1.Eventarc/CreateTrigger', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getTrigger(); - $this->assertProtobufEquals($trigger, $actualValue); - $actualValue = $actualApiRequestObject->getTriggerId(); - $this->assertProtobufEquals($triggerId, $actualValue); - $actualValue = $actualApiRequestObject->getValidateOnly(); - $this->assertProtobufEquals($validateOnly, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createTriggerTest'); - $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 createTriggerExceptionTest() - { - $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/createTriggerTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $trigger = new Trigger(); - $triggerName = 'triggerName-681138077'; - $trigger->setName($triggerName); - $triggerEventFilters = []; - $trigger->setEventFilters($triggerEventFilters); - $triggerDestination = new Destination(); - $trigger->setDestination($triggerDestination); - $triggerId = 'triggerId1363517698'; - $validateOnly = false; - $response = $gapicClient->createTrigger($formattedParent, $trigger, $triggerId, $validateOnly); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createTriggerTest'); - 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 deleteChannelTest() - { - $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/deleteChannelTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $provider = 'provider-987494927'; - $pubsubTopic = 'pubsubTopic-338126829'; - $activationToken = 'activationToken1250030992'; - $cryptoKeyName = 'cryptoKeyName-184663511'; - $expectedResponse = new Channel(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setProvider($provider); - $expectedResponse->setPubsubTopic($pubsubTopic); - $expectedResponse->setActivationToken($activationToken); - $expectedResponse->setCryptoKeyName($cryptoKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteChannelTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - $validateOnly = false; - $response = $gapicClient->deleteChannel($formattedName, $validateOnly); - $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.eventarc.v1.Eventarc/DeleteChannel', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getValidateOnly(); - $this->assertProtobufEquals($validateOnly, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteChannelTest'); - $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 deleteChannelExceptionTest() - { - $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/deleteChannelTest'); - $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->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - $validateOnly = false; - $response = $gapicClient->deleteChannel($formattedName, $validateOnly); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteChannelTest'); - 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 deleteChannelConnectionTest() - { - $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/deleteChannelConnectionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $channel = 'channel738950403'; - $activationToken = 'activationToken1250030992'; - $expectedResponse = new ChannelConnection(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setChannel($channel); - $expectedResponse->setActivationToken($activationToken); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteChannelConnectionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - $response = $gapicClient->deleteChannelConnection($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.eventarc.v1.Eventarc/DeleteChannelConnection', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteChannelConnectionTest'); - $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 deleteChannelConnectionExceptionTest() - { - $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/deleteChannelConnectionTest'); - $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->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - $response = $gapicClient->deleteChannelConnection($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteChannelConnectionTest'); - 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 deleteTriggerTest() - { - $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/deleteTriggerTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $serviceAccount = 'serviceAccount-1948028253'; - $channel = 'channel738950403'; - $etag2 = 'etag2-1293302904'; - $expectedResponse = new Trigger(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setServiceAccount($serviceAccount); - $expectedResponse->setChannel($channel); - $expectedResponse->setEtag($etag2); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteTriggerTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); - $validateOnly = false; - $response = $gapicClient->deleteTrigger($formattedName, $validateOnly); - $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.eventarc.v1.Eventarc/DeleteTrigger', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getValidateOnly(); - $this->assertProtobufEquals($validateOnly, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteTriggerTest'); - $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 deleteTriggerExceptionTest() - { - $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/deleteTriggerTest'); - $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->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); - $validateOnly = false; - $response = $gapicClient->deleteTrigger($formattedName, $validateOnly); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteTriggerTest'); - 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 getChannelTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $provider = 'provider-987494927'; - $pubsubTopic = 'pubsubTopic-338126829'; - $activationToken = 'activationToken1250030992'; - $cryptoKeyName = 'cryptoKeyName-184663511'; - $expectedResponse = new Channel(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setProvider($provider); - $expectedResponse->setPubsubTopic($pubsubTopic); - $expectedResponse->setActivationToken($activationToken); - $expectedResponse->setCryptoKeyName($cryptoKeyName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - $response = $gapicClient->getChannel($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.eventarc.v1.Eventarc/GetChannel', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getChannelExceptionTest() - { - $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->channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]'); - try { - $gapicClient->getChannel($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 getChannelConnectionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $channel = 'channel738950403'; - $activationToken = 'activationToken1250030992'; - $expectedResponse = new ChannelConnection(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setChannel($channel); - $expectedResponse->setActivationToken($activationToken); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - $response = $gapicClient->getChannelConnection($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.eventarc.v1.Eventarc/GetChannelConnection', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getChannelConnectionExceptionTest() - { - $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->channelConnectionName('[PROJECT]', '[LOCATION]', '[CHANNEL_CONNECTION]'); - try { - $gapicClient->getChannelConnection($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 getGoogleChannelConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $cryptoKeyName = 'cryptoKeyName-184663511'; - $expectedResponse = new GoogleChannelConfig(); - $expectedResponse->setName($name2); - $expectedResponse->setCryptoKeyName($cryptoKeyName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->googleChannelConfigName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->getGoogleChannelConfig($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.eventarc.v1.Eventarc/GetGoogleChannelConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getGoogleChannelConfigExceptionTest() - { - $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->googleChannelConfigName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->getGoogleChannelConfig($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 getProviderTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Provider(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->providerName('[PROJECT]', '[LOCATION]', '[PROVIDER]'); - $response = $gapicClient->getProvider($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.eventarc.v1.Eventarc/GetProvider', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getProviderExceptionTest() - { - $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->providerName('[PROJECT]', '[LOCATION]', '[PROVIDER]'); - try { - $gapicClient->getProvider($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 getTriggerTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $serviceAccount = 'serviceAccount-1948028253'; - $channel = 'channel738950403'; - $etag = 'etag3123477'; - $expectedResponse = new Trigger(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setServiceAccount($serviceAccount); - $expectedResponse->setChannel($channel); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); - $response = $gapicClient->getTrigger($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.eventarc.v1.Eventarc/GetTrigger', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getTriggerExceptionTest() - { - $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->triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]'); - try { - $gapicClient->getTrigger($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 listChannelConnectionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $channelConnectionsElement = new ChannelConnection(); - $channelConnections = [ - $channelConnectionsElement, - ]; - $expectedResponse = new ListChannelConnectionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setChannelConnections($channelConnections); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listChannelConnections($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getChannelConnections()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.eventarc.v1.Eventarc/ListChannelConnections', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listChannelConnectionsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listChannelConnections($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 listChannelsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $channelsElement = new Channel(); - $channels = [ - $channelsElement, - ]; - $expectedResponse = new ListChannelsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setChannels($channels); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listChannels($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getChannels()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.eventarc.v1.Eventarc/ListChannels', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listChannelsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listChannels($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 listProvidersTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $providersElement = new Provider(); - $providers = [ - $providersElement, - ]; - $expectedResponse = new ListProvidersResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setProviders($providers); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listProviders($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getProviders()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.eventarc.v1.Eventarc/ListProviders', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listProvidersExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listProviders($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 listTriggersTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $triggersElement = new Trigger(); - $triggers = [ - $triggersElement, - ]; - $expectedResponse = new ListTriggersResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setTriggers($triggers); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listTriggers($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getTriggers()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.eventarc.v1.Eventarc/ListTriggers', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listTriggersExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listTriggers($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 updateChannelTest() - { - $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/updateChannelTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $uid = 'uid115792'; - $provider = 'provider-987494927'; - $pubsubTopic = 'pubsubTopic-338126829'; - $activationToken = 'activationToken1250030992'; - $cryptoKeyName = 'cryptoKeyName-184663511'; - $expectedResponse = new Channel(); - $expectedResponse->setName($name); - $expectedResponse->setUid($uid); - $expectedResponse->setProvider($provider); - $expectedResponse->setPubsubTopic($pubsubTopic); - $expectedResponse->setActivationToken($activationToken); - $expectedResponse->setCryptoKeyName($cryptoKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateChannelTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $validateOnly = false; - $response = $gapicClient->updateChannel($validateOnly); - $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.eventarc.v1.Eventarc/UpdateChannel', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getValidateOnly(); - $this->assertProtobufEquals($validateOnly, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateChannelTest'); - $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 updateChannelExceptionTest() - { - $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/updateChannelTest'); - $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 - $validateOnly = false; - $response = $gapicClient->updateChannel($validateOnly); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateChannelTest'); - 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 updateGoogleChannelConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $cryptoKeyName = 'cryptoKeyName-184663511'; - $expectedResponse = new GoogleChannelConfig(); - $expectedResponse->setName($name); - $expectedResponse->setCryptoKeyName($cryptoKeyName); - $transport->addResponse($expectedResponse); - // Mock request - $googleChannelConfig = new GoogleChannelConfig(); - $googleChannelConfigName = 'googleChannelConfigName-13357801'; - $googleChannelConfig->setName($googleChannelConfigName); - $response = $gapicClient->updateGoogleChannelConfig($googleChannelConfig); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.eventarc.v1.Eventarc/UpdateGoogleChannelConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getGoogleChannelConfig(); - $this->assertProtobufEquals($googleChannelConfig, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateGoogleChannelConfigExceptionTest() - { - $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 - $googleChannelConfig = new GoogleChannelConfig(); - $googleChannelConfigName = 'googleChannelConfigName-13357801'; - $googleChannelConfig->setName($googleChannelConfigName); - try { - $gapicClient->updateGoogleChannelConfig($googleChannelConfig); - // 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 updateTriggerTest() - { - $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/updateTriggerTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $uid = 'uid115792'; - $serviceAccount = 'serviceAccount-1948028253'; - $channel = 'channel738950403'; - $etag = 'etag3123477'; - $expectedResponse = new Trigger(); - $expectedResponse->setName($name); - $expectedResponse->setUid($uid); - $expectedResponse->setServiceAccount($serviceAccount); - $expectedResponse->setChannel($channel); - $expectedResponse->setEtag($etag); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateTriggerTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $validateOnly = false; - $response = $gapicClient->updateTrigger($validateOnly); - $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.eventarc.v1.Eventarc/UpdateTrigger', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getValidateOnly(); - $this->assertProtobufEquals($validateOnly, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateTriggerTest'); - $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 updateTriggerExceptionTest() - { - $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/updateTriggerTest'); - $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 - $validateOnly = false; - $response = $gapicClient->updateTrigger($validateOnly); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateTriggerTest'); - 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 getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $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); - try { - $gapicClient->getLocation(); - // 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 listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $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); - try { - $gapicClient->listLocations(); - // 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 getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/Filestore/owlbot.py b/Filestore/owlbot.py index 7b7cd62163b9..b3de46352842 100644 --- a/Filestore/owlbot.py +++ b/Filestore/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,32 +41,6 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - # format generated clients subprocess.run([ 'npm', @@ -82,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/Filestore/src/V1/Backup.php b/Filestore/src/V1/Backup.php index 6c1515e31e4f..6e3a95d681dd 100644 --- a/Filestore/src/V1/Backup.php +++ b/Filestore/src/V1/Backup.php @@ -21,26 +21,26 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * A description of the backup with 2048 characters or less. * Requests with longer descriptions will be rejected. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * Output only. The backup state. * * Generated from protobuf field .google.cloud.filestore.v1.Backup.State state = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The time when the backup was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Resource labels to represent user provided metadata. * @@ -52,14 +52,14 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 capacity_gb = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $capacity_gb = 0; + protected $capacity_gb = 0; /** * Output only. The size of the storage used by the backup. As backups share * storage, this number is expected to change with backup creation/deletion. * * Generated from protobuf field int64 storage_bytes = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $storage_bytes = 0; + protected $storage_bytes = 0; /** * The resource name of the source Filestore instance, in the format * `projects/{project_number}/locations/{location_id}/instances/{instance_id}`, @@ -67,21 +67,21 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_instance = 8 [(.google.api.resource_reference) = { */ - private $source_instance = ''; + protected $source_instance = ''; /** * Name of the file share in the source Filestore instance that the * backup is created from. * * Generated from protobuf field string source_file_share = 9; */ - private $source_file_share = ''; + protected $source_file_share = ''; /** * Output only. The service tier of the source Filestore instance that this * backup is created from. * * Generated from protobuf field .google.cloud.filestore.v1.Instance.Tier source_instance_tier = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $source_instance_tier = 0; + protected $source_instance_tier = 0; /** * Output only. Amount of bytes that will be downloaded if the backup is * restored. This may be different than storage bytes, since sequential @@ -89,25 +89,25 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 download_bytes = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $download_bytes = 0; + protected $download_bytes = 0; /** * Output only. Reserved for future use. * * Generated from protobuf field .google.protobuf.BoolValue satisfies_pzs = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $satisfies_pzs = null; + protected $satisfies_pzs = null; /** * Output only. Reserved for future use. * * Generated from protobuf field bool satisfies_pzi = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $satisfies_pzi = false; + protected $satisfies_pzi = false; /** * Immutable. KMS key name used for data encryption. * * Generated from protobuf field string kms_key = 13 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $kms_key = ''; + protected $kms_key = ''; /** * Constructor. @@ -502,7 +502,7 @@ public function clearSatisfiesPzs() * Generated from protobuf field .google.protobuf.BoolValue satisfies_pzs = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return bool|null */ - public function getSatisfiesPzsValue() + public function getSatisfiesPzsUnwrapped() { return $this->readWrapperValue("satisfies_pzs"); } @@ -531,7 +531,7 @@ public function setSatisfiesPzs($var) * @param bool|null $var * @return $this */ - public function setSatisfiesPzsValue($var) + public function setSatisfiesPzsUnwrapped($var) { $this->writeWrapperValue("satisfies_pzs", $var); return $this;} diff --git a/Filestore/src/V1/Client/CloudFilestoreManagerClient.php b/Filestore/src/V1/Client/CloudFilestoreManagerClient.php index bd2c332ec3d0..7ad54976946d 100644 --- a/Filestore/src/V1/Client/CloudFilestoreManagerClient.php +++ b/Filestore/src/V1/Client/CloudFilestoreManagerClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a backup * resource. diff --git a/Filestore/src/V1/CloudFilestoreManagerClient.php b/Filestore/src/V1/CloudFilestoreManagerClient.php deleted file mode 100644 index 9801b68df2d2..000000000000 --- a/Filestore/src/V1/CloudFilestoreManagerClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. A [backup resource][google.cloud.filestore.v1.Backup] * * Generated from protobuf field .google.cloud.filestore.v1.Backup backup = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $backup = null; + protected $backup = null; /** * Required. The ID to use for the backup. * The ID must be unique within the specified project and location. @@ -39,7 +39,7 @@ class CreateBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string backup_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $backup_id = ''; + protected $backup_id = ''; /** * @param string $parent Required. The backup's project and location, in the format diff --git a/Filestore/src/V1/CreateInstanceRequest.php b/Filestore/src/V1/CreateInstanceRequest.php index 5503378c582d..1e1334b891cb 100644 --- a/Filestore/src/V1/CreateInstanceRequest.php +++ b/Filestore/src/V1/CreateInstanceRequest.php @@ -22,20 +22,20 @@ class CreateInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The name of the instance to create. * The name must be unique for the specified project and location. * * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $instance_id = ''; + protected $instance_id = ''; /** * Required. An [instance resource][google.cloud.filestore.v1.Instance] * * Generated from protobuf field .google.cloud.filestore.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $instance = null; + protected $instance = null; /** * @param string $parent Required. The instance's project and location, in the format diff --git a/Filestore/src/V1/CreateSnapshotRequest.php b/Filestore/src/V1/CreateSnapshotRequest.php index d9b45e9fe7df..314fbaba9cc4 100644 --- a/Filestore/src/V1/CreateSnapshotRequest.php +++ b/Filestore/src/V1/CreateSnapshotRequest.php @@ -21,7 +21,7 @@ class CreateSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID to use for the snapshot. * The ID must be unique within the specified instance. @@ -30,13 +30,13 @@ class CreateSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string snapshot_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $snapshot_id = ''; + protected $snapshot_id = ''; /** * Required. A snapshot resource. * * Generated from protobuf field .google.cloud.filestore.v1.Snapshot snapshot = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $snapshot = null; + protected $snapshot = null; /** * @param string $parent Required. The Filestore Instance to create the snapshots of, in the format diff --git a/Filestore/src/V1/DeleteBackupRequest.php b/Filestore/src/V1/DeleteBackupRequest.php index d996b3736b03..62048dd9520f 100644 --- a/Filestore/src/V1/DeleteBackupRequest.php +++ b/Filestore/src/V1/DeleteBackupRequest.php @@ -21,7 +21,7 @@ class DeleteBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The backup resource name, in the format diff --git a/Filestore/src/V1/DeleteInstanceRequest.php b/Filestore/src/V1/DeleteInstanceRequest.php index 99bf1f4d38ac..02964f58e99a 100644 --- a/Filestore/src/V1/DeleteInstanceRequest.php +++ b/Filestore/src/V1/DeleteInstanceRequest.php @@ -21,14 +21,14 @@ class DeleteInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * If set to true, all snapshots of the instance will also be deleted. * (Otherwise, the request will only work if the instance has no snapshots.) * * Generated from protobuf field bool force = 2; */ - private $force = false; + protected $force = false; /** * @param string $name Required. The instance resource name, in the format diff --git a/Filestore/src/V1/DeleteSnapshotRequest.php b/Filestore/src/V1/DeleteSnapshotRequest.php index 2506f86d887f..ef16ddaceaf3 100644 --- a/Filestore/src/V1/DeleteSnapshotRequest.php +++ b/Filestore/src/V1/DeleteSnapshotRequest.php @@ -21,7 +21,7 @@ class DeleteSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The snapshot resource name, in the format diff --git a/Filestore/src/V1/FileShareConfig.php b/Filestore/src/V1/FileShareConfig.php index 10f94769038a..dc1cb573dd40 100644 --- a/Filestore/src/V1/FileShareConfig.php +++ b/Filestore/src/V1/FileShareConfig.php @@ -23,14 +23,14 @@ class FileShareConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * File share capacity in gigabytes (GB). * Filestore defines 1 GB as 1024^3 bytes. * * Generated from protobuf field int64 capacity_gb = 2; */ - private $capacity_gb = 0; + protected $capacity_gb = 0; /** * Nfs Export Options. * There is a limit of 10 export options per file share. diff --git a/Filestore/src/V1/Gapic/CloudFilestoreManagerGapicClient.php b/Filestore/src/V1/Gapic/CloudFilestoreManagerGapicClient.php deleted file mode 100644 index 2ec2f6665456..000000000000 --- a/Filestore/src/V1/Gapic/CloudFilestoreManagerGapicClient.php +++ /dev/null @@ -1,1817 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $backup = new Backup(); - * $backupId = 'backup_id'; - * $operationResponse = $cloudFilestoreManagerClient->createBackup($formattedParent, $backup, $backupId); - * $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 = $cloudFilestoreManagerClient->createBackup($formattedParent, $backup, $backupId); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'createBackup'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Filestore\V1\Client\CloudFilestoreManagerClient}. - */ -class CloudFilestoreManagerGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.filestore.v1.CloudFilestoreManager'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'file.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'file.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $backupNameTemplate; - - private static $instanceNameTemplate; - - private static $locationNameTemplate; - - private static $snapshotNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getBackupNameTemplate() - { - if (self::$backupNameTemplate == null) { - self::$backupNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/backups/{backup}' - ); - } - - return self::$backupNameTemplate; - } - - private static function getInstanceNameTemplate() - { - if (self::$instanceNameTemplate == null) { - self::$instanceNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' - ); - } - - return self::$instanceNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getSnapshotNameTemplate() - { - if (self::$snapshotNameTemplate == null) { - self::$snapshotNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}/snapshots/{snapshot}' - ); - } - - return self::$snapshotNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'backup' => self::getBackupNameTemplate(), - 'instance' => self::getInstanceNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'snapshot' => self::getSnapshotNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location, $backup) - { - return self::getBackupNameTemplate()->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($project, $location, $instance) - { - return self::getInstanceNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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( - $project, - $location, - $instance, - $snapshot - ) { - return self::getSnapshotNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Creates a backup. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedParent = $cloudFilestoreManagerClient->locationName('[PROJECT]', '[LOCATION]'); - * $backup = new Backup(); - * $backupId = 'backup_id'; - * $operationResponse = $cloudFilestoreManagerClient->createBackup($formattedParent, $backup, $backupId); - * $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 = $cloudFilestoreManagerClient->createBackup($formattedParent, $backup, $backupId); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'createBackup'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. The backup's project and location, in the format - * `projects/{project_number}/locations/{location}`. In Filestore, - * backup locations map to Google Cloud regions, for example **us-west1**. - * @param Backup $backup Required. A [backup resource][google.cloud.filestore.v1.Backup] - * @param string $backupId Required. The ID to use for the backup. - * The ID must be unique within the specified project and location. - * - * This value must start with a lowercase letter followed by up to 62 - * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. - * Values that do not match this pattern will trigger an INVALID_ARGUMENT - * error. - * @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 createBackup( - $parent, - $backup, - $backupId, - array $optionalArgs = [] - ) { - $request = new CreateBackupRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setBackup($backup); - $request->setBackupId($backupId); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateBackup', - $optionalArgs, - $request, - $this->getOperationsClient() - )->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). - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedParent = $cloudFilestoreManagerClient->locationName('[PROJECT]', '[LOCATION]'); - * $instanceId = 'instance_id'; - * $instance = new Instance(); - * $operationResponse = $cloudFilestoreManagerClient->createInstance($formattedParent, $instanceId, $instance); - * $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 = $cloudFilestoreManagerClient->createInstance($formattedParent, $instanceId, $instance); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'createInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. The instance's project and location, in the format - * `projects/{project_id}/locations/{location}`. In Filestore, - * locations map to Google Cloud zones, for example **us-west1-b**. - * @param string $instanceId Required. The name of the instance to create. - * The name must be unique for the specified project and location. - * @param Instance $instance Required. An [instance resource][google.cloud.filestore.v1.Instance] - * @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 createInstance( - $parent, - $instanceId, - $instance, - array $optionalArgs = [] - ) { - $request = new CreateInstanceRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setInstanceId($instanceId); - $request->setInstance($instance); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Creates a snapshot. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedParent = $cloudFilestoreManagerClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $snapshotId = 'snapshot_id'; - * $snapshot = new Snapshot(); - * $operationResponse = $cloudFilestoreManagerClient->createSnapshot($formattedParent, $snapshotId, $snapshot); - * $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 = $cloudFilestoreManagerClient->createSnapshot($formattedParent, $snapshotId, $snapshot); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'createSnapshot'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. The Filestore Instance to create the snapshots of, in the format - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param string $snapshotId Required. The ID to use for the snapshot. - * The ID must be unique within the specified instance. - * - * This value must start with a lowercase letter followed by up to 62 - * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. - * @param Snapshot $snapshot Required. A snapshot resource. - * @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 createSnapshot( - $parent, - $snapshotId, - $snapshot, - array $optionalArgs = [] - ) { - $request = new CreateSnapshotRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setSnapshotId($snapshotId); - $request->setSnapshot($snapshot); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateSnapshot', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a backup. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedName = $cloudFilestoreManagerClient->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - * $operationResponse = $cloudFilestoreManagerClient->deleteBackup($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 = $cloudFilestoreManagerClient->deleteBackup($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'deleteBackup'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $name Required. The backup resource name, in the format - * `projects/{project_number}/locations/{location}/backups/{backup_id}` - * @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 deleteBackup($name, array $optionalArgs = []) - { - $request = new DeleteBackupRequest(); - $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( - 'DeleteBackup', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes an instance. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedName = $cloudFilestoreManagerClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $operationResponse = $cloudFilestoreManagerClient->deleteInstance($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 = $cloudFilestoreManagerClient->deleteInstance($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'deleteInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $name Required. The instance resource name, in the format - * `projects/{project_id}/locations/{location}/instances/{instance_id}` - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * If set to true, all snapshots of the instance will also be deleted. - * (Otherwise, the request will only work if the instance has no snapshots.) - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deleteInstance($name, array $optionalArgs = []) - { - $request = new DeleteInstanceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a snapshot. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedName = $cloudFilestoreManagerClient->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - * $operationResponse = $cloudFilestoreManagerClient->deleteSnapshot($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 = $cloudFilestoreManagerClient->deleteSnapshot($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'deleteSnapshot'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $name Required. The snapshot resource name, in the format - * `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}` - * @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 deleteSnapshot($name, array $optionalArgs = []) - { - $request = new DeleteSnapshotRequest(); - $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( - 'DeleteSnapshot', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets the details of a specific backup. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedName = $cloudFilestoreManagerClient->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - * $response = $cloudFilestoreManagerClient->getBackup($formattedName); - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $name Required. The backup resource name, in the format - * `projects/{project_number}/locations/{location}/backups/{backup_id}`. - * @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\Filestore\V1\Backup - * - * @throws ApiException if the remote call fails - */ - public function getBackup($name, array $optionalArgs = []) - { - $request = new GetBackupRequest(); - $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( - 'GetBackup', - Backup::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets the details of a specific instance. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedName = $cloudFilestoreManagerClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $response = $cloudFilestoreManagerClient->getInstance($formattedName); - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $name Required. The instance resource name, in the format - * `projects/{project_id}/locations/{location}/instances/{instance_id}`. - * @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\Filestore\V1\Instance - * - * @throws ApiException if the remote call fails - */ - public function getInstance($name, array $optionalArgs = []) - { - $request = new GetInstanceRequest(); - $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( - 'GetInstance', - Instance::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets the details of a specific snapshot. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedName = $cloudFilestoreManagerClient->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - * $response = $cloudFilestoreManagerClient->getSnapshot($formattedName); - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $name Required. The snapshot resource name, in the format - * `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}` - * @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\Filestore\V1\Snapshot - * - * @throws ApiException if the remote call fails - */ - public function getSnapshot($name, array $optionalArgs = []) - { - $request = new GetSnapshotRequest(); - $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( - 'GetSnapshot', - Snapshot::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists all backups in a project for either a specified location or for all - * locations. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedParent = $cloudFilestoreManagerClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $cloudFilestoreManagerClient->listBackups($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $cloudFilestoreManagerClient->listBackups($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. The project and location for which to retrieve backup - * information, in the format - * `projects/{project_number}/locations/{location}`. In Filestore, backup - * locations map to Google Cloud regions, for example **us-west1**. To - * retrieve backup information for all locations, use "-" for the - * `{location}` value. - * @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 string $orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @type string $filter - * List filter. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listBackups($parent, array $optionalArgs = []) - { - $request = new ListBackupsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListBackups', - $optionalArgs, - ListBackupsResponse::class, - $request - ); - } - - /** - * Lists all instances in a project for either a specified location - * or for all locations. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedParent = $cloudFilestoreManagerClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $cloudFilestoreManagerClient->listInstances($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $cloudFilestoreManagerClient->listInstances($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. The project and location for which to retrieve instance - * information, in the format `projects/{project_id}/locations/{location}`. In - * Cloud Filestore, locations map to Google Cloud zones, for example - * **us-west1-b**. To retrieve instance information for all locations, use "-" - * for the - * `{location}` value. - * @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 string $orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @type string $filter - * List filter. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listInstances($parent, array $optionalArgs = []) - { - $request = new ListInstancesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListInstances', - $optionalArgs, - ListInstancesResponse::class, - $request - ); - } - - /** - * Lists all snapshots in a project for either a specified location - * or for all locations. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedParent = $cloudFilestoreManagerClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * // Iterate over pages of elements - * $pagedResponse = $cloudFilestoreManagerClient->listSnapshots($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $cloudFilestoreManagerClient->listSnapshots($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $parent Required. The instance for which to retrieve snapshot information, - * in the format - * `projects/{project_id}/locations/{location}/instances/{instance_id}`. - * @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 string $orderBy - * Sort results. Supported values are "name", "name desc" or "" (unsorted). - * @type string $filter - * List filter. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listSnapshots($parent, array $optionalArgs = []) - { - $request = new ListSnapshotsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListSnapshots', - $optionalArgs, - ListSnapshotsResponse::class, - $request - ); - } - - /** - * 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). - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedName = $cloudFilestoreManagerClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $fileShare = 'file_share'; - * $operationResponse = $cloudFilestoreManagerClient->restoreInstance($formattedName, $fileShare); - * $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 = $cloudFilestoreManagerClient->restoreInstance($formattedName, $fileShare); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'restoreInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the instance, in the format - * `projects/{project_number}/locations/{location_id}/instances/{instance_id}`. - * @param string $fileShare Required. Name of the file share in the Filestore instance that the backup - * is being restored to. - * @param array $optionalArgs { - * Optional. - * - * @type string $sourceBackup - * The resource name of the backup, in the format - * `projects/{project_number}/locations/{location_id}/backups/{backup_id}`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 restoreInstance($name, $fileShare, array $optionalArgs = []) - { - $request = new RestoreInstanceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setFileShare($fileShare); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['sourceBackup'])) { - $request->setSourceBackup($optionalArgs['sourceBackup']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'RestoreInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Revert an existing instance's file system to a specified snapshot. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $formattedName = $cloudFilestoreManagerClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $targetSnapshotId = 'target_snapshot_id'; - * $operationResponse = $cloudFilestoreManagerClient->revertInstance($formattedName, $targetSnapshotId); - * $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 = $cloudFilestoreManagerClient->revertInstance($formattedName, $targetSnapshotId); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'revertInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param string $name Required. - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}`. - * The resource name of the instance, in the format - * @param string $targetSnapshotId Required. The snapshot resource ID, in the format 'my-snapshot', where the - * specified ID is the {snapshot_id} of the fully qualified name like - * `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}` - * @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 revertInstance( - $name, - $targetSnapshotId, - array $optionalArgs = [] - ) { - $request = new RevertInstanceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTargetSnapshotId($targetSnapshotId); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'RevertInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Updates the settings of a specific backup. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $backup = new Backup(); - * $updateMask = new FieldMask(); - * $operationResponse = $cloudFilestoreManagerClient->updateBackup($backup, $updateMask); - * $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 = $cloudFilestoreManagerClient->updateBackup($backup, $updateMask); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'updateBackup'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param Backup $backup Required. A [backup resource][google.cloud.filestore.v1.Backup] - * @param FieldMask $updateMask Required. Mask of fields to update. At least one path must be supplied in - * this field. - * @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 updateBackup($backup, $updateMask, array $optionalArgs = []) - { - $request = new UpdateBackupRequest(); - $requestParamHeaders = []; - $request->setBackup($backup); - $request->setUpdateMask($updateMask); - $requestParamHeaders['backup.name'] = $backup->getName(); - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateBackup', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Updates the settings of a specific instance. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $operationResponse = $cloudFilestoreManagerClient->updateInstance(); - * $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 = $cloudFilestoreManagerClient->updateInstance(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'updateInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Mask of fields to update. At least one path must be supplied in this - * field. The elements of the repeated paths field may only include these - * fields: - * - * * "description" - * * "file_shares" - * * "labels" - * @type Instance $instance - * Only fields specified in update_mask are 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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function updateInstance(array $optionalArgs = []) - { - $request = new UpdateInstanceRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - if (isset($optionalArgs['instance'])) { - $request->setInstance($optionalArgs['instance']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Updates the settings of a specific snapshot. - * - * Sample code: - * ``` - * $cloudFilestoreManagerClient = new CloudFilestoreManagerClient(); - * try { - * $updateMask = new FieldMask(); - * $snapshot = new Snapshot(); - * $operationResponse = $cloudFilestoreManagerClient->updateSnapshot($updateMask, $snapshot); - * $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 = $cloudFilestoreManagerClient->updateSnapshot($updateMask, $snapshot); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'updateSnapshot'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudFilestoreManagerClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Mask of fields to update. At least one path must be supplied in - * this field. - * @param Snapshot $snapshot Required. A snapshot resource. - * @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 updateSnapshot( - $updateMask, - $snapshot, - array $optionalArgs = [] - ) { - $request = new UpdateSnapshotRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setSnapshot($snapshot); - $requestParamHeaders['snapshot.name'] = $snapshot->getName(); - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateSnapshot', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } -} diff --git a/Filestore/src/V1/GetBackupRequest.php b/Filestore/src/V1/GetBackupRequest.php index f6f8c212ce0d..89d8bdb44e69 100644 --- a/Filestore/src/V1/GetBackupRequest.php +++ b/Filestore/src/V1/GetBackupRequest.php @@ -21,7 +21,7 @@ class GetBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The backup resource name, in the format diff --git a/Filestore/src/V1/GetInstanceRequest.php b/Filestore/src/V1/GetInstanceRequest.php index a6e90741228a..a034a1692709 100644 --- a/Filestore/src/V1/GetInstanceRequest.php +++ b/Filestore/src/V1/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) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The instance resource name, in the format diff --git a/Filestore/src/V1/GetSnapshotRequest.php b/Filestore/src/V1/GetSnapshotRequest.php index 4aa010b3a245..a5831ec43669 100644 --- a/Filestore/src/V1/GetSnapshotRequest.php +++ b/Filestore/src/V1/GetSnapshotRequest.php @@ -21,7 +21,7 @@ class GetSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The snapshot resource name, in the format diff --git a/Filestore/src/V1/Instance.php b/Filestore/src/V1/Instance.php index 998371324946..0fce99d9b268 100644 --- a/Filestore/src/V1/Instance.php +++ b/Filestore/src/V1/Instance.php @@ -21,37 +21,37 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * The description of the instance (2048 characters or less). * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * Output only. The instance state. * * Generated from protobuf field .google.cloud.filestore.v1.Instance.State state = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. Additional information about the instance state, if available. * * Generated from protobuf field string status_message = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $status_message = ''; + protected $status_message = ''; /** * Output only. The time when the instance was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * The service tier of the instance. * * Generated from protobuf field .google.cloud.filestore.v1.Instance.Tier tier = 8; */ - private $tier = 0; + protected $tier = 0; /** * Resource labels to represent user provided metadata. * @@ -78,25 +78,25 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 12; */ - private $etag = ''; + protected $etag = ''; /** * Output only. Reserved for future use. * * Generated from protobuf field .google.protobuf.BoolValue satisfies_pzs = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $satisfies_pzs = null; + protected $satisfies_pzs = null; /** * Output only. Reserved for future use. * * Generated from protobuf field bool satisfies_pzi = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $satisfies_pzi = false; + protected $satisfies_pzi = false; /** * KMS key name used for data encryption. * * Generated from protobuf field string kms_key_name = 14; */ - private $kms_key_name = ''; + protected $kms_key_name = ''; /** * Output only. Field indicates all the reasons the instance is in "SUSPENDED" * state. @@ -458,7 +458,7 @@ public function clearSatisfiesPzs() * Generated from protobuf field .google.protobuf.BoolValue satisfies_pzs = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return bool|null */ - public function getSatisfiesPzsValue() + public function getSatisfiesPzsUnwrapped() { return $this->readWrapperValue("satisfies_pzs"); } @@ -487,7 +487,7 @@ public function setSatisfiesPzs($var) * @param bool|null $var * @return $this */ - public function setSatisfiesPzsValue($var) + public function setSatisfiesPzsUnwrapped($var) { $this->writeWrapperValue("satisfies_pzs", $var); return $this;} diff --git a/Filestore/src/V1/ListBackupsRequest.php b/Filestore/src/V1/ListBackupsRequest.php index ba471535458c..2e8d840adf8e 100644 --- a/Filestore/src/V1/ListBackupsRequest.php +++ b/Filestore/src/V1/ListBackupsRequest.php @@ -25,32 +25,32 @@ class ListBackupsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value to use if there are additional * results to retrieve for this list request. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * Sort results. Supported values are "name", "name desc" or "" (unsorted). * * Generated from protobuf field string order_by = 4; */ - private $order_by = ''; + protected $order_by = ''; /** * List filter. * * Generated from protobuf field string filter = 5; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The project and location for which to retrieve backup diff --git a/Filestore/src/V1/ListBackupsResponse.php b/Filestore/src/V1/ListBackupsResponse.php index 07ece0ee6f9e..166221aae3bc 100644 --- a/Filestore/src/V1/ListBackupsResponse.php +++ b/Filestore/src/V1/ListBackupsResponse.php @@ -32,7 +32,7 @@ class ListBackupsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/Filestore/src/V1/ListInstancesRequest.php b/Filestore/src/V1/ListInstancesRequest.php index a86740fe3536..07408da70f18 100644 --- a/Filestore/src/V1/ListInstancesRequest.php +++ b/Filestore/src/V1/ListInstancesRequest.php @@ -25,32 +25,32 @@ class ListInstancesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value to use if there are additional * results to retrieve for this list request. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * Sort results. Supported values are "name", "name desc" or "" (unsorted). * * Generated from protobuf field string order_by = 4; */ - private $order_by = ''; + protected $order_by = ''; /** * List filter. * * Generated from protobuf field string filter = 5; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The project and location for which to retrieve instance diff --git a/Filestore/src/V1/ListInstancesResponse.php b/Filestore/src/V1/ListInstancesResponse.php index c2b5e0defcfe..96c73342d44c 100644 --- a/Filestore/src/V1/ListInstancesResponse.php +++ b/Filestore/src/V1/ListInstancesResponse.php @@ -31,7 +31,7 @@ class ListInstancesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/Filestore/src/V1/ListSnapshotsRequest.php b/Filestore/src/V1/ListSnapshotsRequest.php index ee06f5f03909..eaa004774f70 100644 --- a/Filestore/src/V1/ListSnapshotsRequest.php +++ b/Filestore/src/V1/ListSnapshotsRequest.php @@ -22,32 +22,32 @@ class ListSnapshotsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of items to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value to use if there are additional * results to retrieve for this list request. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * Sort results. Supported values are "name", "name desc" or "" (unsorted). * * Generated from protobuf field string order_by = 4; */ - private $order_by = ''; + protected $order_by = ''; /** * List filter. * * Generated from protobuf field string filter = 5; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The instance for which to retrieve snapshot information, diff --git a/Filestore/src/V1/ListSnapshotsResponse.php b/Filestore/src/V1/ListSnapshotsResponse.php index a3176b37ca06..172b7189d452 100644 --- a/Filestore/src/V1/ListSnapshotsResponse.php +++ b/Filestore/src/V1/ListSnapshotsResponse.php @@ -27,7 +27,7 @@ class ListSnapshotsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Filestore/src/V1/NetworkConfig.php b/Filestore/src/V1/NetworkConfig.php index 469f2f31903a..201ade29815d 100644 --- a/Filestore/src/V1/NetworkConfig.php +++ b/Filestore/src/V1/NetworkConfig.php @@ -22,7 +22,7 @@ class NetworkConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network = 1; */ - private $network = ''; + protected $network = ''; /** * Internet protocol versions for which the instance has IP addresses * assigned. For this version, only MODE_IPV4 is supported. @@ -51,7 +51,7 @@ class NetworkConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string reserved_ip_range = 4; */ - private $reserved_ip_range = ''; + protected $reserved_ip_range = ''; /** * Output only. IPv4 addresses in the format * `{octet1}.{octet2}.{octet3}.{octet4}` or IPv6 addresses in the format @@ -66,7 +66,7 @@ class NetworkConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.filestore.v1.NetworkConfig.ConnectMode connect_mode = 6; */ - private $connect_mode = 0; + protected $connect_mode = 0; /** * Constructor. diff --git a/Filestore/src/V1/NfsExportOptions.php b/Filestore/src/V1/NfsExportOptions.php index 81afb08da0db..9e58d779e63d 100644 --- a/Filestore/src/V1/NfsExportOptions.php +++ b/Filestore/src/V1/NfsExportOptions.php @@ -35,7 +35,7 @@ class NfsExportOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.filestore.v1.NfsExportOptions.AccessMode access_mode = 2; */ - private $access_mode = 0; + protected $access_mode = 0; /** * Either NO_ROOT_SQUASH, for allowing root access on the exported directory, * or ROOT_SQUASH, for not allowing root access. The default is @@ -43,7 +43,7 @@ class NfsExportOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.filestore.v1.NfsExportOptions.SquashMode squash_mode = 3; */ - private $squash_mode = 0; + protected $squash_mode = 0; /** * An integer representing the anonymous user id with a default value of * 65534. @@ -52,7 +52,7 @@ class NfsExportOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 anon_uid = 4; */ - private $anon_uid = 0; + protected $anon_uid = 0; /** * An integer representing the anonymous group id with a default value of * 65534. @@ -61,7 +61,7 @@ class NfsExportOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 anon_gid = 5; */ - private $anon_gid = 0; + protected $anon_gid = 0; /** * Constructor. diff --git a/Filestore/src/V1/RestoreInstanceRequest.php b/Filestore/src/V1/RestoreInstanceRequest.php index eb8ee455f3e0..85a76b2484c5 100644 --- a/Filestore/src/V1/RestoreInstanceRequest.php +++ b/Filestore/src/V1/RestoreInstanceRequest.php @@ -22,14 +22,14 @@ class RestoreInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. Name of the file share in the Filestore instance that the backup * is being restored to. * * Generated from protobuf field string file_share = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $file_share = ''; + protected $file_share = ''; protected $source; /** diff --git a/Filestore/src/V1/RevertInstanceRequest.php b/Filestore/src/V1/RevertInstanceRequest.php index f2b8d12a12e6..581d86803255 100644 --- a/Filestore/src/V1/RevertInstanceRequest.php +++ b/Filestore/src/V1/RevertInstanceRequest.php @@ -23,7 +23,7 @@ class RevertInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The snapshot resource ID, in the format 'my-snapshot', where the * specified ID is the {snapshot_id} of the fully qualified name like @@ -31,7 +31,7 @@ class RevertInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string target_snapshot_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $target_snapshot_id = ''; + protected $target_snapshot_id = ''; /** * Constructor. diff --git a/Filestore/src/V1/Snapshot.php b/Filestore/src/V1/Snapshot.php index 0471bb364397..aba33831cf48 100644 --- a/Filestore/src/V1/Snapshot.php +++ b/Filestore/src/V1/Snapshot.php @@ -21,26 +21,26 @@ class Snapshot extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * A description of the snapshot with 2048 characters or less. * Requests with longer descriptions will be rejected. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * Output only. The snapshot state. * * Generated from protobuf field .google.cloud.filestore.v1.Snapshot.State state = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The time when the snapshot was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Resource labels to represent user provided metadata. * @@ -53,7 +53,7 @@ class Snapshot extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 filesystem_used_bytes = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $filesystem_used_bytes = 0; + protected $filesystem_used_bytes = 0; /** * Constructor. diff --git a/Filestore/src/V1/UpdateBackupRequest.php b/Filestore/src/V1/UpdateBackupRequest.php index 3ed2a2891750..1af115b57bb8 100644 --- a/Filestore/src/V1/UpdateBackupRequest.php +++ b/Filestore/src/V1/UpdateBackupRequest.php @@ -20,14 +20,14 @@ class UpdateBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.filestore.v1.Backup backup = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $backup = null; + protected $backup = null; /** * Required. Mask of fields to update. At least one path must be supplied in * this field. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\Filestore\V1\Backup $backup Required. A [backup resource][google.cloud.filestore.v1.Backup] diff --git a/Filestore/src/V1/UpdateInstanceRequest.php b/Filestore/src/V1/UpdateInstanceRequest.php index db7c4651b10b..5a1930af15f1 100644 --- a/Filestore/src/V1/UpdateInstanceRequest.php +++ b/Filestore/src/V1/UpdateInstanceRequest.php @@ -25,13 +25,13 @@ class UpdateInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1; */ - private $update_mask = null; + protected $update_mask = null; /** * Only fields specified in update_mask are updated. * * Generated from protobuf field .google.cloud.filestore.v1.Instance instance = 2; */ - private $instance = null; + protected $instance = null; /** * @param \Google\Cloud\Filestore\V1\Instance $instance Only fields specified in update_mask are updated. diff --git a/Filestore/src/V1/UpdateSnapshotRequest.php b/Filestore/src/V1/UpdateSnapshotRequest.php index b87e78b7bf76..a2afac066a32 100644 --- a/Filestore/src/V1/UpdateSnapshotRequest.php +++ b/Filestore/src/V1/UpdateSnapshotRequest.php @@ -21,13 +21,13 @@ class UpdateSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. A snapshot resource. * * Generated from protobuf field .google.cloud.filestore.v1.Snapshot snapshot = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $snapshot = null; + protected $snapshot = null; /** * @param \Google\Cloud\Filestore\V1\Snapshot $snapshot Required. A snapshot resource. diff --git a/Filestore/tests/Unit/V1/Client/CloudFilestoreManagerClientTest.php b/Filestore/tests/Unit/V1/Client/CloudFilestoreManagerClientTest.php index 09fba3b7bcd4..a9555277bde4 100644 --- a/Filestore/tests/Unit/V1/Client/CloudFilestoreManagerClientTest.php +++ b/Filestore/tests/Unit/V1/Client/CloudFilestoreManagerClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return CloudFilestoreManagerClient */ @@ -201,12 +203,15 @@ public function createBackupExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -346,12 +351,15 @@ public function createInstanceExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -485,12 +493,15 @@ public function createSnapshotExceptionTest() $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); + $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); @@ -553,8 +564,7 @@ public function deleteBackupTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - $request = (new DeleteBackupRequest()) - ->setName($formattedName); + $request = (new DeleteBackupRequest())->setName($formattedName); $response = $gapicClient->deleteBackup($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -610,17 +620,19 @@ public function deleteBackupExceptionTest() $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); + $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->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - $request = (new DeleteBackupRequest()) - ->setName($formattedName); + $request = (new DeleteBackupRequest())->setName($formattedName); $response = $gapicClient->deleteBackup($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -674,8 +686,7 @@ public function deleteInstanceTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new DeleteInstanceRequest()) - ->setName($formattedName); + $request = (new DeleteInstanceRequest())->setName($formattedName); $response = $gapicClient->deleteInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -731,17 +742,19 @@ public function deleteInstanceExceptionTest() $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); + $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new DeleteInstanceRequest()) - ->setName($formattedName); + $request = (new DeleteInstanceRequest())->setName($formattedName); $response = $gapicClient->deleteInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -795,8 +808,7 @@ public function deleteSnapshotTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - $request = (new DeleteSnapshotRequest()) - ->setName($formattedName); + $request = (new DeleteSnapshotRequest())->setName($formattedName); $response = $gapicClient->deleteSnapshot($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -852,17 +864,19 @@ public function deleteSnapshotExceptionTest() $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); + $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->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - $request = (new DeleteSnapshotRequest()) - ->setName($formattedName); + $request = (new DeleteSnapshotRequest())->setName($formattedName); $response = $gapicClient->deleteSnapshot($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -916,8 +930,7 @@ public function getBackupTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - $request = (new GetBackupRequest()) - ->setName($formattedName); + $request = (new GetBackupRequest())->setName($formattedName); $response = $gapicClient->getBackup($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -941,17 +954,19 @@ public function getBackupExceptionTest() $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); + $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->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - $request = (new GetBackupRequest()) - ->setName($formattedName); + $request = (new GetBackupRequest())->setName($formattedName); try { $gapicClient->getBackup($request); // If the $gapicClient method call did not throw, fail the test @@ -990,8 +1005,7 @@ public function getInstanceTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new GetInstanceRequest()) - ->setName($formattedName); + $request = (new GetInstanceRequest())->setName($formattedName); $response = $gapicClient->getInstance($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1015,17 +1029,19 @@ public function getInstanceExceptionTest() $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); + $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new GetInstanceRequest()) - ->setName($formattedName); + $request = (new GetInstanceRequest())->setName($formattedName); try { $gapicClient->getInstance($request); // If the $gapicClient method call did not throw, fail the test @@ -1058,8 +1074,7 @@ public function getSnapshotTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - $request = (new GetSnapshotRequest()) - ->setName($formattedName); + $request = (new GetSnapshotRequest())->setName($formattedName); $response = $gapicClient->getSnapshot($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1083,17 +1098,19 @@ public function getSnapshotExceptionTest() $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); + $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->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - $request = (new GetSnapshotRequest()) - ->setName($formattedName); + $request = (new GetSnapshotRequest())->setName($formattedName); try { $gapicClient->getSnapshot($request); // If the $gapicClient method call did not throw, fail the test @@ -1118,17 +1135,14 @@ public function listBackupsTest() // Mock response $nextPageToken = ''; $backupsElement = new Backup(); - $backups = [ - $backupsElement, - ]; + $backups = [$backupsElement]; $expectedResponse = new ListBackupsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setBackups($backups); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListBackupsRequest()) - ->setParent($formattedParent); + $request = (new ListBackupsRequest())->setParent($formattedParent); $response = $gapicClient->listBackups($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1155,17 +1169,19 @@ public function listBackupsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListBackupsRequest()) - ->setParent($formattedParent); + $request = (new ListBackupsRequest())->setParent($formattedParent); try { $gapicClient->listBackups($request); // If the $gapicClient method call did not throw, fail the test @@ -1190,17 +1206,14 @@ public function listInstancesTest() // Mock response $nextPageToken = ''; $instancesElement = new Instance(); - $instances = [ - $instancesElement, - ]; + $instances = [$instancesElement]; $expectedResponse = new ListInstancesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setInstances($instances); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListInstancesRequest()) - ->setParent($formattedParent); + $request = (new ListInstancesRequest())->setParent($formattedParent); $response = $gapicClient->listInstances($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1227,17 +1240,19 @@ public function listInstancesExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListInstancesRequest()) - ->setParent($formattedParent); + $request = (new ListInstancesRequest())->setParent($formattedParent); try { $gapicClient->listInstances($request); // If the $gapicClient method call did not throw, fail the test @@ -1262,17 +1277,14 @@ public function listSnapshotsTest() // Mock response $nextPageToken = ''; $snapshotsElement = new Snapshot(); - $snapshots = [ - $snapshotsElement, - ]; + $snapshots = [$snapshotsElement]; $expectedResponse = new ListSnapshotsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSnapshots($snapshots); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new ListSnapshotsRequest()) - ->setParent($formattedParent); + $request = (new ListSnapshotsRequest())->setParent($formattedParent); $response = $gapicClient->listSnapshots($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1299,17 +1311,19 @@ public function listSnapshotsExceptionTest() $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); + $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new ListSnapshotsRequest()) - ->setParent($formattedParent); + $request = (new ListSnapshotsRequest())->setParent($formattedParent); try { $gapicClient->listSnapshots($request); // If the $gapicClient method call did not throw, fail the test @@ -1367,9 +1381,7 @@ public function restoreInstanceTest() // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); $fileShare = 'fileShare2143984476'; - $request = (new RestoreInstanceRequest()) - ->setName($formattedName) - ->setFileShare($fileShare); + $request = (new RestoreInstanceRequest())->setName($formattedName)->setFileShare($fileShare); $response = $gapicClient->restoreInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1427,19 +1439,20 @@ public function restoreInstanceExceptionTest() $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); + $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); $fileShare = 'fileShare2143984476'; - $request = (new RestoreInstanceRequest()) - ->setName($formattedName) - ->setFileShare($fileShare); + $request = (new RestoreInstanceRequest())->setName($formattedName)->setFileShare($fileShare); $response = $gapicClient->restoreInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1506,9 +1519,7 @@ public function revertInstanceTest() // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); $targetSnapshotId = 'targetSnapshotId1030984648'; - $request = (new RevertInstanceRequest()) - ->setName($formattedName) - ->setTargetSnapshotId($targetSnapshotId); + $request = (new RevertInstanceRequest())->setName($formattedName)->setTargetSnapshotId($targetSnapshotId); $response = $gapicClient->revertInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1566,19 +1577,20 @@ public function revertInstanceExceptionTest() $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); + $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); $targetSnapshotId = 'targetSnapshotId1030984648'; - $request = (new RevertInstanceRequest()) - ->setName($formattedName) - ->setTargetSnapshotId($targetSnapshotId); + $request = (new RevertInstanceRequest())->setName($formattedName)->setTargetSnapshotId($targetSnapshotId); $response = $gapicClient->revertInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1651,9 +1663,7 @@ public function updateBackupTest() // Mock request $backup = new Backup(); $updateMask = new FieldMask(); - $request = (new UpdateBackupRequest()) - ->setBackup($backup) - ->setUpdateMask($updateMask); + $request = (new UpdateBackupRequest())->setBackup($backup)->setUpdateMask($updateMask); $response = $gapicClient->updateBackup($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1711,19 +1721,20 @@ public function updateBackupExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $backup = new Backup(); $updateMask = new FieldMask(); - $request = (new UpdateBackupRequest()) - ->setBackup($backup) - ->setUpdateMask($updateMask); + $request = (new UpdateBackupRequest())->setBackup($backup)->setUpdateMask($updateMask); $response = $gapicClient->updateBackup($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1841,12 +1852,15 @@ public function updateInstanceExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new UpdateInstanceRequest(); $response = $gapicClient->updateInstance($request); @@ -1909,9 +1923,7 @@ public function updateSnapshotTest() // Mock request $updateMask = new FieldMask(); $snapshot = new Snapshot(); - $request = (new UpdateSnapshotRequest()) - ->setUpdateMask($updateMask) - ->setSnapshot($snapshot); + $request = (new UpdateSnapshotRequest())->setUpdateMask($updateMask)->setSnapshot($snapshot); $response = $gapicClient->updateSnapshot($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1969,19 +1981,20 @@ public function updateSnapshotExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $updateMask = new FieldMask(); $snapshot = new Snapshot(); - $request = (new UpdateSnapshotRequest()) - ->setUpdateMask($updateMask) - ->setSnapshot($snapshot); + $request = (new UpdateSnapshotRequest())->setUpdateMask($updateMask)->setSnapshot($snapshot); $response = $gapicClient->updateSnapshot($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); diff --git a/Filestore/tests/Unit/V1/CloudFilestoreManagerClientTest.php b/Filestore/tests/Unit/V1/CloudFilestoreManagerClientTest.php deleted file mode 100644 index bb206707edc6..000000000000 --- a/Filestore/tests/Unit/V1/CloudFilestoreManagerClientTest.php +++ /dev/null @@ -1,1903 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return CloudFilestoreManagerClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new CloudFilestoreManagerClient($options); - } - - /** @test */ - public function createBackupTest() - { - $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/createBackupTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $capacityGb = 1923585408; - $storageBytes = 2035244455; - $sourceInstance = 'sourceInstance-677426119'; - $sourceFileShare = 'sourceFileShare-1224476160'; - $downloadBytes = 971924980; - $satisfiesPzi = false; - $kmsKey = 'kmsKey-591635343'; - $expectedResponse = new Backup(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setCapacityGb($capacityGb); - $expectedResponse->setStorageBytes($storageBytes); - $expectedResponse->setSourceInstance($sourceInstance); - $expectedResponse->setSourceFileShare($sourceFileShare); - $expectedResponse->setDownloadBytes($downloadBytes); - $expectedResponse->setSatisfiesPzi($satisfiesPzi); - $expectedResponse->setKmsKey($kmsKey); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createBackupTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $backup = new Backup(); - $backupId = 'backupId1355353272'; - $response = $gapicClient->createBackup($formattedParent, $backup, $backupId); - $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.filestore.v1.CloudFilestoreManager/CreateBackup', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getBackup(); - $this->assertProtobufEquals($backup, $actualValue); - $actualValue = $actualApiRequestObject->getBackupId(); - $this->assertProtobufEquals($backupId, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createBackupTest'); - $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 createBackupExceptionTest() - { - $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/createBackupTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $backup = new Backup(); - $backupId = 'backupId1355353272'; - $response = $gapicClient->createBackup($formattedParent, $backup, $backupId); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createBackupTest'); - 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 createInstanceTest() - { - $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/createInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $statusMessage = 'statusMessage-239442758'; - $etag = 'etag3123477'; - $satisfiesPzi = false; - $kmsKeyName = 'kmsKeyName2094986649'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setStatusMessage($statusMessage); - $expectedResponse->setEtag($etag); - $expectedResponse->setSatisfiesPzi($satisfiesPzi); - $expectedResponse->setKmsKeyName($kmsKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $instanceId = 'instanceId-2101995259'; - $instance = new Instance(); - $response = $gapicClient->createInstance($formattedParent, $instanceId, $instance); - $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.filestore.v1.CloudFilestoreManager/CreateInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getInstanceId(); - $this->assertProtobufEquals($instanceId, $actualValue); - $actualValue = $actualApiRequestObject->getInstance(); - $this->assertProtobufEquals($instance, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createInstanceTest'); - $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 createInstanceExceptionTest() - { - $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/createInstanceTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $instanceId = 'instanceId-2101995259'; - $instance = new Instance(); - $response = $gapicClient->createInstance($formattedParent, $instanceId, $instance); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createInstanceTest'); - 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 createSnapshotTest() - { - $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/createSnapshotTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $filesystemUsedBytes = 387235709; - $expectedResponse = new Snapshot(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setFilesystemUsedBytes($filesystemUsedBytes); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createSnapshotTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $snapshotId = 'snapshotId-168585866'; - $snapshot = new Snapshot(); - $response = $gapicClient->createSnapshot($formattedParent, $snapshotId, $snapshot); - $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.filestore.v1.CloudFilestoreManager/CreateSnapshot', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getSnapshotId(); - $this->assertProtobufEquals($snapshotId, $actualValue); - $actualValue = $actualApiRequestObject->getSnapshot(); - $this->assertProtobufEquals($snapshot, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createSnapshotTest'); - $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 createSnapshotExceptionTest() - { - $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/createSnapshotTest'); - $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $snapshotId = 'snapshotId-168585866'; - $snapshot = new Snapshot(); - $response = $gapicClient->createSnapshot($formattedParent, $snapshotId, $snapshot); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createSnapshotTest'); - 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 deleteBackupTest() - { - $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/deleteBackupTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteBackupTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - $response = $gapicClient->deleteBackup($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.filestore.v1.CloudFilestoreManager/DeleteBackup', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteBackupTest'); - $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 deleteBackupExceptionTest() - { - $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/deleteBackupTest'); - $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->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - $response = $gapicClient->deleteBackup($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteBackupTest'); - 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 deleteInstanceTest() - { - $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/deleteInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->deleteInstance($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.filestore.v1.CloudFilestoreManager/DeleteInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteInstanceTest'); - $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 deleteInstanceExceptionTest() - { - $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/deleteInstanceTest'); - $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->deleteInstance($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteInstanceTest'); - 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 deleteSnapshotTest() - { - $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/deleteSnapshotTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteSnapshotTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - $response = $gapicClient->deleteSnapshot($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.filestore.v1.CloudFilestoreManager/DeleteSnapshot', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteSnapshotTest'); - $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 deleteSnapshotExceptionTest() - { - $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/deleteSnapshotTest'); - $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->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - $response = $gapicClient->deleteSnapshot($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteSnapshotTest'); - 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 getBackupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $capacityGb = 1923585408; - $storageBytes = 2035244455; - $sourceInstance = 'sourceInstance-677426119'; - $sourceFileShare = 'sourceFileShare-1224476160'; - $downloadBytes = 971924980; - $satisfiesPzi = false; - $kmsKey = 'kmsKey-591635343'; - $expectedResponse = new Backup(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setCapacityGb($capacityGb); - $expectedResponse->setStorageBytes($storageBytes); - $expectedResponse->setSourceInstance($sourceInstance); - $expectedResponse->setSourceFileShare($sourceFileShare); - $expectedResponse->setDownloadBytes($downloadBytes); - $expectedResponse->setSatisfiesPzi($satisfiesPzi); - $expectedResponse->setKmsKey($kmsKey); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - $response = $gapicClient->getBackup($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.filestore.v1.CloudFilestoreManager/GetBackup', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getBackupExceptionTest() - { - $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->backupName('[PROJECT]', '[LOCATION]', '[BACKUP]'); - try { - $gapicClient->getBackup($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 getInstanceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $statusMessage = 'statusMessage-239442758'; - $etag = 'etag3123477'; - $satisfiesPzi = false; - $kmsKeyName = 'kmsKeyName2094986649'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setStatusMessage($statusMessage); - $expectedResponse->setEtag($etag); - $expectedResponse->setSatisfiesPzi($satisfiesPzi); - $expectedResponse->setKmsKeyName($kmsKeyName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->getInstance($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.filestore.v1.CloudFilestoreManager/GetInstance', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getInstanceExceptionTest() - { - $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - try { - $gapicClient->getInstance($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 getSnapshotTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $filesystemUsedBytes = 387235709; - $expectedResponse = new Snapshot(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setFilesystemUsedBytes($filesystemUsedBytes); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - $response = $gapicClient->getSnapshot($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.filestore.v1.CloudFilestoreManager/GetSnapshot', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getSnapshotExceptionTest() - { - $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->snapshotName('[PROJECT]', '[LOCATION]', '[INSTANCE]', '[SNAPSHOT]'); - try { - $gapicClient->getSnapshot($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 listBackupsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $backupsElement = new Backup(); - $backups = [ - $backupsElement, - ]; - $expectedResponse = new ListBackupsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setBackups($backups); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listBackups($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getBackups()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.filestore.v1.CloudFilestoreManager/ListBackups', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listBackupsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listBackups($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 listInstancesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $instancesElement = new Instance(); - $instances = [ - $instancesElement, - ]; - $expectedResponse = new ListInstancesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setInstances($instances); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listInstances($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getInstances()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.filestore.v1.CloudFilestoreManager/ListInstances', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listInstancesExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listInstances($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 listSnapshotsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $snapshotsElement = new Snapshot(); - $snapshots = [ - $snapshotsElement, - ]; - $expectedResponse = new ListSnapshotsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSnapshots($snapshots); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->listSnapshots($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSnapshots()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.filestore.v1.CloudFilestoreManager/ListSnapshots', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listSnapshotsExceptionTest() - { - $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - try { - $gapicClient->listSnapshots($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 restoreInstanceTest() - { - $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/restoreInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $statusMessage = 'statusMessage-239442758'; - $etag = 'etag3123477'; - $satisfiesPzi = false; - $kmsKeyName = 'kmsKeyName2094986649'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setStatusMessage($statusMessage); - $expectedResponse->setEtag($etag); - $expectedResponse->setSatisfiesPzi($satisfiesPzi); - $expectedResponse->setKmsKeyName($kmsKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/restoreInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $fileShare = 'fileShare2143984476'; - $response = $gapicClient->restoreInstance($formattedName, $fileShare); - $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.filestore.v1.CloudFilestoreManager/RestoreInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getFileShare(); - $this->assertProtobufEquals($fileShare, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/restoreInstanceTest'); - $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 restoreInstanceExceptionTest() - { - $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/restoreInstanceTest'); - $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $fileShare = 'fileShare2143984476'; - $response = $gapicClient->restoreInstance($formattedName, $fileShare); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/restoreInstanceTest'); - 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 revertInstanceTest() - { - $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/revertInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $statusMessage = 'statusMessage-239442758'; - $etag = 'etag3123477'; - $satisfiesPzi = false; - $kmsKeyName = 'kmsKeyName2094986649'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setStatusMessage($statusMessage); - $expectedResponse->setEtag($etag); - $expectedResponse->setSatisfiesPzi($satisfiesPzi); - $expectedResponse->setKmsKeyName($kmsKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/revertInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $targetSnapshotId = 'targetSnapshotId1030984648'; - $response = $gapicClient->revertInstance($formattedName, $targetSnapshotId); - $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.filestore.v1.CloudFilestoreManager/RevertInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTargetSnapshotId(); - $this->assertProtobufEquals($targetSnapshotId, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/revertInstanceTest'); - $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 revertInstanceExceptionTest() - { - $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/revertInstanceTest'); - $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->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $targetSnapshotId = 'targetSnapshotId1030984648'; - $response = $gapicClient->revertInstance($formattedName, $targetSnapshotId); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/revertInstanceTest'); - 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 updateBackupTest() - { - $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/updateBackupTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $capacityGb = 1923585408; - $storageBytes = 2035244455; - $sourceInstance = 'sourceInstance-677426119'; - $sourceFileShare = 'sourceFileShare-1224476160'; - $downloadBytes = 971924980; - $satisfiesPzi = false; - $kmsKey = 'kmsKey-591635343'; - $expectedResponse = new Backup(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setCapacityGb($capacityGb); - $expectedResponse->setStorageBytes($storageBytes); - $expectedResponse->setSourceInstance($sourceInstance); - $expectedResponse->setSourceFileShare($sourceFileShare); - $expectedResponse->setDownloadBytes($downloadBytes); - $expectedResponse->setSatisfiesPzi($satisfiesPzi); - $expectedResponse->setKmsKey($kmsKey); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateBackupTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $backup = new Backup(); - $updateMask = new FieldMask(); - $response = $gapicClient->updateBackup($backup, $updateMask); - $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.filestore.v1.CloudFilestoreManager/UpdateBackup', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getBackup(); - $this->assertProtobufEquals($backup, $actualValue); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateBackupTest'); - $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 updateBackupExceptionTest() - { - $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/updateBackupTest'); - $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 - $backup = new Backup(); - $updateMask = new FieldMask(); - $response = $gapicClient->updateBackup($backup, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateBackupTest'); - 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 updateInstanceTest() - { - $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/updateInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $statusMessage = 'statusMessage-239442758'; - $etag = 'etag3123477'; - $satisfiesPzi = false; - $kmsKeyName = 'kmsKeyName2094986649'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setStatusMessage($statusMessage); - $expectedResponse->setEtag($etag); - $expectedResponse->setSatisfiesPzi($satisfiesPzi); - $expectedResponse->setKmsKeyName($kmsKeyName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->updateInstance(); - $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.filestore.v1.CloudFilestoreManager/UpdateInstance', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateInstanceTest'); - $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 updateInstanceExceptionTest() - { - $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/updateInstanceTest'); - $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); - $response = $gapicClient->updateInstance(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateInstanceTest'); - 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 updateSnapshotTest() - { - $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/updateSnapshotTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $filesystemUsedBytes = 387235709; - $expectedResponse = new Snapshot(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setFilesystemUsedBytes($filesystemUsedBytes); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateSnapshotTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $snapshot = new Snapshot(); - $response = $gapicClient->updateSnapshot($updateMask, $snapshot); - $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.filestore.v1.CloudFilestoreManager/UpdateSnapshot', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getSnapshot(); - $this->assertProtobufEquals($snapshot, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateSnapshotTest'); - $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 updateSnapshotExceptionTest() - { - $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/updateSnapshotTest'); - $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 - $updateMask = new FieldMask(); - $snapshot = new Snapshot(); - $response = $gapicClient->updateSnapshot($updateMask, $snapshot); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateSnapshotTest'); - 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()); - } -} diff --git a/ManagedIdentities/.OwlBot.yaml b/ManagedIdentities/.OwlBot.yaml index 91e6bace48f0..a3085ad06557 100644 --- a/ManagedIdentities/.OwlBot.yaml +++ b/ManagedIdentities/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/managedidentities/(.*)/.*-php/(.*) + - source: /google/cloud/managedidentities/(v1)/.*-php/(.*) dest: /owl-bot-staging/ManagedIdentities/$1/$2 api-name: ManagedIdentities diff --git a/ManagedIdentities/metadata/V1Beta1/ManagedIdentitiesService.php b/ManagedIdentities/metadata/V1Beta1/ManagedIdentitiesService.php deleted file mode 100644 index 75366bdec34c..000000000000 --- a/ManagedIdentities/metadata/V1Beta1/ManagedIdentitiesService.php +++ /dev/null @@ -1,117 +0,0 @@ -internalAddGeneratedFile( - ' -…& -Ggoogle/cloud/managedidentities/v1beta1/managed_identities_service.proto&google.cloud.managedidentities.v1beta1google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto5google/cloud/managedidentities/v1beta1/resource.proto#google/longrunning/operations.proto google/protobuf/field_mask.protogoogle/protobuf/timestamp.proto"Ü - -OpMetadata4 - create_time ( 2.google.protobuf.TimestampBàA1 -end_time ( 2.google.protobuf.TimestampBàA -target ( BàA -verb ( BàA# -requested_cancellation (BàA - api_version ( BàA"À -CreateMicrosoftAdDomainRequest? -parent ( B/àAúA)\'managedidentities.googleapis.com/Domain - domain_name ( BàAC -domain ( 2..google.cloud.managedidentities.v1beta1.DomainBàA"Z -ResetAdminPasswordRequest= -name ( B/àAúA) -\'managedidentities.googleapis.com/Domain". -ResetAdminPasswordResponse -password ( "ž -ListDomainsRequest? -parent ( B/àAúA)\'managedidentities.googleapis.com/Domain - page_size ( - -page_token (  -filter (  -order_by ( "„ -ListDomainsResponse? -domains ( 2..google.cloud.managedidentities.v1beta1.Domain -next_page_token (  - unreachable ( "Q -GetDomainRequest= -name ( B/àAúA) -\'managedidentities.googleapis.com/Domain" -UpdateDomainRequest4 - update_mask ( 2.google.protobuf.FieldMaskBàAC -domain ( 2..google.cloud.managedidentities.v1beta1.DomainBàA"T -DeleteDomainRequest= -name ( B/àAúA) -\'managedidentities.googleapis.com/Domain"– -AttachTrustRequest= -name ( B/àAúA) -\'managedidentities.googleapis.com/DomainA -trust ( 2-.google.cloud.managedidentities.v1beta1.TrustBàA"Ÿ -ReconfigureTrustRequest= -name ( B/àAúA) -\'managedidentities.googleapis.com/Domain -target_domain_name ( BàA$ -target_dns_ip_addresses ( BàA"– -DetachTrustRequest= -name ( B/àAúA) -\'managedidentities.googleapis.com/DomainA -trust ( 2-.google.cloud.managedidentities.v1beta1.TrustBàA"˜ -ValidateTrustRequest= -name ( B/àAúA) -\'managedidentities.googleapis.com/DomainA -trust ( 2-.google.cloud.managedidentities.v1beta1.TrustBàA2å -ManagedIdentitiesServiceú -CreateMicrosoftAdDomainF.google.cloud.managedidentities.v1beta1.CreateMicrosoftAdDomainRequest.google.longrunning.Operation"xÊA -Domain -OpMetadataÚAparent,domain_name,domain‚Óä“?"5/v1beta1/{parent=projects/*/locations/global}/domains:domain÷ -ResetAdminPasswordA.google.cloud.managedidentities.v1beta1.ResetAdminPasswordRequestB.google.cloud.managedidentities.v1beta1.ResetAdminPasswordResponse"ZÚAname‚Óä“M"H/v1beta1/{name=projects/*/locations/global/domains/*}:resetAdminPassword:*Î - ListDomains:.google.cloud.managedidentities.v1beta1.ListDomainsRequest;.google.cloud.managedidentities.v1beta1.ListDomainsResponse"FÚAparent‚Óä“75/v1beta1/{parent=projects/*/locations/global}/domains» - GetDomain8.google.cloud.managedidentities.v1beta1.GetDomainRequest..google.cloud.managedidentities.v1beta1.Domain"DÚAname‚Óä“75/v1beta1/{name=projects/*/locations/global/domains/*}ä - UpdateDomain;.google.cloud.managedidentities.v1beta1.UpdateDomainRequest.google.longrunning.Operation"xÊA -Domain -OpMetadataÚAdomain,update_mask‚Óä“F2string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The domain trust resource. * * Generated from protobuf field .google.cloud.managedidentities.v1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $trust = null; + protected $trust = null; /** * @param string $name Required. The resource domain name, project name and location using the form: diff --git a/ManagedIdentities/src/V1/Client/ManagedIdentitiesServiceClient.php b/ManagedIdentities/src/V1/Client/ManagedIdentitiesServiceClient.php index 2f92ffe5ee7d..0aa736767382 100644 --- a/ManagedIdentities/src/V1/Client/ManagedIdentitiesServiceClient.php +++ b/ManagedIdentities/src/V1/Client/ManagedIdentitiesServiceClient.php @@ -1,6 +1,6 @@ [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/managed_identities_service_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/managed_identities_service_rest_client_config.php', ], ], ]; @@ -176,12 +175,33 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a domain * resource. @@ -363,8 +383,10 @@ public function attachTrust(AttachTrustRequest $request, array $callOptions = [] * * @throws ApiException Thrown if the API call fails. */ - public function createMicrosoftAdDomain(CreateMicrosoftAdDomainRequest $request, array $callOptions = []): OperationResponse - { + public function createMicrosoftAdDomain( + CreateMicrosoftAdDomainRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CreateMicrosoftAdDomain', $request, $callOptions)->wait(); } @@ -522,8 +544,10 @@ public function reconfigureTrust(ReconfigureTrustRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function resetAdminPassword(ResetAdminPasswordRequest $request, array $callOptions = []): ResetAdminPasswordResponse - { + public function resetAdminPassword( + ResetAdminPasswordRequest $request, + array $callOptions = [] + ): ResetAdminPasswordResponse { return $this->startApiCall('ResetAdminPassword', $request, $callOptions)->wait(); } diff --git a/ManagedIdentities/src/V1/CreateMicrosoftAdDomainRequest.php b/ManagedIdentities/src/V1/CreateMicrosoftAdDomainRequest.php index 2a5db033f468..d96de3d33357 100644 --- a/ManagedIdentities/src/V1/CreateMicrosoftAdDomainRequest.php +++ b/ManagedIdentities/src/V1/CreateMicrosoftAdDomainRequest.php @@ -22,7 +22,7 @@ class CreateMicrosoftAdDomainRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The fully qualified domain name. * e.g. mydomain.myorganization.com, with the following restrictions: @@ -38,13 +38,13 @@ class CreateMicrosoftAdDomainRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string domain_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $domain_name = ''; + protected $domain_name = ''; /** * Required. A Managed Identity domain resource. * * Generated from protobuf field .google.cloud.managedidentities.v1.Domain domain = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $domain = null; + protected $domain = null; /** * @param string $parent Required. The resource project name and location using the form: diff --git a/ManagedIdentities/src/V1/DeleteDomainRequest.php b/ManagedIdentities/src/V1/DeleteDomainRequest.php index f0bfff87e553..e32ca99efc77 100644 --- a/ManagedIdentities/src/V1/DeleteDomainRequest.php +++ b/ManagedIdentities/src/V1/DeleteDomainRequest.php @@ -22,7 +22,7 @@ class DeleteDomainRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The domain resource name using the form: diff --git a/ManagedIdentities/src/V1/DetachTrustRequest.php b/ManagedIdentities/src/V1/DetachTrustRequest.php index f0345c04bdcb..6f4da640e84c 100644 --- a/ManagedIdentities/src/V1/DetachTrustRequest.php +++ b/ManagedIdentities/src/V1/DetachTrustRequest.php @@ -22,13 +22,13 @@ class DetachTrustRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The domain trust resource to removed. * * Generated from protobuf field .google.cloud.managedidentities.v1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $trust = null; + protected $trust = null; /** * @param string $name Required. The resource domain name, project name, and location using the form: diff --git a/ManagedIdentities/src/V1/Domain.php b/ManagedIdentities/src/V1/Domain.php index ee42ada971b1..fcc587589a00 100644 --- a/ManagedIdentities/src/V1/Domain.php +++ b/ManagedIdentities/src/V1/Domain.php @@ -21,7 +21,7 @@ class Domain extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Optional. Resource labels that can contain user-provided metadata. * @@ -30,7 +30,7 @@ class Domain extends \Google\Protobuf\Internal\Message private $labels; /** * Optional. The full names of the Google Compute Engine - * [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain + * [networks](/compute/docs/networks-and-firewalls#networks) the domain * instance is connected to. Networks can be added using UpdateDomain. * The domain is only available on networks listed in `authorized_networks`. * If CIDR subnets overlap between networks, domain creation will fail. @@ -46,7 +46,7 @@ class Domain extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string reserved_ip_range = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $reserved_ip_range = ''; + protected $reserved_ip_range = ''; /** * Required. Locations where domain needs to be provisioned. * [regions][compute/docs/regions-zones/] @@ -63,7 +63,7 @@ class Domain extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string admin = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $admin = ''; + protected $admin = ''; /** * Output only. The fully-qualified domain name of the exposed domain used by * clients to connect to the service. Similar to what would be chosen for an @@ -71,32 +71,32 @@ class Domain extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string fqdn = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $fqdn = ''; + protected $fqdn = ''; /** * Output only. The time the instance was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The last update time. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Output only. The current state of this domain. * * Generated from protobuf field .google.cloud.managedidentities.v1.Domain.State state = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. Additional information about the current status of this * domain, if available. * * Generated from protobuf field string status_message = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $status_message = ''; + protected $status_message = ''; /** * Output only. The current trusts associated with the domain. * @@ -117,7 +117,7 @@ class Domain extends \Google\Protobuf\Internal\Message * Optional. Resource labels that can contain user-provided metadata. * @type array|\Google\Protobuf\Internal\RepeatedField $authorized_networks * Optional. The full names of the Google Compute Engine - * [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain + * [networks](/compute/docs/networks-and-firewalls#networks) the domain * instance is connected to. Networks can be added using UpdateDomain. * The domain is only available on networks listed in `authorized_networks`. * If CIDR subnets overlap between networks, domain creation will fail. @@ -213,7 +213,7 @@ public function setLabels($var) /** * Optional. The full names of the Google Compute Engine - * [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain + * [networks](/compute/docs/networks-and-firewalls#networks) the domain * instance is connected to. Networks can be added using UpdateDomain. * The domain is only available on networks listed in `authorized_networks`. * If CIDR subnets overlap between networks, domain creation will fail. @@ -228,7 +228,7 @@ public function getAuthorizedNetworks() /** * Optional. The full names of the Google Compute Engine - * [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain + * [networks](/compute/docs/networks-and-firewalls#networks) the domain * instance is connected to. Networks can be added using UpdateDomain. * The domain is only available on networks listed in `authorized_networks`. * If CIDR subnets overlap between networks, domain creation will fail. diff --git a/ManagedIdentities/src/V1/Gapic/ManagedIdentitiesServiceGapicClient.php b/ManagedIdentities/src/V1/Gapic/ManagedIdentitiesServiceGapicClient.php deleted file mode 100644 index 74478a000b8e..000000000000 --- a/ManagedIdentities/src/V1/Gapic/ManagedIdentitiesServiceGapicClient.php +++ /dev/null @@ -1,1048 +0,0 @@ -domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $trust = new Trust(); - * $operationResponse = $managedIdentitiesServiceClient->attachTrust($formattedName, $trust); - * $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 = $managedIdentitiesServiceClient->attachTrust($formattedName, $trust); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'attachTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient}. - */ -class ManagedIdentitiesServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.managedidentities.v1.ManagedIdentitiesService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'managedidentities.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'managedidentities.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $domainNameTemplate; - - private static $locationNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getDomainNameTemplate() - { - if (self::$domainNameTemplate == null) { - self::$domainNameTemplate = new PathTemplate('projects/{project}/locations/{location}/domains/{domain}'); - } - - return self::$domainNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'domain' => self::getDomainNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location, $domain) - { - return self::getDomainNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Adds an AD trust to a domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $trust = new Trust(); - * $operationResponse = $managedIdentitiesServiceClient->attachTrust($formattedName, $trust); - * $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 = $managedIdentitiesServiceClient->attachTrust($formattedName, $trust); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'attachTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @param Trust $trust Required. The domain trust resource. - * @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 attachTrust($name, $trust, array $optionalArgs = []) - { - $request = new AttachTrustRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTrust($trust); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('AttachTrust', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a Microsoft AD domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedParent = $managedIdentitiesServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $domainName = 'domain_name'; - * $domain = new Domain(); - * $operationResponse = $managedIdentitiesServiceClient->createMicrosoftAdDomain($formattedParent, $domainName, $domain); - * $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 = $managedIdentitiesServiceClient->createMicrosoftAdDomain($formattedParent, $domainName, $domain); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'createMicrosoftAdDomain'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource project name and location using the form: - * `projects/{project_id}/locations/global` - * @param string $domainName Required. The fully qualified domain name. - * 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. - * @param Domain $domain Required. A Managed Identity domain resource. - * @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 createMicrosoftAdDomain($parent, $domainName, $domain, array $optionalArgs = []) - { - $request = new CreateMicrosoftAdDomainRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setDomainName($domainName); - $request->setDomain($domain); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateMicrosoftAdDomain', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes a domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $operationResponse = $managedIdentitiesServiceClient->deleteDomain($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 = $managedIdentitiesServiceClient->deleteDomain($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'deleteDomain'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @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 deleteDomain($name, array $optionalArgs = []) - { - $request = new DeleteDomainRequest(); - $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('DeleteDomain', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Removes an AD trust. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $trust = new Trust(); - * $operationResponse = $managedIdentitiesServiceClient->detachTrust($formattedName, $trust); - * $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 = $managedIdentitiesServiceClient->detachTrust($formattedName, $trust); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'detachTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @param Trust $trust Required. The domain trust resource to removed. - * @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 detachTrust($name, $trust, array $optionalArgs = []) - { - $request = new DetachTrustRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTrust($trust); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('DetachTrust', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Gets information about a domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $response = $managedIdentitiesServiceClient->getDomain($formattedName); - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @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\ManagedIdentities\V1\Domain - * - * @throws ApiException if the remote call fails - */ - public function getDomain($name, array $optionalArgs = []) - { - $request = new GetDomainRequest(); - $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('GetDomain', Domain::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists domains in a project. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedParent = $managedIdentitiesServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $managedIdentitiesServiceClient->listDomains($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $managedIdentitiesServiceClient->listDomains($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource name of the domain location using the form: - * `projects/{project_id}/locations/global` - * @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 string $filter - * Optional. A filter specifying constraints of a list operation. - * For example, `Domain.fqdn="mydomain.myorginization"`. - * @type string $orderBy - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listDomains($parent, array $optionalArgs = []) - { - $request = new ListDomainsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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('ListDomains', $optionalArgs, ListDomainsResponse::class, $request); - } - - /** - * Updates the DNS conditional forwarder. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $targetDomainName = 'target_domain_name'; - * $targetDnsIpAddresses = []; - * $operationResponse = $managedIdentitiesServiceClient->reconfigureTrust($formattedName, $targetDomainName, $targetDnsIpAddresses); - * $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 = $managedIdentitiesServiceClient->reconfigureTrust($formattedName, $targetDomainName, $targetDnsIpAddresses); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'reconfigureTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @param string $targetDomainName Required. The fully-qualified target domain name which will be in trust with current - * domain. - * @param string[] $targetDnsIpAddresses Required. The target DNS server IP addresses to resolve the remote domain involved - * in the trust. - * @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 reconfigureTrust($name, $targetDomainName, $targetDnsIpAddresses, array $optionalArgs = []) - { - $request = new ReconfigureTrustRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTargetDomainName($targetDomainName); - $request->setTargetDnsIpAddresses($targetDnsIpAddresses); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ReconfigureTrust', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Resets a domain's administrator password. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $response = $managedIdentitiesServiceClient->resetAdminPassword($formattedName); - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @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\ManagedIdentities\V1\ResetAdminPasswordResponse - * - * @throws ApiException if the remote call fails - */ - public function resetAdminPassword($name, array $optionalArgs = []) - { - $request = new ResetAdminPasswordRequest(); - $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('ResetAdminPassword', ResetAdminPasswordResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates the metadata and configuration of a domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $domain = new Domain(); - * $operationResponse = $managedIdentitiesServiceClient->updateDomain($updateMask, $domain); - * $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 = $managedIdentitiesServiceClient->updateDomain($updateMask, $domain); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'updateDomain'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Mask of fields to update. At least one path must be supplied in this - * field. The elements of the repeated paths field may only include - * fields from [Domain][google.cloud.managedidentities.v1.Domain]: - * * `labels` - * * `locations` - * * `authorized_networks` - * @param Domain $domain Required. Domain message with updated fields. Only supported fields specified in - * update_mask are updated. - * @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 updateDomain($updateMask, $domain, array $optionalArgs = []) - { - $request = new UpdateDomainRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setDomain($domain); - $requestParamHeaders['domain.name'] = $domain->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateDomain', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Validates a trust state, that the target domain is reachable, and that the - * target domain is able to accept incoming trust requests. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $trust = new Trust(); - * $operationResponse = $managedIdentitiesServiceClient->validateTrust($formattedName, $trust); - * $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 = $managedIdentitiesServiceClient->validateTrust($formattedName, $trust); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'validateTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @param Trust $trust Required. The domain trust to validate trust state for. - * @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 validateTrust($name, $trust, array $optionalArgs = []) - { - $request = new ValidateTrustRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTrust($trust); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ValidateTrust', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } -} diff --git a/ManagedIdentities/src/V1/GetDomainRequest.php b/ManagedIdentities/src/V1/GetDomainRequest.php index 1a9e234f4aa6..8900370c46d4 100644 --- a/ManagedIdentities/src/V1/GetDomainRequest.php +++ b/ManagedIdentities/src/V1/GetDomainRequest.php @@ -21,7 +21,7 @@ class GetDomainRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The domain resource name using the form: diff --git a/ManagedIdentities/src/V1/ListDomainsRequest.php b/ManagedIdentities/src/V1/ListDomainsRequest.php index 7e5bb75ecba0..0d7b7bdcb159 100644 --- a/ManagedIdentities/src/V1/ListDomainsRequest.php +++ b/ManagedIdentities/src/V1/ListDomainsRequest.php @@ -22,7 +22,7 @@ class ListDomainsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. The maximum number of items to return. * If not specified, a default value of 1000 will be used. @@ -33,21 +33,21 @@ class ListDomainsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The `next_page_token` value returned from a previous ListDomainsRequest * request, if any. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. A filter specifying constraints of a list operation. * For example, `Domain.fqdn="mydomain.myorginization"`. * * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Specifies the ordering of results. See * [Sorting @@ -56,7 +56,7 @@ class ListDomainsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The resource name of the domain location using the form: diff --git a/ManagedIdentities/src/V1/ListDomainsResponse.php b/ManagedIdentities/src/V1/ListDomainsResponse.php index 4cb72ac45e89..4d274be3bf26 100644 --- a/ManagedIdentities/src/V1/ListDomainsResponse.php +++ b/ManagedIdentities/src/V1/ListDomainsResponse.php @@ -28,7 +28,7 @@ class ListDomainsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * A list of locations that could not be reached. * diff --git a/ManagedIdentities/src/V1/ManagedIdentitiesServiceClient.php b/ManagedIdentities/src/V1/ManagedIdentitiesServiceClient.php deleted file mode 100644 index 541ad844170d..000000000000 --- a/ManagedIdentities/src/V1/ManagedIdentitiesServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -.google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. Server-defined resource path for the target of the operation. * * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $target = ''; + protected $target = ''; /** * Output only. Name of the verb executed by the operation. * * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $verb = ''; + protected $verb = ''; /** * Output only. Identifies whether the user has requested cancellation * of the operation. Operations that have successfully been cancelled @@ -47,13 +47,13 @@ class OpMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool requested_cancellation = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $requested_cancellation = false; + protected $requested_cancellation = false; /** * Output only. API version used to start the operation. * * Generated from protobuf field string api_version = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $api_version = ''; + protected $api_version = ''; /** * Constructor. diff --git a/ManagedIdentities/src/V1/ReconfigureTrustRequest.php b/ManagedIdentities/src/V1/ReconfigureTrustRequest.php index 343048fa3994..fe92488377fc 100644 --- a/ManagedIdentities/src/V1/ReconfigureTrustRequest.php +++ b/ManagedIdentities/src/V1/ReconfigureTrustRequest.php @@ -22,14 +22,14 @@ class ReconfigureTrustRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The fully-qualified target domain name which will be in trust with current * domain. * * Generated from protobuf field string target_domain_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $target_domain_name = ''; + protected $target_domain_name = ''; /** * Required. The target DNS server IP addresses to resolve the remote domain involved * in the trust. diff --git a/ManagedIdentities/src/V1/ResetAdminPasswordRequest.php b/ManagedIdentities/src/V1/ResetAdminPasswordRequest.php index c422ebd27ae8..5aa41f4f8b8e 100644 --- a/ManagedIdentities/src/V1/ResetAdminPasswordRequest.php +++ b/ManagedIdentities/src/V1/ResetAdminPasswordRequest.php @@ -22,7 +22,7 @@ class ResetAdminPasswordRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The domain resource name using the form: diff --git a/ManagedIdentities/src/V1/ResetAdminPasswordResponse.php b/ManagedIdentities/src/V1/ResetAdminPasswordResponse.php index 6b59efa73041..0e2b6865b4ef 100644 --- a/ManagedIdentities/src/V1/ResetAdminPasswordResponse.php +++ b/ManagedIdentities/src/V1/ResetAdminPasswordResponse.php @@ -21,7 +21,7 @@ class ResetAdminPasswordResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string password = 1; */ - private $password = ''; + protected $password = ''; /** * Constructor. diff --git a/ManagedIdentities/src/V1/Trust.php b/ManagedIdentities/src/V1/Trust.php index 4dfa84385ff5..637e3b32d72b 100644 --- a/ManagedIdentities/src/V1/Trust.php +++ b/ManagedIdentities/src/V1/Trust.php @@ -22,20 +22,20 @@ class Trust extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string target_domain_name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $target_domain_name = ''; + protected $target_domain_name = ''; /** * Required. The type of trust represented by the trust resource. * * Generated from protobuf field .google.cloud.managedidentities.v1.Trust.TrustType trust_type = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $trust_type = 0; + protected $trust_type = 0; /** * Required. The trust direction, which decides if the current domain is trusted, * trusting, or both. * * Generated from protobuf field .google.cloud.managedidentities.v1.Trust.TrustDirection trust_direction = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $trust_direction = 0; + protected $trust_direction = 0; /** * Optional. The trust authentication type, which decides whether the trusted side has * forest/domain wide access or selective access to an approved set of @@ -43,7 +43,7 @@ class Trust extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool selective_authentication = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $selective_authentication = false; + protected $selective_authentication = false; /** * Required. The target DNS server IP addresses which can resolve the remote domain * involved in the trust. @@ -57,37 +57,37 @@ class Trust extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string trust_handshake_secret = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $trust_handshake_secret = ''; + protected $trust_handshake_secret = ''; /** * Output only. The time the instance was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The last update time. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Output only. The current state of the trust. * * Generated from protobuf field .google.cloud.managedidentities.v1.Trust.State state = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. Additional information about the current state of the trust, if available. * * Generated from protobuf field string state_description = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state_description = ''; + protected $state_description = ''; /** * Output only. The last heartbeat time when the trust was known to be connected. * * Generated from protobuf field .google.protobuf.Timestamp last_trust_heartbeat_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $last_trust_heartbeat_time = null; + protected $last_trust_heartbeat_time = null; /** * Constructor. diff --git a/ManagedIdentities/src/V1/UpdateDomainRequest.php b/ManagedIdentities/src/V1/UpdateDomainRequest.php index 98aab542d858..35eceef3d024 100644 --- a/ManagedIdentities/src/V1/UpdateDomainRequest.php +++ b/ManagedIdentities/src/V1/UpdateDomainRequest.php @@ -26,14 +26,14 @@ class UpdateDomainRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. Domain message with updated fields. Only supported fields specified in * update_mask are updated. * * Generated from protobuf field .google.cloud.managedidentities.v1.Domain domain = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $domain = null; + protected $domain = null; /** * @param \Google\Cloud\ManagedIdentities\V1\Domain $domain Required. Domain message with updated fields. Only supported fields specified in diff --git a/ManagedIdentities/src/V1/ValidateTrustRequest.php b/ManagedIdentities/src/V1/ValidateTrustRequest.php index 959a4db0dc98..da322c4a9393 100644 --- a/ManagedIdentities/src/V1/ValidateTrustRequest.php +++ b/ManagedIdentities/src/V1/ValidateTrustRequest.php @@ -22,13 +22,13 @@ class ValidateTrustRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The domain trust to validate trust state for. * * Generated from protobuf field .google.cloud.managedidentities.v1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $trust = null; + protected $trust = null; /** * @param string $name Required. The resource domain name, project name, and location using the form: diff --git a/ManagedIdentities/src/V1beta1/AttachTrustRequest.php b/ManagedIdentities/src/V1beta1/AttachTrustRequest.php deleted file mode 100644 index 951c7210a938..000000000000 --- a/ManagedIdentities/src/V1beta1/AttachTrustRequest.php +++ /dev/null @@ -1,116 +0,0 @@ -google.cloud.managedidentities.v1beta1.AttachTrustRequest - */ -class AttachTrustRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - /** - * Required. The domain trust resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $trust = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @type \Google\Cloud\ManagedIdentities\V1beta1\Trust $trust - * Required. The domain trust resource. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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 domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * Required. The domain trust resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\ManagedIdentities\V1beta1\Trust|null - */ - public function getTrust() - { - return $this->trust; - } - - public function hasTrust() - { - return isset($this->trust); - } - - public function clearTrust() - { - unset($this->trust); - } - - /** - * Required. The domain trust resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\ManagedIdentities\V1beta1\Trust $var - * @return $this - */ - public function setTrust($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\ManagedIdentities\V1beta1\Trust::class); - $this->trust = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/CreateMicrosoftAdDomainRequest.php b/ManagedIdentities/src/V1beta1/CreateMicrosoftAdDomainRequest.php deleted file mode 100644 index 25dcb9964f44..000000000000 --- a/ManagedIdentities/src/V1beta1/CreateMicrosoftAdDomainRequest.php +++ /dev/null @@ -1,186 +0,0 @@ -google.cloud.managedidentities.v1beta1.CreateMicrosoftAdDomainRequest - */ -class CreateMicrosoftAdDomainRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The resource project name and location using the form: - * `projects/{project_id}/locations/global` - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $parent = ''; - /** - * Required. A domain name, e.g. mydomain.myorg.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 segment length (mydomain form example above) shouldn't exceed - * 15 chars. - * * The last segment cannot be fully numeric. - * * Must be unique within the customer project. - * - * Generated from protobuf field string domain_name = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $domain_name = ''; - /** - * Required. A Managed Identity domain resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain domain = 3 [(.google.api.field_behavior) = REQUIRED]; - */ - private $domain = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * Required. The resource project name and location using the form: - * `projects/{project_id}/locations/global` - * @type string $domain_name - * Required. A domain name, e.g. mydomain.myorg.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 segment length (mydomain form example above) shouldn't exceed - * 15 chars. - * * The last segment cannot be fully numeric. - * * Must be unique within the customer project. - * @type \Google\Cloud\ManagedIdentities\V1beta1\Domain $domain - * Required. A Managed Identity domain resource. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The resource project name and location using the form: - * `projects/{project_id}/locations/global` - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @return string - */ - public function getParent() - { - return $this->parent; - } - - /** - * Required. The resource project name and location using the form: - * `projects/{project_id}/locations/global` - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setParent($var) - { - GPBUtil::checkString($var, True); - $this->parent = $var; - - return $this; - } - - /** - * Required. A domain name, e.g. mydomain.myorg.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 segment length (mydomain form example above) shouldn't exceed - * 15 chars. - * * The last segment cannot be fully numeric. - * * Must be unique within the customer project. - * - * Generated from protobuf field string domain_name = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return string - */ - public function getDomainName() - { - return $this->domain_name; - } - - /** - * Required. A domain name, e.g. mydomain.myorg.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 segment length (mydomain form example above) shouldn't exceed - * 15 chars. - * * The last segment cannot be fully numeric. - * * Must be unique within the customer project. - * - * Generated from protobuf field string domain_name = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param string $var - * @return $this - */ - public function setDomainName($var) - { - GPBUtil::checkString($var, True); - $this->domain_name = $var; - - return $this; - } - - /** - * Required. A Managed Identity domain resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain domain = 3 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\ManagedIdentities\V1beta1\Domain|null - */ - public function getDomain() - { - return $this->domain; - } - - public function hasDomain() - { - return isset($this->domain); - } - - public function clearDomain() - { - unset($this->domain); - } - - /** - * Required. A Managed Identity domain resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain domain = 3 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\ManagedIdentities\V1beta1\Domain $var - * @return $this - */ - public function setDomain($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\ManagedIdentities\V1beta1\Domain::class); - $this->domain = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/DeleteDomainRequest.php b/ManagedIdentities/src/V1beta1/DeleteDomainRequest.php deleted file mode 100644 index ef464d232d8a..000000000000 --- a/ManagedIdentities/src/V1beta1/DeleteDomainRequest.php +++ /dev/null @@ -1,72 +0,0 @@ -google.cloud.managedidentities.v1beta1.DeleteDomainRequest - */ -class DeleteDomainRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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 domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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/ManagedIdentities/src/V1beta1/DetachTrustRequest.php b/ManagedIdentities/src/V1beta1/DetachTrustRequest.php deleted file mode 100644 index c29a088315b8..000000000000 --- a/ManagedIdentities/src/V1beta1/DetachTrustRequest.php +++ /dev/null @@ -1,116 +0,0 @@ -google.cloud.managedidentities.v1beta1.DetachTrustRequest - */ -class DetachTrustRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - /** - * Required. The domain trust resource to removed. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $trust = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @type \Google\Cloud\ManagedIdentities\V1beta1\Trust $trust - * Required. The domain trust resource to removed. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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 domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * Required. The domain trust resource to removed. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\ManagedIdentities\V1beta1\Trust|null - */ - public function getTrust() - { - return $this->trust; - } - - public function hasTrust() - { - return isset($this->trust); - } - - public function clearTrust() - { - unset($this->trust); - } - - /** - * Required. The domain trust resource to removed. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\ManagedIdentities\V1beta1\Trust $var - * @return $this - */ - public function setTrust($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\ManagedIdentities\V1beta1\Trust::class); - $this->trust = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/Domain.php b/ManagedIdentities/src/V1beta1/Domain.php deleted file mode 100644 index e5532a3cf4ca..000000000000 --- a/ManagedIdentities/src/V1beta1/Domain.php +++ /dev/null @@ -1,528 +0,0 @@ -google.cloud.managedidentities.v1beta1.Domain - */ -class Domain extends \Google\Protobuf\Internal\Message -{ - /** - * Output only. The unique name of the domain using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $name = ''; - /** - * Optional. Resource labels that can contain user-provided metadata. - * - * Generated from protobuf field map labels = 2 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $labels; - /** - * Optional. The full names of the Google Compute Engine - * [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain - * instance is connected to. Networks can be added using UpdateDomain. - * The domain is only available on networks listed in `authorized_networks`. - * If CIDR subnets overlap between networks, domain creation will fail. - * - * Generated from protobuf field repeated string authorized_networks = 3 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $authorized_networks; - /** - * Required. The CIDR range of internal addresses that are reserved for this - * domain. Reserved networks must be /24 or larger. Ranges must be - * unique and non-overlapping with existing subnets in - * [Domain].[authorized_networks]. - * - * Generated from protobuf field string reserved_ip_range = 4 [(.google.api.field_behavior) = REQUIRED]; - */ - private $reserved_ip_range = ''; - /** - * Required. Locations where domain needs to be provisioned. - * [regions][compute/docs/regions-zones/] - * e.g. us-west1 or us-east4 - * Service supports up to 4 locations at once. Each location will use a /26 - * block. - * - * Generated from protobuf field repeated string locations = 5 [(.google.api.field_behavior) = REQUIRED]; - */ - private $locations; - /** - * Optional. The name of delegated administrator account used to perform - * Active Directory operations. If not specified, `setupadmin` will be used. - * - * Generated from protobuf field string admin = 6 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $admin = ''; - /** - * Output only. The fully-qualified domain name of the exposed domain used by - * clients to connect to the service. Similar to what would be chosen for an - * Active Directory set up on an internal network. - * - * Generated from protobuf field string fqdn = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $fqdn = ''; - /** - * Output only. The time the instance was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $create_time = null; - /** - * Output only. The last update time. - * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $update_time = null; - /** - * Output only. The current state of this domain. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain.State state = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $state = 0; - /** - * Output only. Additional information about the current status of this - * domain, if available. - * - * Generated from protobuf field string status_message = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $status_message = ''; - /** - * Output only. The current trusts associated with the domain. - * - * Generated from protobuf field repeated .google.cloud.managedidentities.v1beta1.Trust trusts = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $trusts; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Output only. The unique name of the domain using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}`. - * @type array|\Google\Protobuf\Internal\MapField $labels - * Optional. Resource labels that can contain user-provided metadata. - * @type array|\Google\Protobuf\Internal\RepeatedField $authorized_networks - * Optional. The full names of the Google Compute Engine - * [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain - * instance is connected to. Networks can be added using UpdateDomain. - * The domain is only available on networks listed in `authorized_networks`. - * If CIDR subnets overlap between networks, domain creation will fail. - * @type string $reserved_ip_range - * Required. The CIDR range of internal addresses that are reserved for this - * domain. Reserved networks must be /24 or larger. Ranges must be - * unique and non-overlapping with existing subnets in - * [Domain].[authorized_networks]. - * @type array|\Google\Protobuf\Internal\RepeatedField $locations - * Required. Locations where domain needs to be provisioned. - * [regions][compute/docs/regions-zones/] - * e.g. us-west1 or us-east4 - * Service supports up to 4 locations at once. Each location will use a /26 - * block. - * @type string $admin - * Optional. The name of delegated administrator account used to perform - * Active Directory operations. If not specified, `setupadmin` will be used. - * @type string $fqdn - * Output only. The fully-qualified domain name of the exposed domain used by - * clients to connect to the service. Similar to what would be chosen for an - * Active Directory set up on an internal network. - * @type \Google\Protobuf\Timestamp $create_time - * Output only. The time the instance was created. - * @type \Google\Protobuf\Timestamp $update_time - * Output only. The last update time. - * @type int $state - * Output only. The current state of this domain. - * @type string $status_message - * Output only. Additional information about the current status of this - * domain, if available. - * @type array<\Google\Cloud\ManagedIdentities\V1beta1\Trust>|\Google\Protobuf\Internal\RepeatedField $trusts - * Output only. The current trusts associated with the domain. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\Resource::initOnce(); - parent::__construct($data); - } - - /** - * Output only. The unique name of the domain using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Output only. The unique name of the domain using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}`. - * - * 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; - } - - /** - * Optional. Resource labels that can contain user-provided metadata. - * - * Generated from protobuf field map labels = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\MapField - */ - public function getLabels() - { - return $this->labels; - } - - /** - * Optional. Resource labels that can contain user-provided metadata. - * - * Generated from protobuf field map labels = 2 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\MapField $var - * @return $this - */ - public function setLabels($var) - { - $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); - $this->labels = $arr; - - return $this; - } - - /** - * Optional. The full names of the Google Compute Engine - * [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain - * instance is connected to. Networks can be added using UpdateDomain. - * The domain is only available on networks listed in `authorized_networks`. - * If CIDR subnets overlap between networks, domain creation will fail. - * - * Generated from protobuf field repeated string authorized_networks = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getAuthorizedNetworks() - { - return $this->authorized_networks; - } - - /** - * Optional. The full names of the Google Compute Engine - * [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain - * instance is connected to. Networks can be added using UpdateDomain. - * The domain is only available on networks listed in `authorized_networks`. - * If CIDR subnets overlap between networks, domain creation will fail. - * - * Generated from protobuf field repeated string authorized_networks = 3 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setAuthorizedNetworks($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->authorized_networks = $arr; - - return $this; - } - - /** - * Required. The CIDR range of internal addresses that are reserved for this - * domain. Reserved networks must be /24 or larger. Ranges must be - * unique and non-overlapping with existing subnets in - * [Domain].[authorized_networks]. - * - * Generated from protobuf field string reserved_ip_range = 4 [(.google.api.field_behavior) = REQUIRED]; - * @return string - */ - public function getReservedIpRange() - { - return $this->reserved_ip_range; - } - - /** - * Required. The CIDR range of internal addresses that are reserved for this - * domain. Reserved networks must be /24 or larger. Ranges must be - * unique and non-overlapping with existing subnets in - * [Domain].[authorized_networks]. - * - * Generated from protobuf field string reserved_ip_range = 4 [(.google.api.field_behavior) = REQUIRED]; - * @param string $var - * @return $this - */ - public function setReservedIpRange($var) - { - GPBUtil::checkString($var, True); - $this->reserved_ip_range = $var; - - return $this; - } - - /** - * Required. Locations where domain needs to be provisioned. - * [regions][compute/docs/regions-zones/] - * e.g. us-west1 or us-east4 - * Service supports up to 4 locations at once. Each location will use a /26 - * block. - * - * Generated from protobuf field repeated string locations = 5 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getLocations() - { - return $this->locations; - } - - /** - * Required. Locations where domain needs to be provisioned. - * [regions][compute/docs/regions-zones/] - * e.g. us-west1 or us-east4 - * Service supports up to 4 locations at once. Each location will use a /26 - * block. - * - * Generated from protobuf field repeated string locations = 5 [(.google.api.field_behavior) = REQUIRED]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setLocations($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->locations = $arr; - - return $this; - } - - /** - * Optional. The name of delegated administrator account used to perform - * Active Directory operations. If not specified, `setupadmin` will be used. - * - * Generated from protobuf field string admin = 6 [(.google.api.field_behavior) = OPTIONAL]; - * @return string - */ - public function getAdmin() - { - return $this->admin; - } - - /** - * Optional. The name of delegated administrator account used to perform - * Active Directory operations. If not specified, `setupadmin` will be used. - * - * Generated from protobuf field string admin = 6 [(.google.api.field_behavior) = OPTIONAL]; - * @param string $var - * @return $this - */ - public function setAdmin($var) - { - GPBUtil::checkString($var, True); - $this->admin = $var; - - return $this; - } - - /** - * Output only. The fully-qualified domain name of the exposed domain used by - * clients to connect to the service. Similar to what would be chosen for an - * Active Directory set up on an internal network. - * - * Generated from protobuf field string fqdn = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getFqdn() - { - return $this->fqdn; - } - - /** - * Output only. The fully-qualified domain name of the exposed domain used by - * clients to connect to the service. Similar to what would be chosen for an - * Active Directory set up on an internal network. - * - * Generated from protobuf field string fqdn = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setFqdn($var) - { - GPBUtil::checkString($var, True); - $this->fqdn = $var; - - return $this; - } - - /** - * Output only. The time the instance was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp|null - */ - public function getCreateTime() - { - return $this->create_time; - } - - public function hasCreateTime() - { - return isset($this->create_time); - } - - public function clearCreateTime() - { - unset($this->create_time); - } - - /** - * Output only. The time the instance was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param \Google\Protobuf\Timestamp $var - * @return $this - */ - public function setCreateTime($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->create_time = $var; - - return $this; - } - - /** - * Output only. The last update time. - * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp|null - */ - public function getUpdateTime() - { - return $this->update_time; - } - - public function hasUpdateTime() - { - return isset($this->update_time); - } - - public function clearUpdateTime() - { - unset($this->update_time); - } - - /** - * Output only. The last update time. - * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 12 [(.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; - } - - /** - * Output only. The current state of this domain. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain.State state = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return int - */ - public function getState() - { - return $this->state; - } - - /** - * Output only. The current state of this domain. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain.State state = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param int $var - * @return $this - */ - public function setState($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\ManagedIdentities\V1beta1\Domain\State::class); - $this->state = $var; - - return $this; - } - - /** - * Output only. Additional information about the current status of this - * domain, if available. - * - * Generated from protobuf field string status_message = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getStatusMessage() - { - return $this->status_message; - } - - /** - * Output only. Additional information about the current status of this - * domain, if available. - * - * Generated from protobuf field string status_message = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setStatusMessage($var) - { - GPBUtil::checkString($var, True); - $this->status_message = $var; - - return $this; - } - - /** - * Output only. The current trusts associated with the domain. - * - * Generated from protobuf field repeated .google.cloud.managedidentities.v1beta1.Trust trusts = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getTrusts() - { - return $this->trusts; - } - - /** - * Output only. The current trusts associated with the domain. - * - * Generated from protobuf field repeated .google.cloud.managedidentities.v1beta1.Trust trusts = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param array<\Google\Cloud\ManagedIdentities\V1beta1\Trust>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setTrusts($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\ManagedIdentities\V1beta1\Trust::class); - $this->trusts = $arr; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/Domain/State.php b/ManagedIdentities/src/V1beta1/Domain/State.php deleted file mode 100644 index 84331d989a9c..000000000000 --- a/ManagedIdentities/src/V1beta1/Domain/State.php +++ /dev/null @@ -1,98 +0,0 @@ -google.cloud.managedidentities.v1beta1.Domain.State - */ -class State -{ - /** - * Not set. - * - * Generated from protobuf enum STATE_UNSPECIFIED = 0; - */ - const STATE_UNSPECIFIED = 0; - /** - * The domain is being created. - * - * Generated from protobuf enum CREATING = 1; - */ - const CREATING = 1; - /** - * The domain has been created and is fully usable. - * - * Generated from protobuf enum READY = 2; - */ - const READY = 2; - /** - * The domain's configuration is being updated. - * - * Generated from protobuf enum UPDATING = 3; - */ - const UPDATING = 3; - /** - * The domain is being deleted. - * - * Generated from protobuf enum DELETING = 4; - */ - const DELETING = 4; - /** - * The domain is being repaired and may be unusable. Details - * can be found in the `status_message` field. - * - * Generated from protobuf enum REPAIRING = 5; - */ - const REPAIRING = 5; - /** - * The domain is undergoing maintenance. - * - * Generated from protobuf enum PERFORMING_MAINTENANCE = 6; - */ - const PERFORMING_MAINTENANCE = 6; - /** - * The domain is not serving requests. - * - * Generated from protobuf enum UNAVAILABLE = 7; - */ - const UNAVAILABLE = 7; - - private static $valueToName = [ - self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', - self::CREATING => 'CREATING', - self::READY => 'READY', - self::UPDATING => 'UPDATING', - self::DELETING => 'DELETING', - self::REPAIRING => 'REPAIRING', - self::PERFORMING_MAINTENANCE => 'PERFORMING_MAINTENANCE', - self::UNAVAILABLE => 'UNAVAILABLE', - ]; - - 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/ManagedIdentities/src/V1beta1/Gapic/ManagedIdentitiesServiceGapicClient.php b/ManagedIdentities/src/V1beta1/Gapic/ManagedIdentitiesServiceGapicClient.php deleted file mode 100644 index ffd3b81441cf..000000000000 --- a/ManagedIdentities/src/V1beta1/Gapic/ManagedIdentitiesServiceGapicClient.php +++ /dev/null @@ -1,1052 +0,0 @@ -domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $trust = new Trust(); - * $operationResponse = $managedIdentitiesServiceClient->attachTrust($formattedName, $trust); - * $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 = $managedIdentitiesServiceClient->attachTrust($formattedName, $trust); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'attachTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * Many parameters require resource names to be formatted in a particular way. To - * assist with these names, this class includes a format method for each type of - * name, and additionally a parseName method to extract the individual identifiers - * contained within formatted names that are returned by the API. - * - * @experimental - * - * @deprecated This class will be removed in the next major version update. - */ -class ManagedIdentitiesServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.managedidentities.v1beta1.ManagedIdentitiesService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'managedidentities.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'managedidentities.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $domainNameTemplate; - - private static $locationNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getDomainNameTemplate() - { - if (self::$domainNameTemplate == null) { - self::$domainNameTemplate = new PathTemplate('projects/{project}/locations/{location}/domains/{domain}'); - } - - return self::$domainNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'domain' => self::getDomainNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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. - * - * @experimental - */ - public static function domainName($project, $location, $domain) - { - return self::getDomainNameTemplate()->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. - * - * @experimental - */ - public static function locationName($project, $location) - { - return self::getLocationNameTemplate()->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. - * - * @experimental - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * 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 '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 - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Adds an AD trust to a domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $trust = new Trust(); - * $operationResponse = $managedIdentitiesServiceClient->attachTrust($formattedName, $trust); - * $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 = $managedIdentitiesServiceClient->attachTrust($formattedName, $trust); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'attachTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @param Trust $trust Required. The domain trust resource. - * @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 - * - * @experimental - */ - public function attachTrust($name, $trust, array $optionalArgs = []) - { - $request = new AttachTrustRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTrust($trust); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('AttachTrust', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a Microsoft AD domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedParent = $managedIdentitiesServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $domainName = 'domain_name'; - * $domain = new Domain(); - * $operationResponse = $managedIdentitiesServiceClient->createMicrosoftAdDomain($formattedParent, $domainName, $domain); - * $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 = $managedIdentitiesServiceClient->createMicrosoftAdDomain($formattedParent, $domainName, $domain); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'createMicrosoftAdDomain'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource project name and location using the form: - * `projects/{project_id}/locations/global` - * @param string $domainName Required. A domain name, e.g. mydomain.myorg.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 segment length (mydomain form example above) shouldn't exceed - * 15 chars. - * * The last segment cannot be fully numeric. - * * Must be unique within the customer project. - * @param Domain $domain Required. A Managed Identity domain resource. - * @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 - * - * @experimental - */ - public function createMicrosoftAdDomain($parent, $domainName, $domain, array $optionalArgs = []) - { - $request = new CreateMicrosoftAdDomainRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setDomainName($domainName); - $request->setDomain($domain); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateMicrosoftAdDomain', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes a domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $operationResponse = $managedIdentitiesServiceClient->deleteDomain($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 = $managedIdentitiesServiceClient->deleteDomain($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'deleteDomain'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @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 - * - * @experimental - */ - public function deleteDomain($name, array $optionalArgs = []) - { - $request = new DeleteDomainRequest(); - $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('DeleteDomain', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Removes an AD trust. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $trust = new Trust(); - * $operationResponse = $managedIdentitiesServiceClient->detachTrust($formattedName, $trust); - * $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 = $managedIdentitiesServiceClient->detachTrust($formattedName, $trust); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'detachTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @param Trust $trust Required. The domain trust resource to removed. - * @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 - * - * @experimental - */ - public function detachTrust($name, $trust, array $optionalArgs = []) - { - $request = new DetachTrustRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTrust($trust); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('DetachTrust', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Gets information about a domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $response = $managedIdentitiesServiceClient->getDomain($formattedName); - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @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\ManagedIdentities\V1beta1\Domain - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function getDomain($name, array $optionalArgs = []) - { - $request = new GetDomainRequest(); - $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('GetDomain', Domain::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists domains in a project. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedParent = $managedIdentitiesServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $managedIdentitiesServiceClient->listDomains($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $managedIdentitiesServiceClient->listDomains($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource name of the domain location using the form: - * `projects/{project_id}/locations/global` - * @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 string $filter - * Optional. A filter specifying constraints of a list operation. - * For example, `Domain.fqdn="mydomain.myorginization"`. - * @type string $orderBy - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function listDomains($parent, array $optionalArgs = []) - { - $request = new ListDomainsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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('ListDomains', $optionalArgs, ListDomainsResponse::class, $request); - } - - /** - * Updates the DNS conditional forwarder. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $targetDomainName = 'target_domain_name'; - * $targetDnsIpAddresses = []; - * $operationResponse = $managedIdentitiesServiceClient->reconfigureTrust($formattedName, $targetDomainName, $targetDnsIpAddresses); - * $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 = $managedIdentitiesServiceClient->reconfigureTrust($formattedName, $targetDomainName, $targetDnsIpAddresses); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'reconfigureTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @param string $targetDomainName Required. The fully-qualified target domain name which will be in trust with current - * domain. - * @param string[] $targetDnsIpAddresses Required. The target DNS server IP addresses to resolve the remote domain involved - * in the trust. - * @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 - * - * @experimental - */ - public function reconfigureTrust($name, $targetDomainName, $targetDnsIpAddresses, array $optionalArgs = []) - { - $request = new ReconfigureTrustRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTargetDomainName($targetDomainName); - $request->setTargetDnsIpAddresses($targetDnsIpAddresses); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ReconfigureTrust', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Resets a domain's administrator password. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $response = $managedIdentitiesServiceClient->resetAdminPassword($formattedName); - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @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\ManagedIdentities\V1beta1\ResetAdminPasswordResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function resetAdminPassword($name, array $optionalArgs = []) - { - $request = new ResetAdminPasswordRequest(); - $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('ResetAdminPassword', ResetAdminPasswordResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates the metadata and configuration of a domain. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $domain = new Domain(); - * $operationResponse = $managedIdentitiesServiceClient->updateDomain($updateMask, $domain); - * $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 = $managedIdentitiesServiceClient->updateDomain($updateMask, $domain); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'updateDomain'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Mask of fields to update. At least one path must be supplied in this - * field. The elements of the repeated paths field may only include - * fields from [Domain][google.cloud.managedidentities.v1beta1.Domain]: - * * `labels` - * * `locations` - * * `authorized_networks` - * * `audit_logs_enabled` - * @param Domain $domain Required. Domain message with updated fields. Only supported fields specified in - * update_mask are updated. - * @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 - * - * @experimental - */ - public function updateDomain($updateMask, $domain, array $optionalArgs = []) - { - $request = new UpdateDomainRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setDomain($domain); - $requestParamHeaders['domain.name'] = $domain->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateDomain', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Validates a trust state, that the target domain is reachable, and that the - * target domain is able to accept incoming trust requests. - * - * Sample code: - * ``` - * $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient(); - * try { - * $formattedName = $managedIdentitiesServiceClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - * $trust = new Trust(); - * $operationResponse = $managedIdentitiesServiceClient->validateTrust($formattedName, $trust); - * $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 = $managedIdentitiesServiceClient->validateTrust($formattedName, $trust); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $managedIdentitiesServiceClient->resumeOperation($operationName, 'validateTrust'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $managedIdentitiesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @param Trust $trust Required. The domain trust to validate trust state for. - * @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 - * - * @experimental - */ - public function validateTrust($name, $trust, array $optionalArgs = []) - { - $request = new ValidateTrustRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setTrust($trust); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ValidateTrust', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } -} diff --git a/ManagedIdentities/src/V1beta1/GetDomainRequest.php b/ManagedIdentities/src/V1beta1/GetDomainRequest.php deleted file mode 100644 index 0d3b9dc1f369..000000000000 --- a/ManagedIdentities/src/V1beta1/GetDomainRequest.php +++ /dev/null @@ -1,72 +0,0 @@ -google.cloud.managedidentities.v1beta1.GetDomainRequest - */ -class GetDomainRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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 domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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/ManagedIdentities/src/V1beta1/ListDomainsRequest.php b/ManagedIdentities/src/V1beta1/ListDomainsRequest.php deleted file mode 100644 index e7b52e1792fe..000000000000 --- a/ManagedIdentities/src/V1beta1/ListDomainsRequest.php +++ /dev/null @@ -1,248 +0,0 @@ -google.cloud.managedidentities.v1beta1.ListDomainsRequest - */ -class ListDomainsRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The resource name of the domain location using the form: - * `projects/{project_id}/locations/global` - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $parent = ''; - /** - * Optional. The maximum number of items to return. - * If not specified, a default value of 1000 will be used. - * Regardless of the page_size value, the response may include a partial list. - * Callers should rely on a response's - * [next_page_token][google.cloud.managedidentities.v1beta1.ListDomainsResponse.next_page_token] - * to determine if there are additional results to list. - * - * Generated from protobuf field int32 page_size = 2; - */ - private $page_size = 0; - /** - * The `next_page_token` value returned from a previous ListDomainsRequest - * request, if any. - * - * Generated from protobuf field string page_token = 3; - */ - private $page_token = ''; - /** - * Optional. A filter specifying constraints of a list operation. - * For example, `Domain.fqdn="mydomain.myorginization"`. - * - * Generated from protobuf field string filter = 4; - */ - private $filter = ''; - /** - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * - * Generated from protobuf field string order_by = 5; - */ - private $order_by = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * Required. The resource name of the domain location using the form: - * `projects/{project_id}/locations/global` - * @type int $page_size - * Optional. The maximum number of items to return. - * If not specified, a default value of 1000 will be used. - * Regardless of the page_size value, the response may include a partial list. - * Callers should rely on a response's - * [next_page_token][google.cloud.managedidentities.v1beta1.ListDomainsResponse.next_page_token] - * to determine if there are additional results to list. - * @type string $page_token - * The `next_page_token` value returned from a previous ListDomainsRequest - * request, if any. - * @type string $filter - * Optional. A filter specifying constraints of a list operation. - * For example, `Domain.fqdn="mydomain.myorginization"`. - * @type string $order_by - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The resource name of the domain location using the form: - * `projects/{project_id}/locations/global` - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @return string - */ - public function getParent() - { - return $this->parent; - } - - /** - * Required. The resource name of the domain location using the form: - * `projects/{project_id}/locations/global` - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setParent($var) - { - GPBUtil::checkString($var, True); - $this->parent = $var; - - return $this; - } - - /** - * Optional. The maximum number of items to return. - * If not specified, a default value of 1000 will be used. - * Regardless of the page_size value, the response may include a partial list. - * Callers should rely on a response's - * [next_page_token][google.cloud.managedidentities.v1beta1.ListDomainsResponse.next_page_token] - * to determine if there are additional results to list. - * - * Generated from protobuf field int32 page_size = 2; - * @return int - */ - public function getPageSize() - { - return $this->page_size; - } - - /** - * Optional. The maximum number of items to return. - * If not specified, a default value of 1000 will be used. - * Regardless of the page_size value, the response may include a partial list. - * Callers should rely on a response's - * [next_page_token][google.cloud.managedidentities.v1beta1.ListDomainsResponse.next_page_token] - * to determine if there are additional results to list. - * - * Generated from protobuf field int32 page_size = 2; - * @param int $var - * @return $this - */ - public function setPageSize($var) - { - GPBUtil::checkInt32($var); - $this->page_size = $var; - - return $this; - } - - /** - * The `next_page_token` value returned from a previous ListDomainsRequest - * request, if any. - * - * Generated from protobuf field string page_token = 3; - * @return string - */ - public function getPageToken() - { - return $this->page_token; - } - - /** - * The `next_page_token` value returned from a previous ListDomainsRequest - * request, if any. - * - * Generated from protobuf field string page_token = 3; - * @param string $var - * @return $this - */ - public function setPageToken($var) - { - GPBUtil::checkString($var, True); - $this->page_token = $var; - - return $this; - } - - /** - * Optional. A filter specifying constraints of a list operation. - * For example, `Domain.fqdn="mydomain.myorginization"`. - * - * Generated from protobuf field string filter = 4; - * @return string - */ - public function getFilter() - { - return $this->filter; - } - - /** - * Optional. A filter specifying constraints of a list operation. - * For example, `Domain.fqdn="mydomain.myorginization"`. - * - * Generated from protobuf field string filter = 4; - * @param string $var - * @return $this - */ - public function setFilter($var) - { - GPBUtil::checkString($var, True); - $this->filter = $var; - - return $this; - } - - /** - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * - * Generated from protobuf field string order_by = 5; - * @return string - */ - public function getOrderBy() - { - return $this->order_by; - } - - /** - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * - * Generated from protobuf field string order_by = 5; - * @param string $var - * @return $this - */ - public function setOrderBy($var) - { - GPBUtil::checkString($var, True); - $this->order_by = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/ListDomainsResponse.php b/ManagedIdentities/src/V1beta1/ListDomainsResponse.php deleted file mode 100644 index 42cf94d19253..000000000000 --- a/ManagedIdentities/src/V1beta1/ListDomainsResponse.php +++ /dev/null @@ -1,140 +0,0 @@ -google.cloud.managedidentities.v1beta1.ListDomainsResponse - */ -class ListDomainsResponse extends \Google\Protobuf\Internal\Message -{ - /** - * A list of Managed Identities Service domains in the project. - * - * Generated from protobuf field repeated .google.cloud.managedidentities.v1beta1.Domain domains = 1; - */ - private $domains; - /** - * A token to retrieve the next page of results, or empty if there are no more - * results in the list. - * - * Generated from protobuf field string next_page_token = 2; - */ - private $next_page_token = ''; - /** - * A list of locations that could not be reached. - * - * Generated from protobuf field repeated string unreachable = 3; - */ - private $unreachable; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array<\Google\Cloud\ManagedIdentities\V1beta1\Domain>|\Google\Protobuf\Internal\RepeatedField $domains - * A list of Managed Identities Service domains in the project. - * @type string $next_page_token - * A token to retrieve the next page of results, or empty if there are no more - * results in the list. - * @type array|\Google\Protobuf\Internal\RepeatedField $unreachable - * A list of locations that could not be reached. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * A list of Managed Identities Service domains in the project. - * - * Generated from protobuf field repeated .google.cloud.managedidentities.v1beta1.Domain domains = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getDomains() - { - return $this->domains; - } - - /** - * A list of Managed Identities Service domains in the project. - * - * Generated from protobuf field repeated .google.cloud.managedidentities.v1beta1.Domain domains = 1; - * @param array<\Google\Cloud\ManagedIdentities\V1beta1\Domain>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setDomains($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\ManagedIdentities\V1beta1\Domain::class); - $this->domains = $arr; - - return $this; - } - - /** - * A token to retrieve the next page of results, or empty if there are no more - * results in the list. - * - * Generated from protobuf field string next_page_token = 2; - * @return string - */ - public function getNextPageToken() - { - return $this->next_page_token; - } - - /** - * A token to retrieve the next page of results, or empty if there are no more - * results in the list. - * - * 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; - } - - /** - * A list of locations that could not be reached. - * - * Generated from protobuf field repeated string unreachable = 3; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getUnreachable() - { - return $this->unreachable; - } - - /** - * A list of locations that could not be reached. - * - * Generated from protobuf field repeated string unreachable = 3; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setUnreachable($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->unreachable = $arr; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/ManagedIdentitiesServiceClient.php b/ManagedIdentities/src/V1beta1/ManagedIdentitiesServiceClient.php deleted file mode 100644 index e3d6a0898973..000000000000 --- a/ManagedIdentities/src/V1beta1/ManagedIdentitiesServiceClient.php +++ /dev/null @@ -1,36 +0,0 @@ -google.cloud.managedidentities.v1beta1.OpMetadata - */ -class OpMetadata extends \Google\Protobuf\Internal\Message -{ - /** - * Output only. The time the operation was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $create_time = null; - /** - * Output only. The time the operation finished running. - * - * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $end_time = null; - /** - * Output only. Server-defined resource path for the target of the operation. - * - * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $target = ''; - /** - * Output only. Name of the verb executed by the operation. - * - * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $verb = ''; - /** - * Output only. Identifies whether the user has requested cancellation - * of the operation. Operations that have successfully been cancelled - * have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - * corresponding to `Code.CANCELLED`. - * - * Generated from protobuf field bool requested_cancellation = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $requested_cancellation = false; - /** - * Output only. API version used to start the operation. - * - * Generated from protobuf field string api_version = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $api_version = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Protobuf\Timestamp $create_time - * Output only. The time the operation was created. - * @type \Google\Protobuf\Timestamp $end_time - * Output only. The time the operation finished running. - * @type string $target - * Output only. Server-defined resource path for the target of the operation. - * @type string $verb - * Output only. Name of the verb executed by the operation. - * @type bool $requested_cancellation - * Output only. Identifies whether the user has requested cancellation - * of the operation. Operations that have successfully been cancelled - * have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - * corresponding to `Code.CANCELLED`. - * @type string $api_version - * Output only. API version used to start the operation. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Output only. The time the operation was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp|null - */ - public function getCreateTime() - { - return $this->create_time; - } - - public function hasCreateTime() - { - return isset($this->create_time); - } - - public function clearCreateTime() - { - unset($this->create_time); - } - - /** - * Output only. The time the operation was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param \Google\Protobuf\Timestamp $var - * @return $this - */ - public function setCreateTime($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->create_time = $var; - - return $this; - } - - /** - * Output only. The time the operation finished running. - * - * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp|null - */ - public function getEndTime() - { - return $this->end_time; - } - - public function hasEndTime() - { - return isset($this->end_time); - } - - public function clearEndTime() - { - unset($this->end_time); - } - - /** - * Output only. The time the operation finished running. - * - * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param \Google\Protobuf\Timestamp $var - * @return $this - */ - public function setEndTime($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->end_time = $var; - - return $this; - } - - /** - * Output only. Server-defined resource path for the target of the operation. - * - * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getTarget() - { - return $this->target; - } - - /** - * Output only. Server-defined resource path for the target of the operation. - * - * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setTarget($var) - { - GPBUtil::checkString($var, True); - $this->target = $var; - - return $this; - } - - /** - * Output only. Name of the verb executed by the operation. - * - * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getVerb() - { - return $this->verb; - } - - /** - * Output only. Name of the verb executed by the operation. - * - * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setVerb($var) - { - GPBUtil::checkString($var, True); - $this->verb = $var; - - return $this; - } - - /** - * Output only. Identifies whether the user has requested cancellation - * of the operation. Operations that have successfully been cancelled - * have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - * corresponding to `Code.CANCELLED`. - * - * Generated from protobuf field bool requested_cancellation = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return bool - */ - public function getRequestedCancellation() - { - return $this->requested_cancellation; - } - - /** - * Output only. Identifies whether the user has requested cancellation - * of the operation. Operations that have successfully been cancelled - * have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - * corresponding to `Code.CANCELLED`. - * - * Generated from protobuf field bool requested_cancellation = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param bool $var - * @return $this - */ - public function setRequestedCancellation($var) - { - GPBUtil::checkBool($var); - $this->requested_cancellation = $var; - - return $this; - } - - /** - * Output only. API version used to start the operation. - * - * Generated from protobuf field string api_version = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getApiVersion() - { - return $this->api_version; - } - - /** - * Output only. API version used to start the operation. - * - * Generated from protobuf field string api_version = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setApiVersion($var) - { - GPBUtil::checkString($var, True); - $this->api_version = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/ReconfigureTrustRequest.php b/ManagedIdentities/src/V1beta1/ReconfigureTrustRequest.php deleted file mode 100644 index d45bd92dcc38..000000000000 --- a/ManagedIdentities/src/V1beta1/ReconfigureTrustRequest.php +++ /dev/null @@ -1,148 +0,0 @@ -google.cloud.managedidentities.v1beta1.ReconfigureTrustRequest - */ -class ReconfigureTrustRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - /** - * Required. The fully-qualified target domain name which will be in trust with current - * domain. - * - * Generated from protobuf field string target_domain_name = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $target_domain_name = ''; - /** - * Required. The target DNS server IP addresses to resolve the remote domain involved - * in the trust. - * - * Generated from protobuf field repeated string target_dns_ip_addresses = 3 [(.google.api.field_behavior) = REQUIRED]; - */ - private $target_dns_ip_addresses; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @type string $target_domain_name - * Required. The fully-qualified target domain name which will be in trust with current - * domain. - * @type array|\Google\Protobuf\Internal\RepeatedField $target_dns_ip_addresses - * Required. The target DNS server IP addresses to resolve the remote domain involved - * in the trust. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The resource domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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 domain name, project name and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * Required. The fully-qualified target domain name which will be in trust with current - * domain. - * - * Generated from protobuf field string target_domain_name = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return string - */ - public function getTargetDomainName() - { - return $this->target_domain_name; - } - - /** - * Required. The fully-qualified target domain name which will be in trust with current - * domain. - * - * Generated from protobuf field string target_domain_name = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param string $var - * @return $this - */ - public function setTargetDomainName($var) - { - GPBUtil::checkString($var, True); - $this->target_domain_name = $var; - - return $this; - } - - /** - * Required. The target DNS server IP addresses to resolve the remote domain involved - * in the trust. - * - * Generated from protobuf field repeated string target_dns_ip_addresses = 3 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getTargetDnsIpAddresses() - { - return $this->target_dns_ip_addresses; - } - - /** - * Required. The target DNS server IP addresses to resolve the remote domain involved - * in the trust. - * - * Generated from protobuf field repeated string target_dns_ip_addresses = 3 [(.google.api.field_behavior) = REQUIRED]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setTargetDnsIpAddresses($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->target_dns_ip_addresses = $arr; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/ResetAdminPasswordRequest.php b/ManagedIdentities/src/V1beta1/ResetAdminPasswordRequest.php deleted file mode 100644 index f6f5066dc3ba..000000000000 --- a/ManagedIdentities/src/V1beta1/ResetAdminPasswordRequest.php +++ /dev/null @@ -1,72 +0,0 @@ -google.cloud.managedidentities.v1beta1.ResetAdminPasswordRequest - */ -class ResetAdminPasswordRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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 domain resource name using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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/ManagedIdentities/src/V1beta1/ResetAdminPasswordResponse.php b/ManagedIdentities/src/V1beta1/ResetAdminPasswordResponse.php deleted file mode 100644 index fa23fdf42025..000000000000 --- a/ManagedIdentities/src/V1beta1/ResetAdminPasswordResponse.php +++ /dev/null @@ -1,68 +0,0 @@ -google.cloud.managedidentities.v1beta1.ResetAdminPasswordResponse - */ -class ResetAdminPasswordResponse extends \Google\Protobuf\Internal\Message -{ - /** - * A random password. See [admin][google.cloud.managedidentities.v1beta1.Domain.admin] for more information. - * - * Generated from protobuf field string password = 1; - */ - private $password = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $password - * A random password. See [admin][google.cloud.managedidentities.v1beta1.Domain.admin] for more information. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * A random password. See [admin][google.cloud.managedidentities.v1beta1.Domain.admin] for more information. - * - * Generated from protobuf field string password = 1; - * @return string - */ - public function getPassword() - { - return $this->password; - } - - /** - * A random password. See [admin][google.cloud.managedidentities.v1beta1.Domain.admin] for more information. - * - * Generated from protobuf field string password = 1; - * @param string $var - * @return $this - */ - public function setPassword($var) - { - GPBUtil::checkString($var, True); - $this->password = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/Trust.php b/ManagedIdentities/src/V1beta1/Trust.php deleted file mode 100644 index 8b5a451107e1..000000000000 --- a/ManagedIdentities/src/V1beta1/Trust.php +++ /dev/null @@ -1,470 +0,0 @@ -google.cloud.managedidentities.v1beta1.Trust - */ -class Trust extends \Google\Protobuf\Internal\Message -{ - /** - * The fully qualified target domain name which will be in trust with the - * current domain. - * - * Generated from protobuf field string target_domain_name = 1; - */ - private $target_domain_name = ''; - /** - * The type of trust represented by the trust resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.TrustType trust_type = 2; - */ - private $trust_type = 0; - /** - * The trust direction, which decides if the current domain is trusted, - * trusting, or both. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.TrustDirection trust_direction = 3; - */ - private $trust_direction = 0; - /** - * The trust authentication type, which decides whether the trusted side has - * forest/domain wide access or selective access to an approved set of - * resources. - * - * Generated from protobuf field bool selective_authentication = 4; - */ - private $selective_authentication = false; - /** - * The target DNS server IP addresses which can resolve the remote domain - * involved in the trust. - * - * Generated from protobuf field repeated string target_dns_ip_addresses = 5; - */ - private $target_dns_ip_addresses; - /** - * Input only. The trust secret used for the handshake - * with the target domain. It will not be stored. - * - * Generated from protobuf field string trust_handshake_secret = 6 [(.google.api.field_behavior) = INPUT_ONLY]; - */ - private $trust_handshake_secret = ''; - /** - * Output only. The time the instance was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $create_time = null; - /** - * Output only. The last update time. - * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $update_time = null; - /** - * Output only. The current state of the trust. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.State state = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $state = 0; - /** - * Output only. Additional information about the current state of the - * trust, if available. - * - * Generated from protobuf field string state_description = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $state_description = ''; - /** - * Output only. The last heartbeat time when the trust was known to be - * connected. - * - * Generated from protobuf field .google.protobuf.Timestamp last_trust_heartbeat_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - private $last_trust_heartbeat_time = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $target_domain_name - * The fully qualified target domain name which will be in trust with the - * current domain. - * @type int $trust_type - * The type of trust represented by the trust resource. - * @type int $trust_direction - * The trust direction, which decides if the current domain is trusted, - * trusting, or both. - * @type bool $selective_authentication - * The trust authentication type, which decides whether the trusted side has - * forest/domain wide access or selective access to an approved set of - * resources. - * @type array|\Google\Protobuf\Internal\RepeatedField $target_dns_ip_addresses - * The target DNS server IP addresses which can resolve the remote domain - * involved in the trust. - * @type string $trust_handshake_secret - * Input only. The trust secret used for the handshake - * with the target domain. It will not be stored. - * @type \Google\Protobuf\Timestamp $create_time - * Output only. The time the instance was created. - * @type \Google\Protobuf\Timestamp $update_time - * Output only. The last update time. - * @type int $state - * Output only. The current state of the trust. - * @type string $state_description - * Output only. Additional information about the current state of the - * trust, if available. - * @type \Google\Protobuf\Timestamp $last_trust_heartbeat_time - * Output only. The last heartbeat time when the trust was known to be - * connected. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\Resource::initOnce(); - parent::__construct($data); - } - - /** - * The fully qualified target domain name which will be in trust with the - * current domain. - * - * Generated from protobuf field string target_domain_name = 1; - * @return string - */ - public function getTargetDomainName() - { - return $this->target_domain_name; - } - - /** - * The fully qualified target domain name which will be in trust with the - * current domain. - * - * Generated from protobuf field string target_domain_name = 1; - * @param string $var - * @return $this - */ - public function setTargetDomainName($var) - { - GPBUtil::checkString($var, True); - $this->target_domain_name = $var; - - return $this; - } - - /** - * The type of trust represented by the trust resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.TrustType trust_type = 2; - * @return int - */ - public function getTrustType() - { - return $this->trust_type; - } - - /** - * The type of trust represented by the trust resource. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.TrustType trust_type = 2; - * @param int $var - * @return $this - */ - public function setTrustType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\ManagedIdentities\V1beta1\Trust\TrustType::class); - $this->trust_type = $var; - - return $this; - } - - /** - * The trust direction, which decides if the current domain is trusted, - * trusting, or both. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.TrustDirection trust_direction = 3; - * @return int - */ - public function getTrustDirection() - { - return $this->trust_direction; - } - - /** - * The trust direction, which decides if the current domain is trusted, - * trusting, or both. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.TrustDirection trust_direction = 3; - * @param int $var - * @return $this - */ - public function setTrustDirection($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\ManagedIdentities\V1beta1\Trust\TrustDirection::class); - $this->trust_direction = $var; - - return $this; - } - - /** - * The trust authentication type, which decides whether the trusted side has - * forest/domain wide access or selective access to an approved set of - * resources. - * - * Generated from protobuf field bool selective_authentication = 4; - * @return bool - */ - public function getSelectiveAuthentication() - { - return $this->selective_authentication; - } - - /** - * The trust authentication type, which decides whether the trusted side has - * forest/domain wide access or selective access to an approved set of - * resources. - * - * Generated from protobuf field bool selective_authentication = 4; - * @param bool $var - * @return $this - */ - public function setSelectiveAuthentication($var) - { - GPBUtil::checkBool($var); - $this->selective_authentication = $var; - - return $this; - } - - /** - * The target DNS server IP addresses which can resolve the remote domain - * involved in the trust. - * - * Generated from protobuf field repeated string target_dns_ip_addresses = 5; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getTargetDnsIpAddresses() - { - return $this->target_dns_ip_addresses; - } - - /** - * The target DNS server IP addresses which can resolve the remote domain - * involved in the trust. - * - * Generated from protobuf field repeated string target_dns_ip_addresses = 5; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setTargetDnsIpAddresses($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->target_dns_ip_addresses = $arr; - - return $this; - } - - /** - * Input only. The trust secret used for the handshake - * with the target domain. It will not be stored. - * - * Generated from protobuf field string trust_handshake_secret = 6 [(.google.api.field_behavior) = INPUT_ONLY]; - * @return string - */ - public function getTrustHandshakeSecret() - { - return $this->trust_handshake_secret; - } - - /** - * Input only. The trust secret used for the handshake - * with the target domain. It will not be stored. - * - * Generated from protobuf field string trust_handshake_secret = 6 [(.google.api.field_behavior) = INPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setTrustHandshakeSecret($var) - { - GPBUtil::checkString($var, True); - $this->trust_handshake_secret = $var; - - return $this; - } - - /** - * Output only. The time the instance was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp|null - */ - public function getCreateTime() - { - return $this->create_time; - } - - public function hasCreateTime() - { - return isset($this->create_time); - } - - public function clearCreateTime() - { - unset($this->create_time); - } - - /** - * Output only. The time the instance was created. - * - * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param \Google\Protobuf\Timestamp $var - * @return $this - */ - public function setCreateTime($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->create_time = $var; - - return $this; - } - - /** - * Output only. The last update time. - * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp|null - */ - public function getUpdateTime() - { - return $this->update_time; - } - - public function hasUpdateTime() - { - return isset($this->update_time); - } - - public function clearUpdateTime() - { - unset($this->update_time); - } - - /** - * Output only. The last update time. - * - * Generated from protobuf field .google.protobuf.Timestamp update_time = 8 [(.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; - } - - /** - * Output only. The current state of the trust. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.State state = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return int - */ - public function getState() - { - return $this->state; - } - - /** - * Output only. The current state of the trust. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust.State state = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param int $var - * @return $this - */ - public function setState($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\ManagedIdentities\V1beta1\Trust\State::class); - $this->state = $var; - - return $this; - } - - /** - * Output only. Additional information about the current state of the - * trust, if available. - * - * Generated from protobuf field string state_description = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getStateDescription() - { - return $this->state_description; - } - - /** - * Output only. Additional information about the current state of the - * trust, if available. - * - * Generated from protobuf field string state_description = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setStateDescription($var) - { - GPBUtil::checkString($var, True); - $this->state_description = $var; - - return $this; - } - - /** - * Output only. The last heartbeat time when the trust was known to be - * connected. - * - * Generated from protobuf field .google.protobuf.Timestamp last_trust_heartbeat_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp|null - */ - public function getLastTrustHeartbeatTime() - { - return $this->last_trust_heartbeat_time; - } - - public function hasLastTrustHeartbeatTime() - { - return isset($this->last_trust_heartbeat_time); - } - - public function clearLastTrustHeartbeatTime() - { - unset($this->last_trust_heartbeat_time); - } - - /** - * Output only. The last heartbeat time when the trust was known to be - * connected. - * - * Generated from protobuf field .google.protobuf.Timestamp last_trust_heartbeat_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param \Google\Protobuf\Timestamp $var - * @return $this - */ - public function setLastTrustHeartbeatTime($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->last_trust_heartbeat_time = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/Trust/State.php b/ManagedIdentities/src/V1beta1/Trust/State.php deleted file mode 100644 index eebc752b7cf0..000000000000 --- a/ManagedIdentities/src/V1beta1/Trust/State.php +++ /dev/null @@ -1,83 +0,0 @@ -google.cloud.managedidentities.v1beta1.Trust.State - */ -class State -{ - /** - * Not set. - * - * Generated from protobuf enum STATE_UNSPECIFIED = 0; - */ - const STATE_UNSPECIFIED = 0; - /** - * The domain trust is being created. - * - * Generated from protobuf enum CREATING = 1; - */ - const CREATING = 1; - /** - * The domain trust is being updated. - * - * Generated from protobuf enum UPDATING = 2; - */ - const UPDATING = 2; - /** - * The domain trust is being deleted. - * - * Generated from protobuf enum DELETING = 3; - */ - const DELETING = 3; - /** - * The domain trust is connected. - * - * Generated from protobuf enum CONNECTED = 4; - */ - const CONNECTED = 4; - /** - * The domain trust is disconnected. - * - * Generated from protobuf enum DISCONNECTED = 5; - */ - const DISCONNECTED = 5; - - private static $valueToName = [ - self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', - self::CREATING => 'CREATING', - self::UPDATING => 'UPDATING', - self::DELETING => 'DELETING', - self::CONNECTED => 'CONNECTED', - self::DISCONNECTED => 'DISCONNECTED', - ]; - - 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/ManagedIdentities/src/V1beta1/Trust/TrustDirection.php b/ManagedIdentities/src/V1beta1/Trust/TrustDirection.php deleted file mode 100644 index 64eb1d4e69c7..000000000000 --- a/ManagedIdentities/src/V1beta1/Trust/TrustDirection.php +++ /dev/null @@ -1,72 +0,0 @@ -google.cloud.managedidentities.v1beta1.Trust.TrustDirection - */ -class TrustDirection -{ - /** - * Not set. - * - * Generated from protobuf enum TRUST_DIRECTION_UNSPECIFIED = 0; - */ - const TRUST_DIRECTION_UNSPECIFIED = 0; - /** - * The inbound direction represents the trusting side. - * - * Generated from protobuf enum INBOUND = 1; - */ - const INBOUND = 1; - /** - * The outboud direction represents the trusted side. - * - * Generated from protobuf enum OUTBOUND = 2; - */ - const OUTBOUND = 2; - /** - * The bidirectional direction represents the trusted / trusting side. - * - * Generated from protobuf enum BIDIRECTIONAL = 3; - */ - const BIDIRECTIONAL = 3; - - private static $valueToName = [ - self::TRUST_DIRECTION_UNSPECIFIED => 'TRUST_DIRECTION_UNSPECIFIED', - self::INBOUND => 'INBOUND', - self::OUTBOUND => 'OUTBOUND', - self::BIDIRECTIONAL => 'BIDIRECTIONAL', - ]; - - 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/ManagedIdentities/src/V1beta1/Trust/TrustType.php b/ManagedIdentities/src/V1beta1/Trust/TrustType.php deleted file mode 100644 index d1c1f3c92003..000000000000 --- a/ManagedIdentities/src/V1beta1/Trust/TrustType.php +++ /dev/null @@ -1,62 +0,0 @@ -google.cloud.managedidentities.v1beta1.Trust.TrustType - */ -class TrustType -{ - /** - * Not set. - * - * Generated from protobuf enum TRUST_TYPE_UNSPECIFIED = 0; - */ - const TRUST_TYPE_UNSPECIFIED = 0; - /** - * The forest trust. - * - * Generated from protobuf enum FOREST = 1; - */ - const FOREST = 1; - /** - * The external domain trust. - * - * Generated from protobuf enum EXTERNAL = 2; - */ - const EXTERNAL = 2; - - private static $valueToName = [ - self::TRUST_TYPE_UNSPECIFIED => 'TRUST_TYPE_UNSPECIFIED', - self::FOREST => 'FOREST', - self::EXTERNAL => 'EXTERNAL', - ]; - - 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/ManagedIdentities/src/V1beta1/UpdateDomainRequest.php b/ManagedIdentities/src/V1beta1/UpdateDomainRequest.php deleted file mode 100644 index 8ec048d9bff2..000000000000 --- a/ManagedIdentities/src/V1beta1/UpdateDomainRequest.php +++ /dev/null @@ -1,150 +0,0 @@ -google.cloud.managedidentities.v1beta1.UpdateDomainRequest - */ -class UpdateDomainRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. Mask of fields to update. At least one path must be supplied in this - * field. The elements of the repeated paths field may only include - * fields from [Domain][google.cloud.managedidentities.v1beta1.Domain]: - * * `labels` - * * `locations` - * * `authorized_networks` - * * `audit_logs_enabled` - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $update_mask = null; - /** - * Required. Domain message with updated fields. Only supported fields specified in - * update_mask are updated. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain domain = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $domain = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Protobuf\FieldMask $update_mask - * Required. Mask of fields to update. At least one path must be supplied in this - * field. The elements of the repeated paths field may only include - * fields from [Domain][google.cloud.managedidentities.v1beta1.Domain]: - * * `labels` - * * `locations` - * * `authorized_networks` - * * `audit_logs_enabled` - * @type \Google\Cloud\ManagedIdentities\V1beta1\Domain $domain - * Required. Domain message with updated fields. Only supported fields specified in - * update_mask are updated. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. Mask of fields to update. At least one path must be supplied in this - * field. The elements of the repeated paths field may only include - * fields from [Domain][google.cloud.managedidentities.v1beta1.Domain]: - * * `labels` - * * `locations` - * * `authorized_networks` - * * `audit_logs_enabled` - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Protobuf\FieldMask|null - */ - public function getUpdateMask() - { - return $this->update_mask; - } - - public function hasUpdateMask() - { - return isset($this->update_mask); - } - - public function clearUpdateMask() - { - unset($this->update_mask); - } - - /** - * Required. Mask of fields to update. At least one path must be supplied in this - * field. The elements of the repeated paths field may only include - * fields from [Domain][google.cloud.managedidentities.v1beta1.Domain]: - * * `labels` - * * `locations` - * * `authorized_networks` - * * `audit_logs_enabled` - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Protobuf\FieldMask $var - * @return $this - */ - public function setUpdateMask($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); - $this->update_mask = $var; - - return $this; - } - - /** - * Required. Domain message with updated fields. Only supported fields specified in - * update_mask are updated. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain domain = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\ManagedIdentities\V1beta1\Domain|null - */ - public function getDomain() - { - return $this->domain; - } - - public function hasDomain() - { - return isset($this->domain); - } - - public function clearDomain() - { - unset($this->domain); - } - - /** - * Required. Domain message with updated fields. Only supported fields specified in - * update_mask are updated. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Domain domain = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\ManagedIdentities\V1beta1\Domain $var - * @return $this - */ - public function setDomain($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\ManagedIdentities\V1beta1\Domain::class); - $this->domain = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/ValidateTrustRequest.php b/ManagedIdentities/src/V1beta1/ValidateTrustRequest.php deleted file mode 100644 index d8f51b9e01ad..000000000000 --- a/ManagedIdentities/src/V1beta1/ValidateTrustRequest.php +++ /dev/null @@ -1,116 +0,0 @@ -google.cloud.managedidentities.v1beta1.ValidateTrustRequest - */ -class ValidateTrustRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - /** - * Required. The domain trust to validate trust state for. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $trust = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * @type \Google\Cloud\ManagedIdentities\V1beta1\Trust $trust - * Required. The domain trust to validate trust state for. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Managedidentities\V1Beta1\ManagedIdentitiesService::initOnce(); - parent::__construct($data); - } - - /** - * Required. The resource domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * 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 domain name, project name, and location using the form: - * `projects/{project_id}/locations/global/domains/{domain_name}` - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * Required. The domain trust to validate trust state for. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\ManagedIdentities\V1beta1\Trust|null - */ - public function getTrust() - { - return $this->trust; - } - - public function hasTrust() - { - return isset($this->trust); - } - - public function clearTrust() - { - unset($this->trust); - } - - /** - * Required. The domain trust to validate trust state for. - * - * Generated from protobuf field .google.cloud.managedidentities.v1beta1.Trust trust = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\ManagedIdentities\V1beta1\Trust $var - * @return $this - */ - public function setTrust($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\ManagedIdentities\V1beta1\Trust::class); - $this->trust = $var; - - return $this; - } - -} - diff --git a/ManagedIdentities/src/V1beta1/gapic_metadata.json b/ManagedIdentities/src/V1beta1/gapic_metadata.json deleted file mode 100644 index 58b855239516..000000000000 --- a/ManagedIdentities/src/V1beta1/gapic_metadata.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", - "language": "php", - "protoPackage": "google.cloud.managedidentities.v1beta1", - "libraryPackage": "Google\\Cloud\\ManagedIdentities\\V1beta1", - "services": { - "ManagedIdentitiesService": { - "clients": { - "grpc": { - "libraryClient": "ManagedIdentitiesServiceGapicClient", - "rpcs": { - "AttachTrust": { - "methods": [ - "attachTrust" - ] - }, - "CreateMicrosoftAdDomain": { - "methods": [ - "createMicrosoftAdDomain" - ] - }, - "DeleteDomain": { - "methods": [ - "deleteDomain" - ] - }, - "DetachTrust": { - "methods": [ - "detachTrust" - ] - }, - "GetDomain": { - "methods": [ - "getDomain" - ] - }, - "ListDomains": { - "methods": [ - "listDomains" - ] - }, - "ReconfigureTrust": { - "methods": [ - "reconfigureTrust" - ] - }, - "ResetAdminPassword": { - "methods": [ - "resetAdminPassword" - ] - }, - "UpdateDomain": { - "methods": [ - "updateDomain" - ] - }, - "ValidateTrust": { - "methods": [ - "validateTrust" - ] - } - } - } - } - } - } -} \ No newline at end of file diff --git a/ManagedIdentities/src/V1beta1/resources/managed_identities_service_client_config.json b/ManagedIdentities/src/V1beta1/resources/managed_identities_service_client_config.json deleted file mode 100644 index e67132d98d74..000000000000 --- a/ManagedIdentities/src/V1beta1/resources/managed_identities_service_client_config.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "interfaces": { - "google.cloud.managedidentities.v1beta1.ManagedIdentitiesService": { - "retry_codes": { - "no_retry_codes": [] - }, - "retry_params": { - "no_retry_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 0, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 0, - "total_timeout_millis": 0 - } - }, - "methods": { - "AttachTrust": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "CreateMicrosoftAdDomain": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "DeleteDomain": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "DetachTrust": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "GetDomain": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "ListDomains": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "ReconfigureTrust": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "ResetAdminPassword": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "UpdateDomain": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "ValidateTrust": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - } - } - } - } -} diff --git a/ManagedIdentities/src/V1beta1/resources/managed_identities_service_descriptor_config.php b/ManagedIdentities/src/V1beta1/resources/managed_identities_service_descriptor_config.php deleted file mode 100644 index 11dd1b5af54b..000000000000 --- a/ManagedIdentities/src/V1beta1/resources/managed_identities_service_descriptor_config.php +++ /dev/null @@ -1,108 +0,0 @@ - [ - 'google.cloud.managedidentities.v1beta1.ManagedIdentitiesService' => [ - 'AttachTrust' => [ - 'longRunning' => [ - 'operationReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\Domain', - 'metadataReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\OpMetadata', - 'initialPollDelayMillis' => '500', - 'pollDelayMultiplier' => '1.5', - 'maxPollDelayMillis' => '5000', - 'totalPollTimeoutMillis' => '300000', - ], - ], - 'CreateMicrosoftAdDomain' => [ - 'longRunning' => [ - 'operationReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\Domain', - 'metadataReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\OpMetadata', - 'initialPollDelayMillis' => '500', - 'pollDelayMultiplier' => '1.5', - 'maxPollDelayMillis' => '5000', - 'totalPollTimeoutMillis' => '300000', - ], - ], - 'DeleteDomain' => [ - 'longRunning' => [ - 'operationReturnType' => '\Google\Protobuf\GPBEmpty', - 'metadataReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\OpMetadata', - 'initialPollDelayMillis' => '500', - 'pollDelayMultiplier' => '1.5', - 'maxPollDelayMillis' => '5000', - 'totalPollTimeoutMillis' => '300000', - ], - ], - 'DetachTrust' => [ - 'longRunning' => [ - 'operationReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\Domain', - 'metadataReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\OpMetadata', - 'initialPollDelayMillis' => '500', - 'pollDelayMultiplier' => '1.5', - 'maxPollDelayMillis' => '5000', - 'totalPollTimeoutMillis' => '300000', - ], - ], - 'ReconfigureTrust' => [ - 'longRunning' => [ - 'operationReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\Domain', - 'metadataReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\OpMetadata', - 'initialPollDelayMillis' => '500', - 'pollDelayMultiplier' => '1.5', - 'maxPollDelayMillis' => '5000', - 'totalPollTimeoutMillis' => '300000', - ], - ], - 'UpdateDomain' => [ - 'longRunning' => [ - 'operationReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\Domain', - 'metadataReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\OpMetadata', - 'initialPollDelayMillis' => '500', - 'pollDelayMultiplier' => '1.5', - 'maxPollDelayMillis' => '5000', - 'totalPollTimeoutMillis' => '300000', - ], - ], - 'ValidateTrust' => [ - 'longRunning' => [ - 'operationReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\Domain', - 'metadataReturnType' => '\Google\Cloud\ManagedIdentities\V1beta1\OpMetadata', - 'initialPollDelayMillis' => '500', - 'pollDelayMultiplier' => '1.5', - 'maxPollDelayMillis' => '5000', - 'totalPollTimeoutMillis' => '300000', - ], - ], - 'ListDomains' => [ - 'pageStreaming' => [ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getDomains', - ], - ], - ], - ], -]; diff --git a/ManagedIdentities/src/V1beta1/resources/managed_identities_service_rest_client_config.php b/ManagedIdentities/src/V1beta1/resources/managed_identities_service_rest_client_config.php deleted file mode 100644 index 27b32f685b73..000000000000 --- a/ManagedIdentities/src/V1beta1/resources/managed_identities_service_rest_client_config.php +++ /dev/null @@ -1,295 +0,0 @@ - [ - 'google.cloud.location.Locations' => [ - 'GetLocation' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ListLocations' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=projects/*}/locations', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - ], - 'google.cloud.managedidentities.v1beta1.ManagedIdentitiesService' => [ - 'AttachTrust' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/domains/*}:attachTrust', - 'body' => '*', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'CreateMicrosoftAdDomain' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{parent=projects/*/locations/global}/domains', - 'body' => 'domain', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - 'queryParams' => [ - 'domain_name', - ], - ], - 'DeleteDomain' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/domains/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'DetachTrust' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/domains/*}:detachTrust', - 'body' => '*', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'GetDomain' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/domains/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ListDomains' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{parent=projects/*/locations/global}/domains', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'ReconfigureTrust' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/domains/*}:reconfigureTrust', - 'body' => '*', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ResetAdminPassword' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/domains/*}:resetAdminPassword', - 'body' => '*', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'UpdateDomain' => [ - 'method' => 'patch', - 'uriTemplate' => '/v1beta1/{domain.name=projects/*/locations/global/domains/*}', - 'body' => 'domain', - 'placeholders' => [ - 'domain.name' => [ - 'getters' => [ - 'getDomain', - 'getName', - ], - ], - ], - 'queryParams' => [ - 'update_mask', - ], - ], - 'ValidateTrust' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/domains/*}:validateTrust', - 'body' => '*', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - ], - 'google.iam.v1.IAMPolicy' => [ - 'GetIamPolicy' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/domains/*}:getIamPolicy', - 'additionalBindings' => [ - [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/peerings/*}:getIamPolicy', - ], - [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:getIamPolicy', - ], - ], - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - 'SetIamPolicy' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/domains/*}:setIamPolicy', - 'body' => '*', - 'additionalBindings' => [ - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/peerings/*}:setIamPolicy', - 'body' => '*', - ], - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:setIamPolicy', - 'body' => '*', - ], - ], - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - 'TestIamPermissions' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/domains/*}:testIamPermissions', - 'body' => '*', - 'additionalBindings' => [ - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/peerings/*}:testIamPermissions', - 'body' => '*', - ], - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:testIamPermissions', - 'body' => '*', - ], - ], - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - ], - 'google.longrunning.Operations' => [ - 'CancelOperation' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel', - 'body' => '*', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'DeleteOperation' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/operations/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'GetOperation' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/operations/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ListOperations' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/global/operations}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - ], - ], - 'numericEnums' => true, -]; diff --git a/ManagedIdentities/tests/Unit/V1/Client/ManagedIdentitiesServiceClientTest.php b/ManagedIdentities/tests/Unit/V1/Client/ManagedIdentitiesServiceClientTest.php index f4931fbce335..b3926c2b71df 100644 --- a/ManagedIdentities/tests/Unit/V1/Client/ManagedIdentitiesServiceClientTest.php +++ b/ManagedIdentities/tests/Unit/V1/Client/ManagedIdentitiesServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ManagedIdentitiesServiceClient */ @@ -132,9 +134,7 @@ public function attachTrustTest() $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $request = (new AttachTrustRequest()) - ->setName($formattedName) - ->setTrust($trust); + $request = (new AttachTrustRequest())->setName($formattedName)->setTrust($trust); $response = $gapicClient->attachTrust($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -144,7 +144,10 @@ public function attachTrustTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/AttachTrust', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/AttachTrust', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $actualValue = $actualApiRequestObject->getTrust(); @@ -192,12 +195,15 @@ public function attachTrustExceptionTest() $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); + $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); @@ -212,9 +218,7 @@ public function attachTrustExceptionTest() $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $request = (new AttachTrustRequest()) - ->setName($formattedName) - ->setTrust($trust); + $request = (new AttachTrustRequest())->setName($formattedName)->setTrust($trust); $response = $gapicClient->attachTrust($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -299,7 +303,10 @@ public function createMicrosoftAdDomainTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/CreateMicrosoftAdDomain', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/CreateMicrosoftAdDomain', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getDomainName(); @@ -349,12 +356,15 @@ public function createMicrosoftAdDomainExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -423,8 +433,7 @@ public function deleteDomainTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $request = (new DeleteDomainRequest()) - ->setName($formattedName); + $request = (new DeleteDomainRequest())->setName($formattedName); $response = $gapicClient->deleteDomain($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -434,7 +443,10 @@ public function deleteDomainTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/DeleteDomain', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/DeleteDomain', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -480,17 +492,19 @@ public function deleteDomainExceptionTest() $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); + $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $request = (new DeleteDomainRequest()) - ->setName($formattedName); + $request = (new DeleteDomainRequest())->setName($formattedName); $response = $gapicClient->deleteDomain($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -565,9 +579,7 @@ public function detachTrustTest() $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $request = (new DetachTrustRequest()) - ->setName($formattedName) - ->setTrust($trust); + $request = (new DetachTrustRequest())->setName($formattedName)->setTrust($trust); $response = $gapicClient->detachTrust($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -577,7 +589,10 @@ public function detachTrustTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/DetachTrust', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/DetachTrust', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $actualValue = $actualApiRequestObject->getTrust(); @@ -625,12 +640,15 @@ public function detachTrustExceptionTest() $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); + $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); @@ -645,9 +663,7 @@ public function detachTrustExceptionTest() $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $request = (new DetachTrustRequest()) - ->setName($formattedName) - ->setTrust($trust); + $request = (new DetachTrustRequest())->setName($formattedName)->setTrust($trust); $response = $gapicClient->detachTrust($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -693,8 +709,7 @@ public function getDomainTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $request = (new GetDomainRequest()) - ->setName($formattedName); + $request = (new GetDomainRequest())->setName($formattedName); $response = $gapicClient->getDomain($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -718,17 +733,19 @@ public function getDomainExceptionTest() $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); + $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $request = (new GetDomainRequest()) - ->setName($formattedName); + $request = (new GetDomainRequest())->setName($formattedName); try { $gapicClient->getDomain($request); // If the $gapicClient method call did not throw, fail the test @@ -753,17 +770,14 @@ public function listDomainsTest() // Mock response $nextPageToken = ''; $domainsElement = new Domain(); - $domains = [ - $domainsElement, - ]; + $domains = [$domainsElement]; $expectedResponse = new ListDomainsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setDomains($domains); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListDomainsRequest()) - ->setParent($formattedParent); + $request = (new ListDomainsRequest())->setParent($formattedParent); $response = $gapicClient->listDomains($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -790,17 +804,19 @@ public function listDomainsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListDomainsRequest()) - ->setParent($formattedParent); + $request = (new ListDomainsRequest())->setParent($formattedParent); try { $gapicClient->listDomains($request); // If the $gapicClient method call did not throw, fail the test @@ -870,7 +886,10 @@ public function reconfigureTrustTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/ReconfigureTrust', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/ReconfigureTrust', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $actualValue = $actualApiRequestObject->getTargetDomainName(); @@ -920,12 +939,15 @@ public function reconfigureTrustExceptionTest() $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); + $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); @@ -972,15 +994,17 @@ public function resetAdminPasswordTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $request = (new ResetAdminPasswordRequest()) - ->setName($formattedName); + $request = (new ResetAdminPasswordRequest())->setName($formattedName); $response = $gapicClient->resetAdminPassword($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.managedidentities.v1.ManagedIdentitiesService/ResetAdminPassword', $actualFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/ResetAdminPassword', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -997,17 +1021,19 @@ public function resetAdminPasswordExceptionTest() $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); + $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $request = (new ResetAdminPasswordRequest()) - ->setName($formattedName); + $request = (new ResetAdminPasswordRequest())->setName($formattedName); try { $gapicClient->resetAdminPassword($request); // If the $gapicClient method call did not throw, fail the test @@ -1069,9 +1095,7 @@ public function updateDomainTest() $domain->setReservedIpRange($domainReservedIpRange); $domainLocations = []; $domain->setLocations($domainLocations); - $request = (new UpdateDomainRequest()) - ->setUpdateMask($updateMask) - ->setDomain($domain); + $request = (new UpdateDomainRequest())->setUpdateMask($updateMask)->setDomain($domain); $response = $gapicClient->updateDomain($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1081,7 +1105,10 @@ public function updateDomainTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/UpdateDomain', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/UpdateDomain', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getUpdateMask(); $this->assertProtobufEquals($updateMask, $actualValue); $actualValue = $actualApiRequestObject->getDomain(); @@ -1129,12 +1156,15 @@ public function updateDomainExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $updateMask = new FieldMask(); @@ -1145,9 +1175,7 @@ public function updateDomainExceptionTest() $domain->setReservedIpRange($domainReservedIpRange); $domainLocations = []; $domain->setLocations($domainLocations); - $request = (new UpdateDomainRequest()) - ->setUpdateMask($updateMask) - ->setDomain($domain); + $request = (new UpdateDomainRequest())->setUpdateMask($updateMask)->setDomain($domain); $response = $gapicClient->updateDomain($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1222,9 +1250,7 @@ public function validateTrustTest() $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $request = (new ValidateTrustRequest()) - ->setName($formattedName) - ->setTrust($trust); + $request = (new ValidateTrustRequest())->setName($formattedName)->setTrust($trust); $response = $gapicClient->validateTrust($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1234,7 +1260,10 @@ public function validateTrustTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/ValidateTrust', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/ValidateTrust', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $actualValue = $actualApiRequestObject->getTrust(); @@ -1282,12 +1311,15 @@ public function validateTrustExceptionTest() $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); + $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); @@ -1302,9 +1334,7 @@ public function validateTrustExceptionTest() $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $request = (new ValidateTrustRequest()) - ->setName($formattedName) - ->setTrust($trust); + $request = (new ValidateTrustRequest())->setName($formattedName)->setTrust($trust); $response = $gapicClient->validateTrust($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1379,9 +1409,7 @@ public function attachTrustAsyncTest() $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $request = (new AttachTrustRequest()) - ->setName($formattedName) - ->setTrust($trust); + $request = (new AttachTrustRequest())->setName($formattedName)->setTrust($trust); $response = $gapicClient->attachTrustAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1391,7 +1419,10 @@ public function attachTrustAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/AttachTrust', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.managedidentities.v1.ManagedIdentitiesService/AttachTrust', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $actualValue = $actualApiRequestObject->getTrust(); diff --git a/ManagedIdentities/tests/Unit/V1/ManagedIdentitiesServiceClientTest.php b/ManagedIdentities/tests/Unit/V1/ManagedIdentitiesServiceClientTest.php deleted file mode 100644 index c40d06625436..000000000000 --- a/ManagedIdentities/tests/Unit/V1/ManagedIdentitiesServiceClientTest.php +++ /dev/null @@ -1,1263 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ManagedIdentitiesServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ManagedIdentitiesServiceClient($options); - } - - /** @test */ - public function attachTrustTest() - { - $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/attachTrustTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/attachTrustTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $trustTargetDomainName = 'trustTargetDomainName-39985064'; - $trust->setTargetDomainName($trustTargetDomainName); - $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED; - $trust->setTrustType($trustTrustType); - $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED; - $trust->setTrustDirection($trustTrustDirection); - $trustTargetDnsIpAddresses = []; - $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); - $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; - $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $response = $gapicClient->attachTrust($formattedName, $trust); - $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.managedidentities.v1.ManagedIdentitiesService/AttachTrust', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTrust(); - $this->assertProtobufEquals($trust, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/attachTrustTest'); - $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 attachTrustExceptionTest() - { - $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/attachTrustTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $trustTargetDomainName = 'trustTargetDomainName-39985064'; - $trust->setTargetDomainName($trustTargetDomainName); - $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED; - $trust->setTrustType($trustTrustType); - $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED; - $trust->setTrustDirection($trustTrustDirection); - $trustTargetDnsIpAddresses = []; - $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); - $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; - $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $response = $gapicClient->attachTrust($formattedName, $trust); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/attachTrustTest'); - 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 createMicrosoftAdDomainTest() - { - $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/createMicrosoftAdDomainTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createMicrosoftAdDomainTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $domainName = 'domainName104118566'; - $domain = new Domain(); - $domainName = 'domainName-1244085905'; - $domain->setName($domainName); - $domainReservedIpRange = 'domainReservedIpRange1357926058'; - $domain->setReservedIpRange($domainReservedIpRange); - $domainLocations = []; - $domain->setLocations($domainLocations); - $response = $gapicClient->createMicrosoftAdDomain($formattedParent, $domainName, $domain); - $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.managedidentities.v1.ManagedIdentitiesService/CreateMicrosoftAdDomain', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getDomainName(); - $this->assertProtobufEquals($domainName, $actualValue); - $actualValue = $actualApiRequestObject->getDomain(); - $this->assertProtobufEquals($domain, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createMicrosoftAdDomainTest'); - $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 createMicrosoftAdDomainExceptionTest() - { - $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/createMicrosoftAdDomainTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $domainName = 'domainName104118566'; - $domain = new Domain(); - $domainName = 'domainName-1244085905'; - $domain->setName($domainName); - $domainReservedIpRange = 'domainReservedIpRange1357926058'; - $domain->setReservedIpRange($domainReservedIpRange); - $domainLocations = []; - $domain->setLocations($domainLocations); - $response = $gapicClient->createMicrosoftAdDomain($formattedParent, $domainName, $domain); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createMicrosoftAdDomainTest'); - 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 deleteDomainTest() - { - $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/deleteDomainTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteDomainTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $response = $gapicClient->deleteDomain($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.managedidentities.v1.ManagedIdentitiesService/DeleteDomain', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteDomainTest'); - $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 deleteDomainExceptionTest() - { - $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/deleteDomainTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $response = $gapicClient->deleteDomain($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteDomainTest'); - 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 detachTrustTest() - { - $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/detachTrustTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/detachTrustTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $trustTargetDomainName = 'trustTargetDomainName-39985064'; - $trust->setTargetDomainName($trustTargetDomainName); - $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED; - $trust->setTrustType($trustTrustType); - $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED; - $trust->setTrustDirection($trustTrustDirection); - $trustTargetDnsIpAddresses = []; - $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); - $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; - $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $response = $gapicClient->detachTrust($formattedName, $trust); - $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.managedidentities.v1.ManagedIdentitiesService/DetachTrust', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTrust(); - $this->assertProtobufEquals($trust, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/detachTrustTest'); - $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 detachTrustExceptionTest() - { - $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/detachTrustTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $trustTargetDomainName = 'trustTargetDomainName-39985064'; - $trust->setTargetDomainName($trustTargetDomainName); - $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED; - $trust->setTrustType($trustTrustType); - $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED; - $trust->setTrustDirection($trustTrustDirection); - $trustTargetDnsIpAddresses = []; - $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); - $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; - $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $response = $gapicClient->detachTrust($formattedName, $trust); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/detachTrustTest'); - 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 getDomainTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $response = $gapicClient->getDomain($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.managedidentities.v1.ManagedIdentitiesService/GetDomain', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getDomainExceptionTest() - { - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - try { - $gapicClient->getDomain($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 listDomainsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $domainsElement = new Domain(); - $domains = [ - $domainsElement, - ]; - $expectedResponse = new ListDomainsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setDomains($domains); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listDomains($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getDomains()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1.ManagedIdentitiesService/ListDomains', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listDomainsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listDomains($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 reconfigureTrustTest() - { - $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/reconfigureTrustTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/reconfigureTrustTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $targetDomainName = 'targetDomainName1303689080'; - $targetDnsIpAddresses = []; - $response = $gapicClient->reconfigureTrust($formattedName, $targetDomainName, $targetDnsIpAddresses); - $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.managedidentities.v1.ManagedIdentitiesService/ReconfigureTrust', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTargetDomainName(); - $this->assertProtobufEquals($targetDomainName, $actualValue); - $actualValue = $actualApiRequestObject->getTargetDnsIpAddresses(); - $this->assertProtobufEquals($targetDnsIpAddresses, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/reconfigureTrustTest'); - $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 reconfigureTrustExceptionTest() - { - $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/reconfigureTrustTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $targetDomainName = 'targetDomainName1303689080'; - $targetDnsIpAddresses = []; - $response = $gapicClient->reconfigureTrust($formattedName, $targetDomainName, $targetDnsIpAddresses); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/reconfigureTrustTest'); - 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 resetAdminPasswordTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $password = 'password1216985755'; - $expectedResponse = new ResetAdminPasswordResponse(); - $expectedResponse->setPassword($password); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $response = $gapicClient->resetAdminPassword($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.managedidentities.v1.ManagedIdentitiesService/ResetAdminPassword', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function resetAdminPasswordExceptionTest() - { - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - try { - $gapicClient->resetAdminPassword($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 updateDomainTest() - { - $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/updateDomainTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateDomainTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $domain = new Domain(); - $domainName = 'domainName-1244085905'; - $domain->setName($domainName); - $domainReservedIpRange = 'domainReservedIpRange1357926058'; - $domain->setReservedIpRange($domainReservedIpRange); - $domainLocations = []; - $domain->setLocations($domainLocations); - $response = $gapicClient->updateDomain($updateMask, $domain); - $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.managedidentities.v1.ManagedIdentitiesService/UpdateDomain', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getDomain(); - $this->assertProtobufEquals($domain, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateDomainTest'); - $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 updateDomainExceptionTest() - { - $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/updateDomainTest'); - $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 - $updateMask = new FieldMask(); - $domain = new Domain(); - $domainName = 'domainName-1244085905'; - $domain->setName($domainName); - $domainReservedIpRange = 'domainReservedIpRange1357926058'; - $domain->setReservedIpRange($domainReservedIpRange); - $domainLocations = []; - $domain->setLocations($domainLocations); - $response = $gapicClient->updateDomain($updateMask, $domain); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateDomainTest'); - 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 validateTrustTest() - { - $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/validateTrustTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/validateTrustTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $trustTargetDomainName = 'trustTargetDomainName-39985064'; - $trust->setTargetDomainName($trustTargetDomainName); - $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED; - $trust->setTrustType($trustTrustType); - $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED; - $trust->setTrustDirection($trustTrustDirection); - $trustTargetDnsIpAddresses = []; - $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); - $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; - $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $response = $gapicClient->validateTrust($formattedName, $trust); - $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.managedidentities.v1.ManagedIdentitiesService/ValidateTrust', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTrust(); - $this->assertProtobufEquals($trust, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/validateTrustTest'); - $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 validateTrustExceptionTest() - { - $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/validateTrustTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $trustTargetDomainName = 'trustTargetDomainName-39985064'; - $trust->setTargetDomainName($trustTargetDomainName); - $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED; - $trust->setTrustType($trustTrustType); - $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED; - $trust->setTrustDirection($trustTrustDirection); - $trustTargetDnsIpAddresses = []; - $trust->setTargetDnsIpAddresses($trustTargetDnsIpAddresses); - $trustTrustHandshakeSecret = 'trustTrustHandshakeSecret-1896647033'; - $trust->setTrustHandshakeSecret($trustTrustHandshakeSecret); - $response = $gapicClient->validateTrust($formattedName, $trust); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/validateTrustTest'); - 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()); - } -} diff --git a/ManagedIdentities/tests/Unit/V1beta1/ManagedIdentitiesServiceClientTest.php b/ManagedIdentities/tests/Unit/V1beta1/ManagedIdentitiesServiceClientTest.php deleted file mode 100644 index 001c6cfea97b..000000000000 --- a/ManagedIdentities/tests/Unit/V1beta1/ManagedIdentitiesServiceClientTest.php +++ /dev/null @@ -1,1193 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ManagedIdentitiesServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ManagedIdentitiesServiceClient($options); - } - - /** @test */ - public function attachTrustTest() - { - $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/attachTrustTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/attachTrustTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $response = $gapicClient->attachTrust($formattedName, $trust); - $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.managedidentities.v1beta1.ManagedIdentitiesService/AttachTrust', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTrust(); - $this->assertProtobufEquals($trust, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/attachTrustTest'); - $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 attachTrustExceptionTest() - { - $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/attachTrustTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $response = $gapicClient->attachTrust($formattedName, $trust); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/attachTrustTest'); - 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 createMicrosoftAdDomainTest() - { - $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/createMicrosoftAdDomainTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createMicrosoftAdDomainTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $domainName = 'domainName104118566'; - $domain = new Domain(); - $domainReservedIpRange = 'domainReservedIpRange1357926058'; - $domain->setReservedIpRange($domainReservedIpRange); - $domainLocations = []; - $domain->setLocations($domainLocations); - $response = $gapicClient->createMicrosoftAdDomain($formattedParent, $domainName, $domain); - $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.managedidentities.v1beta1.ManagedIdentitiesService/CreateMicrosoftAdDomain', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getDomainName(); - $this->assertProtobufEquals($domainName, $actualValue); - $actualValue = $actualApiRequestObject->getDomain(); - $this->assertProtobufEquals($domain, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createMicrosoftAdDomainTest'); - $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 createMicrosoftAdDomainExceptionTest() - { - $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/createMicrosoftAdDomainTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $domainName = 'domainName104118566'; - $domain = new Domain(); - $domainReservedIpRange = 'domainReservedIpRange1357926058'; - $domain->setReservedIpRange($domainReservedIpRange); - $domainLocations = []; - $domain->setLocations($domainLocations); - $response = $gapicClient->createMicrosoftAdDomain($formattedParent, $domainName, $domain); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createMicrosoftAdDomainTest'); - 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 deleteDomainTest() - { - $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/deleteDomainTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteDomainTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $response = $gapicClient->deleteDomain($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.managedidentities.v1beta1.ManagedIdentitiesService/DeleteDomain', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteDomainTest'); - $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 deleteDomainExceptionTest() - { - $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/deleteDomainTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $response = $gapicClient->deleteDomain($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteDomainTest'); - 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 detachTrustTest() - { - $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/detachTrustTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/detachTrustTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $response = $gapicClient->detachTrust($formattedName, $trust); - $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.managedidentities.v1beta1.ManagedIdentitiesService/DetachTrust', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTrust(); - $this->assertProtobufEquals($trust, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/detachTrustTest'); - $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 detachTrustExceptionTest() - { - $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/detachTrustTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $response = $gapicClient->detachTrust($formattedName, $trust); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/detachTrustTest'); - 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 getDomainTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $response = $gapicClient->getDomain($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.managedidentities.v1beta1.ManagedIdentitiesService/GetDomain', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getDomainExceptionTest() - { - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - try { - $gapicClient->getDomain($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 listDomainsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $domainsElement = new Domain(); - $domains = [ - $domainsElement, - ]; - $expectedResponse = new ListDomainsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setDomains($domains); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listDomains($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getDomains()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.managedidentities.v1beta1.ManagedIdentitiesService/ListDomains', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listDomainsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listDomains($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 reconfigureTrustTest() - { - $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/reconfigureTrustTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/reconfigureTrustTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $targetDomainName = 'targetDomainName1303689080'; - $targetDnsIpAddresses = []; - $response = $gapicClient->reconfigureTrust($formattedName, $targetDomainName, $targetDnsIpAddresses); - $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.managedidentities.v1beta1.ManagedIdentitiesService/ReconfigureTrust', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTargetDomainName(); - $this->assertProtobufEquals($targetDomainName, $actualValue); - $actualValue = $actualApiRequestObject->getTargetDnsIpAddresses(); - $this->assertProtobufEquals($targetDnsIpAddresses, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/reconfigureTrustTest'); - $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 reconfigureTrustExceptionTest() - { - $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/reconfigureTrustTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $targetDomainName = 'targetDomainName1303689080'; - $targetDnsIpAddresses = []; - $response = $gapicClient->reconfigureTrust($formattedName, $targetDomainName, $targetDnsIpAddresses); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/reconfigureTrustTest'); - 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 resetAdminPasswordTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $password = 'password1216985755'; - $expectedResponse = new ResetAdminPasswordResponse(); - $expectedResponse->setPassword($password); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $response = $gapicClient->resetAdminPassword($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.managedidentities.v1beta1.ManagedIdentitiesService/ResetAdminPassword', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function resetAdminPasswordExceptionTest() - { - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - try { - $gapicClient->resetAdminPassword($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 updateDomainTest() - { - $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/updateDomainTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateDomainTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $domain = new Domain(); - $domainReservedIpRange = 'domainReservedIpRange1357926058'; - $domain->setReservedIpRange($domainReservedIpRange); - $domainLocations = []; - $domain->setLocations($domainLocations); - $response = $gapicClient->updateDomain($updateMask, $domain); - $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.managedidentities.v1beta1.ManagedIdentitiesService/UpdateDomain', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getDomain(); - $this->assertProtobufEquals($domain, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateDomainTest'); - $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 updateDomainExceptionTest() - { - $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/updateDomainTest'); - $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 - $updateMask = new FieldMask(); - $domain = new Domain(); - $domainReservedIpRange = 'domainReservedIpRange1357926058'; - $domain->setReservedIpRange($domainReservedIpRange); - $domainLocations = []; - $domain->setLocations($domainLocations); - $response = $gapicClient->updateDomain($updateMask, $domain); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateDomainTest'); - 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 validateTrustTest() - { - $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/validateTrustTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $reservedIpRange = 'reservedIpRange-1082940580'; - $admin = 'admin92668751'; - $fqdn = 'fqdn3150485'; - $statusMessage = 'statusMessage-239442758'; - $expectedResponse = new Domain(); - $expectedResponse->setName($name2); - $expectedResponse->setReservedIpRange($reservedIpRange); - $expectedResponse->setAdmin($admin); - $expectedResponse->setFqdn($fqdn); - $expectedResponse->setStatusMessage($statusMessage); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/validateTrustTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $response = $gapicClient->validateTrust($formattedName, $trust); - $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.managedidentities.v1beta1.ManagedIdentitiesService/ValidateTrust', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getTrust(); - $this->assertProtobufEquals($trust, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/validateTrustTest'); - $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 validateTrustExceptionTest() - { - $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/validateTrustTest'); - $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->domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]'); - $trust = new Trust(); - $response = $gapicClient->validateTrust($formattedName, $trust); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/validateTrustTest'); - 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()); - } -} diff --git a/NetworkConnectivity/owlbot.py b/NetworkConnectivity/owlbot.py index baac27b85273..424cd9ba8e60 100644 --- a/NetworkConnectivity/owlbot.py +++ b/NetworkConnectivity/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,32 +41,6 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - # format generated clients subprocess.run([ 'npm', @@ -82,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/NetworkConnectivity/src/V1/AcceptHubSpokeRequest.php b/NetworkConnectivity/src/V1/AcceptHubSpokeRequest.php index 3850ae130f62..37b9e0f97d23 100644 --- a/NetworkConnectivity/src/V1/AcceptHubSpokeRequest.php +++ b/NetworkConnectivity/src/V1/AcceptHubSpokeRequest.php @@ -21,13 +21,13 @@ class AcceptHubSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The URI of the spoke to accept into the hub. * * Generated from protobuf field string spoke_uri = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $spoke_uri = ''; + protected $spoke_uri = ''; /** * Optional. A request ID to identify requests. Specify a unique request ID so * that if you must retry your request, the server knows to ignore the request @@ -44,7 +44,7 @@ class AcceptHubSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $name Required. The name of the hub into which to accept the spoke. Please see diff --git a/NetworkConnectivity/src/V1/AcceptHubSpokeResponse.php b/NetworkConnectivity/src/V1/AcceptHubSpokeResponse.php index 36a4ef91813d..48fe6468b2b9 100644 --- a/NetworkConnectivity/src/V1/AcceptHubSpokeResponse.php +++ b/NetworkConnectivity/src/V1/AcceptHubSpokeResponse.php @@ -21,7 +21,7 @@ class AcceptHubSpokeResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.Spoke spoke = 1; */ - private $spoke = null; + protected $spoke = null; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/Client/HubServiceClient.php b/NetworkConnectivity/src/V1/Client/HubServiceClient.php index 6a1afa145204..62a6bcebed19 100644 --- a/NetworkConnectivity/src/V1/Client/HubServiceClient.php +++ b/NetworkConnectivity/src/V1/Client/HubServiceClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a group * resource. @@ -1116,8 +1135,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + 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 f57d13fed6dd..0fbdaef55f8f 100644 --- a/NetworkConnectivity/src/V1/Client/PolicyBasedRoutingServiceClient.php +++ b/NetworkConnectivity/src/V1/Client/PolicyBasedRoutingServiceClient.php @@ -1,6 +1,6 @@ [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/policy_based_routing_service_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/policy_based_routing_service_rest_client_config.php', ], ], ]; @@ -146,12 +145,33 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a location * resource. @@ -323,8 +343,10 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createPolicyBasedRoute(CreatePolicyBasedRouteRequest $request, array $callOptions = []): OperationResponse - { + public function createPolicyBasedRoute( + CreatePolicyBasedRouteRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CreatePolicyBasedRoute', $request, $callOptions)->wait(); } @@ -350,8 +372,10 @@ public function createPolicyBasedRoute(CreatePolicyBasedRouteRequest $request, a * * @throws ApiException Thrown if the API call fails. */ - public function deletePolicyBasedRoute(DeletePolicyBasedRouteRequest $request, array $callOptions = []): OperationResponse - { + public function deletePolicyBasedRoute( + DeletePolicyBasedRouteRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('DeletePolicyBasedRoute', $request, $callOptions)->wait(); } @@ -404,8 +428,10 @@ public function getPolicyBasedRoute(GetPolicyBasedRouteRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function listPolicyBasedRoutes(ListPolicyBasedRoutesRequest $request, array $callOptions = []): PagedListResponse - { + public function listPolicyBasedRoutes( + ListPolicyBasedRoutesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListPolicyBasedRoutes', $request, $callOptions); } @@ -550,8 +576,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/NetworkConnectivity/src/V1/CreateHubRequest.php b/NetworkConnectivity/src/V1/CreateHubRequest.php index 288986a42256..94e90f9d1b6c 100644 --- a/NetworkConnectivity/src/V1/CreateHubRequest.php +++ b/NetworkConnectivity/src/V1/CreateHubRequest.php @@ -22,19 +22,19 @@ class CreateHubRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. A unique identifier for the hub. * * Generated from protobuf field string hub_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $hub_id = ''; + protected $hub_id = ''; /** * Required. The initial values for a new hub. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.Hub hub = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $hub = null; + protected $hub = null; /** * Optional. A request ID to identify requests. Specify a unique request ID so * that if you must retry your request, the server knows to ignore the request @@ -51,7 +51,7 @@ class CreateHubRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $parent Required. The parent resource. Please see diff --git a/NetworkConnectivity/src/V1/CreatePolicyBasedRouteRequest.php b/NetworkConnectivity/src/V1/CreatePolicyBasedRouteRequest.php index 2adde859148f..39cc389b0596 100644 --- a/NetworkConnectivity/src/V1/CreatePolicyBasedRouteRequest.php +++ b/NetworkConnectivity/src/V1/CreatePolicyBasedRouteRequest.php @@ -20,19 +20,19 @@ class CreatePolicyBasedRouteRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. Unique id for the Policy Based Route to create. * * Generated from protobuf field string policy_based_route_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $policy_based_route_id = ''; + protected $policy_based_route_id = ''; /** * Required. Initial values for a new Policy Based Route. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.PolicyBasedRoute policy_based_route = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $policy_based_route = null; + protected $policy_based_route = null; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID so that if you must retry your request, the server will know to @@ -48,7 +48,7 @@ class CreatePolicyBasedRouteRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $parent Required. The parent resource's name of the PolicyBasedRoute. Please see diff --git a/NetworkConnectivity/src/V1/CreateSpokeRequest.php b/NetworkConnectivity/src/V1/CreateSpokeRequest.php index 490ae19ddde1..ac28e3725546 100644 --- a/NetworkConnectivity/src/V1/CreateSpokeRequest.php +++ b/NetworkConnectivity/src/V1/CreateSpokeRequest.php @@ -21,19 +21,19 @@ class CreateSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. Unique id for the spoke to create. * * Generated from protobuf field string spoke_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $spoke_id = ''; + protected $spoke_id = ''; /** * Required. The initial values for a new spoke. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.Spoke spoke = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $spoke = null; + protected $spoke = null; /** * Optional. A request ID to identify requests. Specify a unique request ID so * that if you must retry your request, the server knows to ignore the request @@ -50,7 +50,7 @@ class CreateSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $parent Required. The parent resource. Please see diff --git a/NetworkConnectivity/src/V1/DeleteHubRequest.php b/NetworkConnectivity/src/V1/DeleteHubRequest.php index ade05aaf6c8b..c9c7d31d1486 100644 --- a/NetworkConnectivity/src/V1/DeleteHubRequest.php +++ b/NetworkConnectivity/src/V1/DeleteHubRequest.php @@ -21,7 +21,7 @@ class DeleteHubRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. A request ID to identify requests. Specify a unique request ID so * that if you must retry your request, the server knows to ignore the request @@ -38,7 +38,7 @@ class DeleteHubRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $name Required. The name of the hub to delete. Please see diff --git a/NetworkConnectivity/src/V1/DeletePolicyBasedRouteRequest.php b/NetworkConnectivity/src/V1/DeletePolicyBasedRouteRequest.php index 0d2da7cf28ef..ee4a3805d495 100644 --- a/NetworkConnectivity/src/V1/DeletePolicyBasedRouteRequest.php +++ b/NetworkConnectivity/src/V1/DeletePolicyBasedRouteRequest.php @@ -20,7 +20,7 @@ class DeletePolicyBasedRouteRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID so that if you must retry your request, the server will know to @@ -36,7 +36,7 @@ class DeletePolicyBasedRouteRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $name Required. Name of the PolicyBasedRoute resource to delete. Please see diff --git a/NetworkConnectivity/src/V1/DeleteSpokeRequest.php b/NetworkConnectivity/src/V1/DeleteSpokeRequest.php index 9a7bc8a02e68..647e4efa1128 100644 --- a/NetworkConnectivity/src/V1/DeleteSpokeRequest.php +++ b/NetworkConnectivity/src/V1/DeleteSpokeRequest.php @@ -21,7 +21,7 @@ class DeleteSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. A request ID to identify requests. Specify a unique request ID so * that if you must retry your request, the server knows to ignore the request @@ -38,7 +38,7 @@ class DeleteSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param string $name Required. The name of the spoke to delete. Please see diff --git a/NetworkConnectivity/src/V1/Gapic/HubServiceGapicClient.php b/NetworkConnectivity/src/V1/Gapic/HubServiceGapicClient.php deleted file mode 100644 index 2a74c37d48d0..000000000000 --- a/NetworkConnectivity/src/V1/Gapic/HubServiceGapicClient.php +++ /dev/null @@ -1,2598 +0,0 @@ -hubName('[PROJECT]', '[HUB]'); - * $formattedSpokeUri = $hubServiceClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - * $operationResponse = $hubServiceClient->acceptHubSpoke($formattedName, $formattedSpokeUri); - * $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 = $hubServiceClient->acceptHubSpoke($formattedName, $formattedSpokeUri); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'acceptHubSpoke'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\NetworkConnectivity\V1\Client\HubServiceClient}. - */ -class HubServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.networkconnectivity.v1.HubService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'networkconnectivity.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'networkconnectivity.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $groupNameTemplate; - - private static $hubNameTemplate; - - private static $hubRouteNameTemplate; - - private static $instanceNameTemplate; - - private static $interconnectAttachmentNameTemplate; - - private static $locationNameTemplate; - - private static $networkNameTemplate; - - private static $routeTableNameTemplate; - - private static $spokeNameTemplate; - - private static $vpnTunnelNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getGroupNameTemplate() - { - if (self::$groupNameTemplate == null) { - self::$groupNameTemplate = new PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/groups/{group}' - ); - } - - return self::$groupNameTemplate; - } - - private static function getHubNameTemplate() - { - if (self::$hubNameTemplate == null) { - self::$hubNameTemplate = new PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}' - ); - } - - return self::$hubNameTemplate; - } - - private static function getHubRouteNameTemplate() - { - if (self::$hubRouteNameTemplate == null) { - self::$hubRouteNameTemplate = new PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route}' - ); - } - - return self::$hubRouteNameTemplate; - } - - private static function getInstanceNameTemplate() - { - if (self::$instanceNameTemplate == null) { - self::$instanceNameTemplate = new PathTemplate( - 'projects/{project}/zones/{zone}/instances/{instance}' - ); - } - - return self::$instanceNameTemplate; - } - - private static function getInterconnectAttachmentNameTemplate() - { - if (self::$interconnectAttachmentNameTemplate == null) { - self::$interconnectAttachmentNameTemplate = new PathTemplate( - 'projects/{project}/regions/{region}/interconnectAttachments/{resource_id}' - ); - } - - return self::$interconnectAttachmentNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getNetworkNameTemplate() - { - if (self::$networkNameTemplate == null) { - self::$networkNameTemplate = new PathTemplate( - 'projects/{project}/global/networks/{resource_id}' - ); - } - - return self::$networkNameTemplate; - } - - private static function getRouteTableNameTemplate() - { - if (self::$routeTableNameTemplate == null) { - self::$routeTableNameTemplate = new PathTemplate( - 'projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}' - ); - } - - return self::$routeTableNameTemplate; - } - - private static function getSpokeNameTemplate() - { - if (self::$spokeNameTemplate == null) { - self::$spokeNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/spokes/{spoke}' - ); - } - - return self::$spokeNameTemplate; - } - - private static function getVpnTunnelNameTemplate() - { - if (self::$vpnTunnelNameTemplate == null) { - self::$vpnTunnelNameTemplate = new PathTemplate( - 'projects/{project}/regions/{region}/vpnTunnels/{resource_id}' - ); - } - - return self::$vpnTunnelNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'group' => self::getGroupNameTemplate(), - 'hub' => self::getHubNameTemplate(), - 'hubRoute' => self::getHubRouteNameTemplate(), - 'instance' => self::getInstanceNameTemplate(), - 'interconnectAttachment' => self::getInterconnectAttachmentNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'network' => self::getNetworkNameTemplate(), - 'routeTable' => self::getRouteTableNameTemplate(), - 'spoke' => self::getSpokeNameTemplate(), - 'vpnTunnel' => self::getVpnTunnelNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $hub, $group) - { - return self::getGroupNameTemplate()->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($project, $hub) - { - return self::getHubNameTemplate()->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($project, $hub, $routeTable, $route) - { - return self::getHubRouteNameTemplate()->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($project, $zone, $instance) - { - return self::getInstanceNameTemplate()->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( - $project, - $region, - $resourceId - ) { - return self::getInterconnectAttachmentNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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($project, $resourceId) - { - return self::getNetworkNameTemplate()->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($project, $hub, $routeTable) - { - return self::getRouteTableNameTemplate()->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($project, $location, $spoke) - { - return self::getSpokeNameTemplate()->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($project, $region, $resourceId) - { - return self::getVpnTunnelNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Accepts a proposal to attach a Network Connectivity Center spoke - * to a hub. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->hubName('[PROJECT]', '[HUB]'); - * $formattedSpokeUri = $hubServiceClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - * $operationResponse = $hubServiceClient->acceptHubSpoke($formattedName, $formattedSpokeUri); - * $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 = $hubServiceClient->acceptHubSpoke($formattedName, $formattedSpokeUri); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'acceptHubSpoke'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the hub into which to accept the spoke. - * @param string $spokeUri Required. The URI of the spoke to accept into the hub. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 acceptHubSpoke($name, $spokeUri, array $optionalArgs = []) - { - $request = new AcceptHubSpokeRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setSpokeUri($spokeUri); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'AcceptHubSpoke', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Creates a new Network Connectivity Center hub in the specified project. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedParent = $hubServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $hubId = 'hub_id'; - * $hub = new Hub(); - * $operationResponse = $hubServiceClient->createHub($formattedParent, $hubId, $hub); - * $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 = $hubServiceClient->createHub($formattedParent, $hubId, $hub); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'createHub'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource. - * @param string $hubId Required. A unique identifier for the hub. - * @param Hub $hub Required. The initial values for a new hub. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 createHub($parent, $hubId, $hub, array $optionalArgs = []) - { - $request = new CreateHubRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setHubId($hubId); - $request->setHub($hub); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateHub', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Creates a Network Connectivity Center spoke. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedParent = $hubServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $spokeId = 'spoke_id'; - * $spoke = new Spoke(); - * $operationResponse = $hubServiceClient->createSpoke($formattedParent, $spokeId, $spoke); - * $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 = $hubServiceClient->createSpoke($formattedParent, $spokeId, $spoke); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'createSpoke'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource. - * @param string $spokeId Required. Unique id for the spoke to create. - * @param Spoke $spoke Required. The initial values for a new spoke. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 createSpoke( - $parent, - $spokeId, - $spoke, - array $optionalArgs = [] - ) { - $request = new CreateSpokeRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setSpokeId($spokeId); - $request->setSpoke($spoke); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateSpoke', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a Network Connectivity Center hub. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->hubName('[PROJECT]', '[HUB]'); - * $operationResponse = $hubServiceClient->deleteHub($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 = $hubServiceClient->deleteHub($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'deleteHub'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the hub to delete. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deleteHub($name, array $optionalArgs = []) - { - $request = new DeleteHubRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteHub', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a Network Connectivity Center spoke. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - * $operationResponse = $hubServiceClient->deleteSpoke($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 = $hubServiceClient->deleteSpoke($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'deleteSpoke'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the spoke to delete. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deleteSpoke($name, array $optionalArgs = []) - { - $request = new DeleteSpokeRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteSpoke', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets details about a Network Connectivity Center group. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->groupName('[PROJECT]', '[HUB]', '[GROUP]'); - * $response = $hubServiceClient->getGroup($formattedName); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the route table resource. - * @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\NetworkConnectivity\V1\Group - * - * @throws ApiException if the remote call fails - */ - public function getGroup($name, array $optionalArgs = []) - { - $request = new GetGroupRequest(); - $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( - 'GetGroup', - Group::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets details about a Network Connectivity Center hub. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->hubName('[PROJECT]', '[HUB]'); - * $response = $hubServiceClient->getHub($formattedName); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the hub resource to get. - * @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\NetworkConnectivity\V1\Hub - * - * @throws ApiException if the remote call fails - */ - public function getHub($name, array $optionalArgs = []) - { - $request = new GetHubRequest(); - $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( - 'GetHub', - Hub::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets details about the specified route. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->hubRouteName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]', '[ROUTE]'); - * $response = $hubServiceClient->getRoute($formattedName); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the route resource. - * @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\NetworkConnectivity\V1\Route - * - * @throws ApiException if the remote call fails - */ - public function getRoute($name, array $optionalArgs = []) - { - $request = new GetRouteRequest(); - $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( - 'GetRoute', - Route::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets details about a Network Connectivity Center route table. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - * $response = $hubServiceClient->getRouteTable($formattedName); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the route table resource. - * @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\NetworkConnectivity\V1\RouteTable - * - * @throws ApiException if the remote call fails - */ - public function getRouteTable($name, array $optionalArgs = []) - { - $request = new GetRouteTableRequest(); - $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( - 'GetRouteTable', - RouteTable::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets details about a Network Connectivity Center spoke. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - * $response = $hubServiceClient->getSpoke($formattedName); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the spoke resource. - * @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\NetworkConnectivity\V1\Spoke - * - * @throws ApiException if the remote call fails - */ - public function getSpoke($name, array $optionalArgs = []) - { - $request = new GetSpokeRequest(); - $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( - 'GetSpoke', - Spoke::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists groups in a given hub. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedParent = $hubServiceClient->hubName('[PROJECT]', '[HUB]'); - * // Iterate over pages of elements - * $pagedResponse = $hubServiceClient->listGroups($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $hubServiceClient->listGroups($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource's name. - * @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 string $filter - * An expression that filters the list of results. - * @type string $orderBy - * Sort the results by a certain order. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listGroups($parent, array $optionalArgs = []) - { - $request = new ListGroupsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListGroups', - $optionalArgs, - ListGroupsResponse::class, - $request - ); - } - - /** - * 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. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->hubName('[PROJECT]', '[HUB]'); - * // Iterate over pages of elements - * $pagedResponse = $hubServiceClient->listHubSpokes($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $hubServiceClient->listHubSpokes($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the hub. - * @param array $optionalArgs { - * Optional. - * - * @type string[] $spokeLocations - * A list of locations. - * Specify one of the following: `[global]`, a single region (for - * example, `[us-central1]`), or a combination of - * values (for example, `[global, us-central1, us-west1]`). - * If the spoke_locations field is populated, the list of results - * includes only spokes in the specified location. - * If the spoke_locations field is not populated, the list of results - * includes spokes in all locations. - * @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 string $filter - * An expression that filters the list of results. - * @type string $orderBy - * Sort the results by name or create_time. - * @type int $view - * The view of the spoke to return. - * The view that you use determines which spoke fields are included in the - * response. - * For allowed values, use constants defined on {@see \Google\Cloud\NetworkConnectivity\V1\ListHubSpokesRequest\SpokeView} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listHubSpokes($name, array $optionalArgs = []) - { - $request = new ListHubSpokesRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['spokeLocations'])) { - $request->setSpokeLocations($optionalArgs['spokeLocations']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListHubSpokes', - $optionalArgs, - ListHubSpokesResponse::class, - $request - ); - } - - /** - * Lists the Network Connectivity Center hubs associated with a given project. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedParent = $hubServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $hubServiceClient->listHubs($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $hubServiceClient->listHubs($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource's name. - * @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 string $filter - * An expression that filters the list of results. - * @type string $orderBy - * Sort the results by a certain order. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listHubs($parent, array $optionalArgs = []) - { - $request = new ListHubsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListHubs', - $optionalArgs, - ListHubsResponse::class, - $request - ); - } - - /** - * Lists route tables in a given project. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedParent = $hubServiceClient->hubName('[PROJECT]', '[HUB]'); - * // Iterate over pages of elements - * $pagedResponse = $hubServiceClient->listRouteTables($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $hubServiceClient->listRouteTables($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource's name. - * @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 string $filter - * An expression that filters the list of results. - * @type string $orderBy - * Sort the results by a certain order. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listRouteTables($parent, array $optionalArgs = []) - { - $request = new ListRouteTablesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListRouteTables', - $optionalArgs, - ListRouteTablesResponse::class, - $request - ); - } - - /** - * Lists routes in a given project. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedParent = $hubServiceClient->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - * // Iterate over pages of elements - * $pagedResponse = $hubServiceClient->listRoutes($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $hubServiceClient->listRoutes($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource's name. - * @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 string $filter - * An expression that filters the list of results. - * @type string $orderBy - * Sort the results by a certain order. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listRoutes($parent, array $optionalArgs = []) - { - $request = new ListRoutesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListRoutes', - $optionalArgs, - ListRoutesResponse::class, - $request - ); - } - - /** - * Lists the Network Connectivity Center spokes in a specified project and - * location. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedParent = $hubServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $hubServiceClient->listSpokes($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $hubServiceClient->listSpokes($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource. - * @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 string $filter - * An expression that filters the list of results. - * @type string $orderBy - * Sort the results by a certain order. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listSpokes($parent, array $optionalArgs = []) - { - $request = new ListSpokesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListSpokes', - $optionalArgs, - ListSpokesResponse::class, - $request - ); - } - - /** - * 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. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $formattedName = $hubServiceClient->hubName('[PROJECT]', '[HUB]'); - * $formattedSpokeUri = $hubServiceClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - * $operationResponse = $hubServiceClient->rejectHubSpoke($formattedName, $formattedSpokeUri); - * $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 = $hubServiceClient->rejectHubSpoke($formattedName, $formattedSpokeUri); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'rejectHubSpoke'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the hub from which to reject the spoke. - * @param string $spokeUri Required. The URI of the spoke to reject from the hub. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type string $details - * Optional. Additional information provided by the hub administrator. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 rejectHubSpoke($name, $spokeUri, array $optionalArgs = []) - { - $request = new RejectHubSpokeRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setSpokeUri($spokeUri); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['details'])) { - $request->setDetails($optionalArgs['details']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'RejectHubSpoke', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Updates the description and/or labels of a Network Connectivity Center - * hub. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $hub = new Hub(); - * $operationResponse = $hubServiceClient->updateHub($hub); - * $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 = $hubServiceClient->updateHub($hub); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'updateHub'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param Hub $hub Required. The state that the hub should be in after the update. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Optional. In the case of an update to an existing hub, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @type string $requestId - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 updateHub($hub, array $optionalArgs = []) - { - $request = new UpdateHubRequest(); - $requestParamHeaders = []; - $request->setHub($hub); - $requestParamHeaders['hub.name'] = $hub->getName(); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateHub', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Updates the parameters of a Network Connectivity Center spoke. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $spoke = new Spoke(); - * $operationResponse = $hubServiceClient->updateSpoke($spoke); - * $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 = $hubServiceClient->updateSpoke($spoke); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $hubServiceClient->resumeOperation($operationName, 'updateSpoke'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param Spoke $spoke Required. The state that the spoke should be in after the update. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Optional. In the case of an update to an existing spoke, field mask is used - * to specify the fields to be overwritten. The fields specified in the - * update_mask are relative to the resource, not the full request. A field is - * overwritten if it is in the mask. If the user does not provide a mask, then - * all fields are overwritten. - * @type string $requestId - * Optional. A request ID to identify requests. Specify a unique request ID so - * that if you must retry your request, the server knows to ignore the request - * if it has already been completed. The server guarantees that a request - * doesn't result in creation of duplicate commitments for at least 60 - * minutes. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check to see whether the original operation - * was received. If it was, the server ignores the second request. This - * behavior prevents clients from mistakenly creating duplicate commitments. - * - * The request ID must be a valid UUID, with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 updateSpoke($spoke, array $optionalArgs = []) - { - $request = new UpdateSpokeRequest(); - $requestParamHeaders = []; - $request->setSpoke($spoke); - $requestParamHeaders['spoke.name'] = $spoke->getName(); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateSpoke', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $response = $hubServiceClient->getLocation(); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $hubServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $hubServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * 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 RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $resource = 'resource'; - * $response = $hubServiceClient->getIamPolicy($resource); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $hubServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->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. - * - * Sample code: - * ``` - * $hubServiceClient = new HubServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $hubServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $hubServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/NetworkConnectivity/src/V1/Gapic/PolicyBasedRoutingServiceGapicClient.php b/NetworkConnectivity/src/V1/Gapic/PolicyBasedRoutingServiceGapicClient.php deleted file mode 100644 index 80583f1fdbe7..000000000000 --- a/NetworkConnectivity/src/V1/Gapic/PolicyBasedRoutingServiceGapicClient.php +++ /dev/null @@ -1,1077 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $policyBasedRouteId = 'policy_based_route_id'; - * $policyBasedRoute = new PolicyBasedRoute(); - * $operationResponse = $policyBasedRoutingServiceClient->createPolicyBasedRoute($formattedParent, $policyBasedRouteId, $policyBasedRoute); - * $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 = $policyBasedRoutingServiceClient->createPolicyBasedRoute($formattedParent, $policyBasedRouteId, $policyBasedRoute); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $policyBasedRoutingServiceClient->resumeOperation($operationName, 'createPolicyBasedRoute'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $policyBasedRoutingServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\NetworkConnectivity\V1\Client\PolicyBasedRoutingServiceClient}. - */ -class PolicyBasedRoutingServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.networkconnectivity.v1.PolicyBasedRoutingService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'networkconnectivity.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'networkconnectivity.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $locationNameTemplate; - - private static $networkNameTemplate; - - private static $policyBasedRouteNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getNetworkNameTemplate() - { - if (self::$networkNameTemplate == null) { - self::$networkNameTemplate = new PathTemplate( - 'projects/{project}/global/networks/{resource_id}' - ); - } - - return self::$networkNameTemplate; - } - - private static function getPolicyBasedRouteNameTemplate() - { - if (self::$policyBasedRouteNameTemplate == null) { - self::$policyBasedRouteNameTemplate = new PathTemplate( - 'projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route}' - ); - } - - return self::$policyBasedRouteNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'location' => self::getLocationNameTemplate(), - 'network' => self::getNetworkNameTemplate(), - 'policyBasedRoute' => self::getPolicyBasedRouteNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location) - { - return self::getLocationNameTemplate()->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($project, $resourceId) - { - return self::getNetworkNameTemplate()->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($project, $policyBasedRoute) - { - return self::getPolicyBasedRouteNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Creates a new PolicyBasedRoute in a given project and location. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * $formattedParent = $policyBasedRoutingServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $policyBasedRouteId = 'policy_based_route_id'; - * $policyBasedRoute = new PolicyBasedRoute(); - * $operationResponse = $policyBasedRoutingServiceClient->createPolicyBasedRoute($formattedParent, $policyBasedRouteId, $policyBasedRoute); - * $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 = $policyBasedRoutingServiceClient->createPolicyBasedRoute($formattedParent, $policyBasedRouteId, $policyBasedRoute); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $policyBasedRoutingServiceClient->resumeOperation($operationName, 'createPolicyBasedRoute'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource's name of the PolicyBasedRoute. - * @param string $policyBasedRouteId Required. Unique id for the Policy Based Route to create. - * @param PolicyBasedRoute $policyBasedRoute Required. Initial values for a new Policy Based Route. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 createPolicyBasedRoute( - $parent, - $policyBasedRouteId, - $policyBasedRoute, - array $optionalArgs = [] - ) { - $request = new CreatePolicyBasedRouteRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setPolicyBasedRouteId($policyBasedRouteId); - $request->setPolicyBasedRoute($policyBasedRoute); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreatePolicyBasedRoute', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a single PolicyBasedRoute. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * $formattedName = $policyBasedRoutingServiceClient->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - * $operationResponse = $policyBasedRoutingServiceClient->deletePolicyBasedRoute($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 = $policyBasedRoutingServiceClient->deletePolicyBasedRoute($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $policyBasedRoutingServiceClient->resumeOperation($operationName, 'deletePolicyBasedRoute'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the PolicyBasedRoute resource to delete. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deletePolicyBasedRoute($name, array $optionalArgs = []) - { - $request = new DeletePolicyBasedRouteRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeletePolicyBasedRoute', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets details of a single PolicyBasedRoute. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * $formattedName = $policyBasedRoutingServiceClient->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - * $response = $policyBasedRoutingServiceClient->getPolicyBasedRoute($formattedName); - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the PolicyBasedRoute resource to get. - * @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\NetworkConnectivity\V1\PolicyBasedRoute - * - * @throws ApiException if the remote call fails - */ - public function getPolicyBasedRoute($name, array $optionalArgs = []) - { - $request = new GetPolicyBasedRouteRequest(); - $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( - 'GetPolicyBasedRoute', - PolicyBasedRoute::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists PolicyBasedRoutes in a given project and location. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * $formattedParent = $policyBasedRoutingServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $policyBasedRoutingServiceClient->listPolicyBasedRoutes($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $policyBasedRoutingServiceClient->listPolicyBasedRoutes($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource's name. - * @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 string $filter - * A filter expression that filters the results listed in the response. - * @type string $orderBy - * Sort the results by a certain order. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listPolicyBasedRoutes($parent, array $optionalArgs = []) - { - $request = new ListPolicyBasedRoutesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListPolicyBasedRoutes', - $optionalArgs, - ListPolicyBasedRoutesResponse::class, - $request - ); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * $response = $policyBasedRoutingServiceClient->getLocation(); - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $policyBasedRoutingServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $policyBasedRoutingServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * 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 RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * $resource = 'resource'; - * $response = $policyBasedRoutingServiceClient->getIamPolicy($resource); - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $policyBasedRoutingServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->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. - * - * Sample code: - * ``` - * $policyBasedRoutingServiceClient = new PolicyBasedRoutingServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $policyBasedRoutingServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $policyBasedRoutingServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/NetworkConnectivity/src/V1/GetGroupRequest.php b/NetworkConnectivity/src/V1/GetGroupRequest.php index 68c84dd17bcc..b81f16b129b7 100644 --- a/NetworkConnectivity/src/V1/GetGroupRequest.php +++ b/NetworkConnectivity/src/V1/GetGroupRequest.php @@ -21,7 +21,7 @@ class GetGroupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the route table resource. Please see diff --git a/NetworkConnectivity/src/V1/GetHubRequest.php b/NetworkConnectivity/src/V1/GetHubRequest.php index 798736f695ab..71dba213b11a 100644 --- a/NetworkConnectivity/src/V1/GetHubRequest.php +++ b/NetworkConnectivity/src/V1/GetHubRequest.php @@ -22,7 +22,7 @@ class GetHubRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the hub resource to get. Please see diff --git a/NetworkConnectivity/src/V1/GetPolicyBasedRouteRequest.php b/NetworkConnectivity/src/V1/GetPolicyBasedRouteRequest.php index f1ed3eef36bb..c86de4e35afd 100644 --- a/NetworkConnectivity/src/V1/GetPolicyBasedRouteRequest.php +++ b/NetworkConnectivity/src/V1/GetPolicyBasedRouteRequest.php @@ -20,7 +20,7 @@ class GetPolicyBasedRouteRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the PolicyBasedRoute resource to get. Please see diff --git a/NetworkConnectivity/src/V1/GetRouteRequest.php b/NetworkConnectivity/src/V1/GetRouteRequest.php index b1091c2ebbec..beaedda82648 100644 --- a/NetworkConnectivity/src/V1/GetRouteRequest.php +++ b/NetworkConnectivity/src/V1/GetRouteRequest.php @@ -21,7 +21,7 @@ class GetRouteRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the route resource. Please see diff --git a/NetworkConnectivity/src/V1/GetRouteTableRequest.php b/NetworkConnectivity/src/V1/GetRouteTableRequest.php index 5cf8016c35d8..bea2175034fb 100644 --- a/NetworkConnectivity/src/V1/GetRouteTableRequest.php +++ b/NetworkConnectivity/src/V1/GetRouteTableRequest.php @@ -21,7 +21,7 @@ class GetRouteTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the route table resource. Please see diff --git a/NetworkConnectivity/src/V1/GetSpokeRequest.php b/NetworkConnectivity/src/V1/GetSpokeRequest.php index 7b4e5b1c3548..bd9bbd634b42 100644 --- a/NetworkConnectivity/src/V1/GetSpokeRequest.php +++ b/NetworkConnectivity/src/V1/GetSpokeRequest.php @@ -21,7 +21,7 @@ class GetSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The name of the spoke resource. Please see diff --git a/NetworkConnectivity/src/V1/Group.php b/NetworkConnectivity/src/V1/Group.php index 6b65a9a62552..713dd8b97f97 100644 --- a/NetworkConnectivity/src/V1/Group.php +++ b/NetworkConnectivity/src/V1/Group.php @@ -22,19 +22,19 @@ class Group extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. The time the group was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the group was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional. Labels in key-value pair format. For more information about * labels, see [Requirements for @@ -48,7 +48,7 @@ class Group extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $description = ''; + protected $description = ''; /** * Output only. The Google-generated UUID for the group. This value is unique * across all group resources. If a group is deleted and @@ -57,13 +57,13 @@ class Group extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uid = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Output only. The current lifecycle state of this group. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/Hub.php b/NetworkConnectivity/src/V1/Hub.php index a5415014c55a..41a7c3370bb7 100644 --- a/NetworkConnectivity/src/V1/Hub.php +++ b/NetworkConnectivity/src/V1/Hub.php @@ -27,19 +27,19 @@ class Hub extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. The time the hub was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the hub was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional labels in key-value pair format. For more information about * labels, see [Requirements for @@ -53,7 +53,7 @@ class Hub extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 5; */ - private $description = ''; + protected $description = ''; /** * Output only. The Google-generated UUID for the hub. This value is unique * across all hub resources. If a hub is deleted and another with the same @@ -61,13 +61,13 @@ class Hub extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string unique_id = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $unique_id = ''; + protected $unique_id = ''; /** * Output only. The current lifecycle state of this hub. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.State state = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * The VPC networks associated with this hub's spokes. * This field is read-only. Network Connectivity Center automatically @@ -95,7 +95,7 @@ class Hub extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.SpokeSummary spoke_summary = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $spoke_summary = null; + protected $spoke_summary = null; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/HubServiceClient.php b/NetworkConnectivity/src/V1/HubServiceClient.php deleted file mode 100644 index ef78fd76e129..000000000000 --- a/NetworkConnectivity/src/V1/HubServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -bool site_to_site_data_transfer = 2; */ - private $site_to_site_data_transfer = false; + protected $site_to_site_data_transfer = false; /** * Output only. The VPC network where these VLAN attachments are located. * * Generated from protobuf field string vpc_network = 3 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $vpc_network = ''; + protected $vpc_network = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/LinkedRouterApplianceInstances.php b/NetworkConnectivity/src/V1/LinkedRouterApplianceInstances.php index c4359aa3fdcb..83e8f7dcbda6 100644 --- a/NetworkConnectivity/src/V1/LinkedRouterApplianceInstances.php +++ b/NetworkConnectivity/src/V1/LinkedRouterApplianceInstances.php @@ -31,14 +31,14 @@ class LinkedRouterApplianceInstances extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool site_to_site_data_transfer = 2; */ - private $site_to_site_data_transfer = false; + protected $site_to_site_data_transfer = false; /** * Output only. The VPC network where these router appliance instances are * located. * * Generated from protobuf field string vpc_network = 3 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $vpc_network = ''; + protected $vpc_network = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/LinkedVpcNetwork.php b/NetworkConnectivity/src/V1/LinkedVpcNetwork.php index 6854dd6a8572..846c9fec8a87 100644 --- a/NetworkConnectivity/src/V1/LinkedVpcNetwork.php +++ b/NetworkConnectivity/src/V1/LinkedVpcNetwork.php @@ -20,7 +20,7 @@ class LinkedVpcNetwork extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uri = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $uri = ''; + protected $uri = ''; /** * Optional. IP ranges encompassing the subnets to be excluded from peering. * diff --git a/NetworkConnectivity/src/V1/LinkedVpnTunnels.php b/NetworkConnectivity/src/V1/LinkedVpnTunnels.php index f6d0f5e018d9..be611474650e 100644 --- a/NetworkConnectivity/src/V1/LinkedVpnTunnels.php +++ b/NetworkConnectivity/src/V1/LinkedVpnTunnels.php @@ -31,13 +31,13 @@ class LinkedVpnTunnels extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool site_to_site_data_transfer = 2; */ - private $site_to_site_data_transfer = false; + protected $site_to_site_data_transfer = false; /** * Output only. The VPC network where these VPN tunnels are located. * * Generated from protobuf field string vpc_network = 3 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $vpc_network = ''; + protected $vpc_network = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/ListGroupsRequest.php b/NetworkConnectivity/src/V1/ListGroupsRequest.php index abf131f2b3b3..085e83e39803 100644 --- a/NetworkConnectivity/src/V1/ListGroupsRequest.php +++ b/NetworkConnectivity/src/V1/ListGroupsRequest.php @@ -22,31 +22,31 @@ class ListGroupsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of results to return per page. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * An expression that filters the list of results. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Sort the results by a certain order. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent resource's name. Please see diff --git a/NetworkConnectivity/src/V1/ListGroupsResponse.php b/NetworkConnectivity/src/V1/ListGroupsResponse.php index c9965baeb157..46f49f57e807 100644 --- a/NetworkConnectivity/src/V1/ListGroupsResponse.php +++ b/NetworkConnectivity/src/V1/ListGroupsResponse.php @@ -30,7 +30,7 @@ class ListGroupsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Hubs that could not be reached. * diff --git a/NetworkConnectivity/src/V1/ListHubSpokesRequest.php b/NetworkConnectivity/src/V1/ListHubSpokesRequest.php index 751504e80282..62c06d3b7a07 100644 --- a/NetworkConnectivity/src/V1/ListHubSpokesRequest.php +++ b/NetworkConnectivity/src/V1/ListHubSpokesRequest.php @@ -21,7 +21,7 @@ class ListHubSpokesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * A list of locations. * Specify one of the following: `[global]`, a single region (for @@ -40,25 +40,25 @@ class ListHubSpokesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 3; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token. * * Generated from protobuf field string page_token = 4; */ - private $page_token = ''; + protected $page_token = ''; /** * An expression that filters the list of results. * * Generated from protobuf field string filter = 5; */ - private $filter = ''; + protected $filter = ''; /** * Sort the results by name or create_time. * * Generated from protobuf field string order_by = 6; */ - private $order_by = ''; + protected $order_by = ''; /** * The view of the spoke to return. * The view that you use determines which spoke fields are included in the @@ -66,7 +66,7 @@ class ListHubSpokesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.ListHubSpokesRequest.SpokeView view = 7; */ - private $view = 0; + protected $view = 0; /** * @param string $name Required. The name of the hub. Please see diff --git a/NetworkConnectivity/src/V1/ListHubSpokesResponse.php b/NetworkConnectivity/src/V1/ListHubSpokesResponse.php index 318b5575a542..0cfab298026e 100644 --- a/NetworkConnectivity/src/V1/ListHubSpokesResponse.php +++ b/NetworkConnectivity/src/V1/ListHubSpokesResponse.php @@ -31,7 +31,7 @@ class ListHubSpokesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/NetworkConnectivity/src/V1/ListHubsRequest.php b/NetworkConnectivity/src/V1/ListHubsRequest.php index cdbfd35942b7..e7c1d8cb3332 100644 --- a/NetworkConnectivity/src/V1/ListHubsRequest.php +++ b/NetworkConnectivity/src/V1/ListHubsRequest.php @@ -22,31 +22,31 @@ class ListHubsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of results per page to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * An expression that filters the list of results. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Sort the results by a certain order. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent resource's name. Please see diff --git a/NetworkConnectivity/src/V1/ListHubsResponse.php b/NetworkConnectivity/src/V1/ListHubsResponse.php index 92b86adf149b..bf9e4e2a2c5a 100644 --- a/NetworkConnectivity/src/V1/ListHubsResponse.php +++ b/NetworkConnectivity/src/V1/ListHubsResponse.php @@ -30,7 +30,7 @@ class ListHubsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/NetworkConnectivity/src/V1/ListPolicyBasedRoutesRequest.php b/NetworkConnectivity/src/V1/ListPolicyBasedRoutesRequest.php index 6adeb5e49820..e8db9931970a 100644 --- a/NetworkConnectivity/src/V1/ListPolicyBasedRoutesRequest.php +++ b/NetworkConnectivity/src/V1/ListPolicyBasedRoutesRequest.php @@ -20,31 +20,31 @@ class ListPolicyBasedRoutesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of results per page that should be returned. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * A filter expression that filters the results listed in the response. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Sort the results by a certain order. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent resource's name. Please see diff --git a/NetworkConnectivity/src/V1/ListPolicyBasedRoutesResponse.php b/NetworkConnectivity/src/V1/ListPolicyBasedRoutesResponse.php index 037d95d8d4a1..b339ada59758 100644 --- a/NetworkConnectivity/src/V1/ListPolicyBasedRoutesResponse.php +++ b/NetworkConnectivity/src/V1/ListPolicyBasedRoutesResponse.php @@ -27,7 +27,7 @@ class ListPolicyBasedRoutesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/NetworkConnectivity/src/V1/ListRouteTablesRequest.php b/NetworkConnectivity/src/V1/ListRouteTablesRequest.php index b0a0b9dc5f84..b0611b5da8e4 100644 --- a/NetworkConnectivity/src/V1/ListRouteTablesRequest.php +++ b/NetworkConnectivity/src/V1/ListRouteTablesRequest.php @@ -22,31 +22,31 @@ class ListRouteTablesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of results to return per page. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * An expression that filters the list of results. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Sort the results by a certain order. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent resource's name. Please see diff --git a/NetworkConnectivity/src/V1/ListRouteTablesResponse.php b/NetworkConnectivity/src/V1/ListRouteTablesResponse.php index da24abc656c7..3e25d8233472 100644 --- a/NetworkConnectivity/src/V1/ListRouteTablesResponse.php +++ b/NetworkConnectivity/src/V1/ListRouteTablesResponse.php @@ -30,7 +30,7 @@ class ListRouteTablesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Hubs that could not be reached. * diff --git a/NetworkConnectivity/src/V1/ListRoutesRequest.php b/NetworkConnectivity/src/V1/ListRoutesRequest.php index 7119fdb8fec1..3a72b0a33561 100644 --- a/NetworkConnectivity/src/V1/ListRoutesRequest.php +++ b/NetworkConnectivity/src/V1/ListRoutesRequest.php @@ -22,31 +22,31 @@ class ListRoutesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of results to return per page. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * An expression that filters the list of results. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Sort the results by a certain order. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent resource's name. Please see diff --git a/NetworkConnectivity/src/V1/ListRoutesResponse.php b/NetworkConnectivity/src/V1/ListRoutesResponse.php index 02f437bdab43..dd5886f2dfed 100644 --- a/NetworkConnectivity/src/V1/ListRoutesResponse.php +++ b/NetworkConnectivity/src/V1/ListRoutesResponse.php @@ -30,7 +30,7 @@ class ListRoutesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * RouteTables that could not be reached. * diff --git a/NetworkConnectivity/src/V1/ListSpokesRequest.php b/NetworkConnectivity/src/V1/ListSpokesRequest.php index 4d6eb5c8d194..cd61a254e3ed 100644 --- a/NetworkConnectivity/src/V1/ListSpokesRequest.php +++ b/NetworkConnectivity/src/V1/ListSpokesRequest.php @@ -21,31 +21,31 @@ class ListSpokesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of results to return per page. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The page token. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * An expression that filters the list of results. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Sort the results by a certain order. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent resource. Please see diff --git a/NetworkConnectivity/src/V1/ListSpokesResponse.php b/NetworkConnectivity/src/V1/ListSpokesResponse.php index 362a73efe7c5..f5ce899c5452 100644 --- a/NetworkConnectivity/src/V1/ListSpokesResponse.php +++ b/NetworkConnectivity/src/V1/ListSpokesResponse.php @@ -29,7 +29,7 @@ class ListSpokesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached. * diff --git a/NetworkConnectivity/src/V1/NextHopVpcNetwork.php b/NetworkConnectivity/src/V1/NextHopVpcNetwork.php index f361cf554543..925d449792c9 100644 --- a/NetworkConnectivity/src/V1/NextHopVpcNetwork.php +++ b/NetworkConnectivity/src/V1/NextHopVpcNetwork.php @@ -18,7 +18,7 @@ class NextHopVpcNetwork extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uri = 1 [(.google.api.resource_reference) = { */ - private $uri = ''; + protected $uri = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/OperationMetadata.php b/NetworkConnectivity/src/V1/OperationMetadata.php index a2988af41a58..95de1b39336b 100644 --- a/NetworkConnectivity/src/V1/OperationMetadata.php +++ b/NetworkConnectivity/src/V1/OperationMetadata.php @@ -20,31 +20,31 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. Server-defined resource path for the target of the operation. * * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $target = ''; + protected $target = ''; /** * Output only. Name of the verb executed by the operation. * * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $verb = ''; + protected $verb = ''; /** * Output only. Human-readable status of the operation, if any. * * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $status_message = ''; + protected $status_message = ''; /** * Output only. Identifies whether the user has requested cancellation * of the operation. Operations that have been cancelled successfully @@ -54,13 +54,13 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $requested_cancellation = false; + protected $requested_cancellation = false; /** * Output only. API version used to start the operation. * * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $api_version = ''; + protected $api_version = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/PolicyBasedRoute.php b/NetworkConnectivity/src/V1/PolicyBasedRoute.php index 6fdad669db69..c8c841af24f3 100644 --- a/NetworkConnectivity/src/V1/PolicyBasedRoute.php +++ b/NetworkConnectivity/src/V1/PolicyBasedRoute.php @@ -25,19 +25,19 @@ class PolicyBasedRoute extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. Time when the PolicyBasedRoute was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. Time when the PolicyBasedRoute was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * User-defined labels. * @@ -50,20 +50,20 @@ class PolicyBasedRoute extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $description = ''; + protected $description = ''; /** * Required. Fully-qualified URL of the network that this route applies to. * e.g. projects/my-project/global/networks/my-network. * * Generated from protobuf field string network = 6 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $network = ''; + protected $network = ''; /** * Required. The filter to match L4 traffic. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.PolicyBasedRoute.Filter filter = 10 [(.google.api.field_behavior) = REQUIRED]; */ - private $filter = null; + protected $filter = null; /** * Optional. The priority of this policy based route. Priority is used to * break ties in cases where there are more than one matching policy based @@ -73,7 +73,7 @@ class PolicyBasedRoute extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 priority = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $priority = 0; + protected $priority = 0; /** * Output only. If potential misconfigurations are detected for this route, * this field will be populated with warning messages. @@ -86,14 +86,14 @@ class PolicyBasedRoute extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string self_link = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $self_link = ''; + protected $self_link = ''; /** * Output only. Type of this resource. Always * networkconnectivity#policyBasedRoute for Policy Based Route resources. * * Generated from protobuf field string kind = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $kind = ''; + protected $kind = ''; protected $target; protected $next_hop; diff --git a/NetworkConnectivity/src/V1/PolicyBasedRoute/Filter.php b/NetworkConnectivity/src/V1/PolicyBasedRoute/Filter.php index 9563c8b50d5e..ce38c5cc5485 100644 --- a/NetworkConnectivity/src/V1/PolicyBasedRoute/Filter.php +++ b/NetworkConnectivity/src/V1/PolicyBasedRoute/Filter.php @@ -21,14 +21,14 @@ class Filter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string ip_protocol = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $ip_protocol = ''; + protected $ip_protocol = ''; /** * Optional. The source IP range of outgoing packets that this policy based * route applies to. Default is "0.0.0.0/0" if protocol version is IPv4. * * Generated from protobuf field string src_range = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $src_range = ''; + protected $src_range = ''; /** * Optional. The destination IP range of outgoing packets that this policy * based route applies to. Default is "0.0.0.0/0" if protocol version is @@ -36,14 +36,14 @@ class Filter extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string dest_range = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $dest_range = ''; + protected $dest_range = ''; /** * Required. Internet protocol versions this policy based route applies to. * For this version, only IPV4 is supported. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.PolicyBasedRoute.Filter.ProtocolVersion protocol_version = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $protocol_version = 0; + protected $protocol_version = 0; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/PolicyBasedRoute/InterconnectAttachment.php b/NetworkConnectivity/src/V1/PolicyBasedRoute/InterconnectAttachment.php index bcc42892418f..29e3f8afa36c 100644 --- a/NetworkConnectivity/src/V1/PolicyBasedRoute/InterconnectAttachment.php +++ b/NetworkConnectivity/src/V1/PolicyBasedRoute/InterconnectAttachment.php @@ -21,7 +21,7 @@ class InterconnectAttachment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string region = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $region = ''; + protected $region = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/PolicyBasedRoute/Warnings.php b/NetworkConnectivity/src/V1/PolicyBasedRoute/Warnings.php index 31d73a286c38..2004d3d1c760 100644 --- a/NetworkConnectivity/src/V1/PolicyBasedRoute/Warnings.php +++ b/NetworkConnectivity/src/V1/PolicyBasedRoute/Warnings.php @@ -20,7 +20,7 @@ class Warnings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.PolicyBasedRoute.Warnings.Code code = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $code = 0; + protected $code = 0; /** * Output only. Metadata about this warning in key: value format. The key * should provides more detail on the warning being returned. For example, @@ -37,7 +37,7 @@ class Warnings extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string warning_message = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $warning_message = ''; + protected $warning_message = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/PolicyBasedRoutingServiceClient.php b/NetworkConnectivity/src/V1/PolicyBasedRoutingServiceClient.php deleted file mode 100644 index d45afe7bf240..000000000000 --- a/NetworkConnectivity/src/V1/PolicyBasedRoutingServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/ListPolicyBasedRoutes', - $argument, - ['\Google\Cloud\NetworkConnectivity\V1\ListPolicyBasedRoutesResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets details of a single PolicyBasedRoute. - * @param \Google\Cloud\NetworkConnectivity\V1\GetPolicyBasedRouteRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetPolicyBasedRoute(\Google\Cloud\NetworkConnectivity\V1\GetPolicyBasedRouteRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/GetPolicyBasedRoute', - $argument, - ['\Google\Cloud\NetworkConnectivity\V1\PolicyBasedRoute', 'decode'], - $metadata, $options); - } - - /** - * Creates a new PolicyBasedRoute in a given project and location. - * @param \Google\Cloud\NetworkConnectivity\V1\CreatePolicyBasedRouteRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreatePolicyBasedRoute(\Google\Cloud\NetworkConnectivity\V1\CreatePolicyBasedRouteRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/CreatePolicyBasedRoute', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Deletes a single PolicyBasedRoute. - * @param \Google\Cloud\NetworkConnectivity\V1\DeletePolicyBasedRouteRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeletePolicyBasedRoute(\Google\Cloud\NetworkConnectivity\V1\DeletePolicyBasedRouteRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/DeletePolicyBasedRoute', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - -} diff --git a/NetworkConnectivity/src/V1/RejectHubSpokeRequest.php b/NetworkConnectivity/src/V1/RejectHubSpokeRequest.php index c2a7c6f2b6b4..5dc16ed99792 100644 --- a/NetworkConnectivity/src/V1/RejectHubSpokeRequest.php +++ b/NetworkConnectivity/src/V1/RejectHubSpokeRequest.php @@ -21,13 +21,13 @@ class RejectHubSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The URI of the spoke to reject from the hub. * * Generated from protobuf field string spoke_uri = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $spoke_uri = ''; + protected $spoke_uri = ''; /** * Optional. A request ID to identify requests. Specify a unique request ID so * that if you must retry your request, the server knows to ignore the request @@ -44,13 +44,13 @@ class RejectHubSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. Additional information provided by the hub administrator. * * Generated from protobuf field string details = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $details = ''; + protected $details = ''; /** * @param string $name Required. The name of the hub from which to reject the spoke. Please see diff --git a/NetworkConnectivity/src/V1/RejectHubSpokeResponse.php b/NetworkConnectivity/src/V1/RejectHubSpokeResponse.php index 35b1358dce4c..6a01f4ea38ee 100644 --- a/NetworkConnectivity/src/V1/RejectHubSpokeResponse.php +++ b/NetworkConnectivity/src/V1/RejectHubSpokeResponse.php @@ -21,7 +21,7 @@ class RejectHubSpokeResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.Spoke spoke = 1; */ - private $spoke = null; + protected $spoke = null; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/Route.php b/NetworkConnectivity/src/V1/Route.php index bfede90a7e71..6525688f95d8 100644 --- a/NetworkConnectivity/src/V1/Route.php +++ b/NetworkConnectivity/src/V1/Route.php @@ -23,38 +23,38 @@ class Route extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. The time the route was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the route was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * The destination IP address range. * * Generated from protobuf field string ip_cidr_range = 1; */ - private $ip_cidr_range = ''; + protected $ip_cidr_range = ''; /** * Output only. The route's type. Its type is determined by the properties of * its IP address range. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.RouteType type = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $type = 0; + protected $type = 0; /** * Immutable. The destination VPC network for packets on this route. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.NextHopVpcNetwork next_hop_vpc_network = 2 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $next_hop_vpc_network = null; + protected $next_hop_vpc_network = null; /** * Optional labels in key-value pair format. For more information about * labels, see [Requirements for @@ -68,7 +68,7 @@ class Route extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 7; */ - private $description = ''; + protected $description = ''; /** * Output only. The Google-generated UUID for the route. This value is unique * across all Network Connectivity Center route resources. If a @@ -77,20 +77,20 @@ class Route extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uid = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Output only. The current lifecycle state of the route. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.State state = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Immutable. The spoke that this route leads to. * Example: projects/12345/locations/global/spokes/SPOKE * * Generated from protobuf field string spoke = 11 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.resource_reference) = { */ - private $spoke = ''; + protected $spoke = ''; /** * Output only. The location of the route. * Uses the following form: "projects/{project}/locations/{location}" @@ -98,7 +98,7 @@ class Route extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string location = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $location = ''; + protected $location = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/RouteTable.php b/NetworkConnectivity/src/V1/RouteTable.php index 4293552d7570..c48d43791198 100644 --- a/NetworkConnectivity/src/V1/RouteTable.php +++ b/NetworkConnectivity/src/V1/RouteTable.php @@ -20,19 +20,19 @@ class RouteTable extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. The time the route table was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the route table was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional labels in key-value pair format. For more information about * labels, see [Requirements for @@ -46,7 +46,7 @@ class RouteTable extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 5; */ - private $description = ''; + protected $description = ''; /** * Output only. The Google-generated UUID for the route table. This value is * unique across all route table resources. If a route table is deleted and @@ -55,13 +55,13 @@ class RouteTable extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uid = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Output only. The current lifecycle state of this route table. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/RouterApplianceInstance.php b/NetworkConnectivity/src/V1/RouterApplianceInstance.php index 6f4383d97dd1..97d6be00b42d 100644 --- a/NetworkConnectivity/src/V1/RouterApplianceInstance.php +++ b/NetworkConnectivity/src/V1/RouterApplianceInstance.php @@ -23,13 +23,13 @@ class RouterApplianceInstance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string virtual_machine = 1 [(.google.api.resource_reference) = { */ - private $virtual_machine = ''; + protected $virtual_machine = ''; /** * The IP address on the VM to use for peering. * * Generated from protobuf field string ip_address = 3; */ - private $ip_address = ''; + protected $ip_address = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/RoutingVPC.php b/NetworkConnectivity/src/V1/RoutingVPC.php index 93fa05066b71..2ef9e562490d 100644 --- a/NetworkConnectivity/src/V1/RoutingVPC.php +++ b/NetworkConnectivity/src/V1/RoutingVPC.php @@ -21,7 +21,7 @@ class RoutingVPC extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uri = 1 [(.google.api.resource_reference) = { */ - private $uri = ''; + protected $uri = ''; /** * Output only. If true, indicates that this VPC network is currently * associated with spokes that use the data transfer feature (spokes where the @@ -31,7 +31,7 @@ class RoutingVPC extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool required_for_new_site_to_site_data_transfer_spokes = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $required_for_new_site_to_site_data_transfer_spokes = false; + protected $required_for_new_site_to_site_data_transfer_spokes = false; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/Spoke.php b/NetworkConnectivity/src/V1/Spoke.php index ef86dc08542d..969b8287d349 100644 --- a/NetworkConnectivity/src/V1/Spoke.php +++ b/NetworkConnectivity/src/V1/Spoke.php @@ -29,19 +29,19 @@ class Spoke extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. The time the spoke was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the spoke was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional labels in key-value pair format. For more information about * labels, see [Requirements for @@ -55,43 +55,43 @@ class Spoke extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 5; */ - private $description = ''; + protected $description = ''; /** * Immutable. The name of the hub that this spoke is attached to. * * Generated from protobuf field string hub = 6 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.resource_reference) = { */ - private $hub = ''; + protected $hub = ''; /** * Optional. The name of the group that this spoke is associated with. * * Generated from protobuf field string group = 23 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $group = ''; + protected $group = ''; /** * VPN tunnels that are associated with the spoke. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.LinkedVpnTunnels linked_vpn_tunnels = 17; */ - private $linked_vpn_tunnels = null; + protected $linked_vpn_tunnels = null; /** * VLAN attachments that are associated with the spoke. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.LinkedInterconnectAttachments linked_interconnect_attachments = 18; */ - private $linked_interconnect_attachments = null; + protected $linked_interconnect_attachments = null; /** * Router appliance instances that are associated with the spoke. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.LinkedRouterApplianceInstances linked_router_appliance_instances = 19; */ - private $linked_router_appliance_instances = null; + protected $linked_router_appliance_instances = null; /** * Optional. VPC network that is associated with the spoke. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.LinkedVpcNetwork linked_vpc_network = 20 [(.google.api.field_behavior) = OPTIONAL]; */ - private $linked_vpc_network = null; + protected $linked_vpc_network = null; /** * Output only. The Google-generated UUID for the spoke. This value is unique * across all spoke resources. If a spoke is deleted and another with the same @@ -99,13 +99,13 @@ class Spoke extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string unique_id = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $unique_id = ''; + protected $unique_id = ''; /** * Output only. The current lifecycle state of this spoke. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.State state = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The reasons for current state of the spoke. Only present when * the spoke is in the `INACTIVE` state. @@ -118,7 +118,7 @@ class Spoke extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.SpokeType spoke_type = 22 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $spoke_type = 0; + protected $spoke_type = 0; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/Spoke/StateReason.php b/NetworkConnectivity/src/V1/Spoke/StateReason.php index a6c04e37ee59..14cd29efc106 100644 --- a/NetworkConnectivity/src/V1/Spoke/StateReason.php +++ b/NetworkConnectivity/src/V1/Spoke/StateReason.php @@ -20,19 +20,19 @@ class StateReason extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.Spoke.StateReason.Code code = 1; */ - private $code = 0; + protected $code = 0; /** * Human-readable details about this reason. * * Generated from protobuf field string message = 2; */ - private $message = ''; + protected $message = ''; /** * Additional information provided by the user in the RejectSpoke call. * * Generated from protobuf field string user_details = 3; */ - private $user_details = ''; + protected $user_details = ''; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/SpokeSummary/SpokeStateCount.php b/NetworkConnectivity/src/V1/SpokeSummary/SpokeStateCount.php index bf143f70a6ca..4353324f154d 100644 --- a/NetworkConnectivity/src/V1/SpokeSummary/SpokeStateCount.php +++ b/NetworkConnectivity/src/V1/SpokeSummary/SpokeStateCount.php @@ -21,14 +21,14 @@ class SpokeStateCount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The total number of spokes that are in this state * and associated with a given hub. * * Generated from protobuf field int64 count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $count = 0; + protected $count = 0; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/SpokeSummary/SpokeStateReasonCount.php b/NetworkConnectivity/src/V1/SpokeSummary/SpokeStateReasonCount.php index 4089fe870ce5..7c1cc26a2d96 100644 --- a/NetworkConnectivity/src/V1/SpokeSummary/SpokeStateReasonCount.php +++ b/NetworkConnectivity/src/V1/SpokeSummary/SpokeStateReasonCount.php @@ -20,14 +20,14 @@ class SpokeStateReasonCount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.Spoke.StateReason.Code state_reason_code = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state_reason_code = 0; + protected $state_reason_code = 0; /** * Output only. The total number of spokes that are inactive for a * particular reason and associated with a given hub. * * Generated from protobuf field int64 count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $count = 0; + protected $count = 0; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/SpokeSummary/SpokeTypeCount.php b/NetworkConnectivity/src/V1/SpokeSummary/SpokeTypeCount.php index 10110c09bedf..6087b363c228 100644 --- a/NetworkConnectivity/src/V1/SpokeSummary/SpokeTypeCount.php +++ b/NetworkConnectivity/src/V1/SpokeSummary/SpokeTypeCount.php @@ -22,14 +22,14 @@ class SpokeTypeCount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkconnectivity.v1.SpokeType spoke_type = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $spoke_type = 0; + protected $spoke_type = 0; /** * Output only. The total number of spokes of this type that are * associated with the hub. * * Generated from protobuf field int64 count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $count = 0; + protected $count = 0; /** * Constructor. diff --git a/NetworkConnectivity/src/V1/UpdateHubRequest.php b/NetworkConnectivity/src/V1/UpdateHubRequest.php index de935ee8b046..17e009bf5bd7 100644 --- a/NetworkConnectivity/src/V1/UpdateHubRequest.php +++ b/NetworkConnectivity/src/V1/UpdateHubRequest.php @@ -26,13 +26,13 @@ class UpdateHubRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. The state that the hub should be in after the update. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.Hub hub = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $hub = null; + protected $hub = null; /** * Optional. A request ID to identify requests. Specify a unique request ID so * that if you must retry your request, the server knows to ignore the request @@ -49,7 +49,7 @@ class UpdateHubRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param \Google\Cloud\NetworkConnectivity\V1\Hub $hub Required. The state that the hub should be in after the update. diff --git a/NetworkConnectivity/src/V1/UpdateSpokeRequest.php b/NetworkConnectivity/src/V1/UpdateSpokeRequest.php index 9c77e899c530..ee50dce1145a 100644 --- a/NetworkConnectivity/src/V1/UpdateSpokeRequest.php +++ b/NetworkConnectivity/src/V1/UpdateSpokeRequest.php @@ -26,13 +26,13 @@ class UpdateSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. The state that the spoke should be in after the update. * * Generated from protobuf field .google.cloud.networkconnectivity.v1.Spoke spoke = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $spoke = null; + protected $spoke = null; /** * Optional. A request ID to identify requests. Specify a unique request ID so * that if you must retry your request, the server knows to ignore the request @@ -49,7 +49,7 @@ class UpdateSpokeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * @param \Google\Cloud\NetworkConnectivity\V1\Spoke $spoke Required. The state that the spoke should be in after the update. diff --git a/NetworkConnectivity/tests/Unit/V1/Client/HubServiceClientTest.php b/NetworkConnectivity/tests/Unit/V1/Client/HubServiceClientTest.php index 4fc4d7f645e9..1f5659c63815 100644 --- a/NetworkConnectivity/tests/Unit/V1/Client/HubServiceClientTest.php +++ b/NetworkConnectivity/tests/Unit/V1/Client/HubServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return HubServiceClient */ @@ -136,9 +138,7 @@ public function acceptHubSpokeTest() // Mock request $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new AcceptHubSpokeRequest()) - ->setName($formattedName) - ->setSpokeUri($formattedSpokeUri); + $request = (new AcceptHubSpokeRequest())->setName($formattedName)->setSpokeUri($formattedSpokeUri); $response = $gapicClient->acceptHubSpoke($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -196,19 +196,20 @@ public function acceptHubSpokeExceptionTest() $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); + $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->hubName('[PROJECT]', '[HUB]'); $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new AcceptHubSpokeRequest()) - ->setName($formattedName) - ->setSpokeUri($formattedSpokeUri); + $request = (new AcceptHubSpokeRequest())->setName($formattedName)->setSpokeUri($formattedSpokeUri); $response = $gapicClient->acceptHubSpoke($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -333,12 +334,15 @@ public function createHubExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -476,12 +480,15 @@ public function createSpokeExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -544,8 +551,7 @@ public function deleteHubTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $request = (new DeleteHubRequest()) - ->setName($formattedName); + $request = (new DeleteHubRequest())->setName($formattedName); $response = $gapicClient->deleteHub($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -601,17 +607,19 @@ public function deleteHubExceptionTest() $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); + $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->hubName('[PROJECT]', '[HUB]'); - $request = (new DeleteHubRequest()) - ->setName($formattedName); + $request = (new DeleteHubRequest())->setName($formattedName); $response = $gapicClient->deleteHub($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -665,8 +673,7 @@ public function deleteSpokeTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new DeleteSpokeRequest()) - ->setName($formattedName); + $request = (new DeleteSpokeRequest())->setName($formattedName); $response = $gapicClient->deleteSpoke($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -722,17 +729,19 @@ public function deleteSpokeExceptionTest() $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); + $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->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new DeleteSpokeRequest()) - ->setName($formattedName); + $request = (new DeleteSpokeRequest())->setName($formattedName); $response = $gapicClient->deleteSpoke($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -774,8 +783,7 @@ public function getGroupTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->groupName('[PROJECT]', '[HUB]', '[GROUP]'); - $request = (new GetGroupRequest()) - ->setName($formattedName); + $request = (new GetGroupRequest())->setName($formattedName); $response = $gapicClient->getGroup($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -799,17 +807,19 @@ public function getGroupExceptionTest() $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); + $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->groupName('[PROJECT]', '[HUB]', '[GROUP]'); - $request = (new GetGroupRequest()) - ->setName($formattedName); + $request = (new GetGroupRequest())->setName($formattedName); try { $gapicClient->getGroup($request); // If the $gapicClient method call did not throw, fail the test @@ -842,8 +852,7 @@ public function getHubTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $request = (new GetHubRequest()) - ->setName($formattedName); + $request = (new GetHubRequest())->setName($formattedName); $response = $gapicClient->getHub($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -867,17 +876,19 @@ public function getHubExceptionTest() $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); + $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->hubName('[PROJECT]', '[HUB]'); - $request = (new GetHubRequest()) - ->setName($formattedName); + $request = (new GetHubRequest())->setName($formattedName); try { $gapicClient->getHub($request); // If the $gapicClient method call did not throw, fail the test @@ -916,8 +927,7 @@ public function getRouteTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->hubRouteName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]', '[ROUTE]'); - $request = (new GetRouteRequest()) - ->setName($formattedName); + $request = (new GetRouteRequest())->setName($formattedName); $response = $gapicClient->getRoute($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -941,17 +951,19 @@ public function getRouteExceptionTest() $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); + $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->hubRouteName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]', '[ROUTE]'); - $request = (new GetRouteRequest()) - ->setName($formattedName); + $request = (new GetRouteRequest())->setName($formattedName); try { $gapicClient->getRoute($request); // If the $gapicClient method call did not throw, fail the test @@ -984,8 +996,7 @@ public function getRouteTableTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - $request = (new GetRouteTableRequest()) - ->setName($formattedName); + $request = (new GetRouteTableRequest())->setName($formattedName); $response = $gapicClient->getRouteTable($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1009,17 +1020,19 @@ public function getRouteTableExceptionTest() $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); + $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->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - $request = (new GetRouteTableRequest()) - ->setName($formattedName); + $request = (new GetRouteTableRequest())->setName($formattedName); try { $gapicClient->getRouteTable($request); // If the $gapicClient method call did not throw, fail the test @@ -1056,8 +1069,7 @@ public function getSpokeTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new GetSpokeRequest()) - ->setName($formattedName); + $request = (new GetSpokeRequest())->setName($formattedName); $response = $gapicClient->getSpoke($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1081,17 +1093,19 @@ public function getSpokeExceptionTest() $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); + $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->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new GetSpokeRequest()) - ->setName($formattedName); + $request = (new GetSpokeRequest())->setName($formattedName); try { $gapicClient->getSpoke($request); // If the $gapicClient method call did not throw, fail the test @@ -1116,17 +1130,14 @@ public function listGroupsTest() // Mock response $nextPageToken = ''; $groupsElement = new Group(); - $groups = [ - $groupsElement, - ]; + $groups = [$groupsElement]; $expectedResponse = new ListGroupsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setGroups($groups); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $request = (new ListGroupsRequest()) - ->setParent($formattedParent); + $request = (new ListGroupsRequest())->setParent($formattedParent); $response = $gapicClient->listGroups($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1153,17 +1164,19 @@ public function listGroupsExceptionTest() $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); + $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->hubName('[PROJECT]', '[HUB]'); - $request = (new ListGroupsRequest()) - ->setParent($formattedParent); + $request = (new ListGroupsRequest())->setParent($formattedParent); try { $gapicClient->listGroups($request); // If the $gapicClient method call did not throw, fail the test @@ -1188,17 +1201,14 @@ public function listHubSpokesTest() // Mock response $nextPageToken = ''; $spokesElement = new Spoke(); - $spokes = [ - $spokesElement, - ]; + $spokes = [$spokesElement]; $expectedResponse = new ListHubSpokesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSpokes($spokes); $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $request = (new ListHubSpokesRequest()) - ->setName($formattedName); + $request = (new ListHubSpokesRequest())->setName($formattedName); $response = $gapicClient->listHubSpokes($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1225,17 +1235,19 @@ public function listHubSpokesExceptionTest() $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); + $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->hubName('[PROJECT]', '[HUB]'); - $request = (new ListHubSpokesRequest()) - ->setName($formattedName); + $request = (new ListHubSpokesRequest())->setName($formattedName); try { $gapicClient->listHubSpokes($request); // If the $gapicClient method call did not throw, fail the test @@ -1260,17 +1272,14 @@ public function listHubsTest() // Mock response $nextPageToken = ''; $hubsElement = new Hub(); - $hubs = [ - $hubsElement, - ]; + $hubs = [$hubsElement]; $expectedResponse = new ListHubsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setHubs($hubs); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListHubsRequest()) - ->setParent($formattedParent); + $request = (new ListHubsRequest())->setParent($formattedParent); $response = $gapicClient->listHubs($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1297,17 +1306,19 @@ public function listHubsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListHubsRequest()) - ->setParent($formattedParent); + $request = (new ListHubsRequest())->setParent($formattedParent); try { $gapicClient->listHubs($request); // If the $gapicClient method call did not throw, fail the test @@ -1332,17 +1343,14 @@ public function listRouteTablesTest() // Mock response $nextPageToken = ''; $routeTablesElement = new RouteTable(); - $routeTables = [ - $routeTablesElement, - ]; + $routeTables = [$routeTablesElement]; $expectedResponse = new ListRouteTablesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setRouteTables($routeTables); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $request = (new ListRouteTablesRequest()) - ->setParent($formattedParent); + $request = (new ListRouteTablesRequest())->setParent($formattedParent); $response = $gapicClient->listRouteTables($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1369,17 +1377,19 @@ public function listRouteTablesExceptionTest() $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); + $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->hubName('[PROJECT]', '[HUB]'); - $request = (new ListRouteTablesRequest()) - ->setParent($formattedParent); + $request = (new ListRouteTablesRequest())->setParent($formattedParent); try { $gapicClient->listRouteTables($request); // If the $gapicClient method call did not throw, fail the test @@ -1404,17 +1414,14 @@ public function listRoutesTest() // Mock response $nextPageToken = ''; $routesElement = new Route(); - $routes = [ - $routesElement, - ]; + $routes = [$routesElement]; $expectedResponse = new ListRoutesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setRoutes($routes); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - $request = (new ListRoutesRequest()) - ->setParent($formattedParent); + $request = (new ListRoutesRequest())->setParent($formattedParent); $response = $gapicClient->listRoutes($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1441,17 +1448,19 @@ public function listRoutesExceptionTest() $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); + $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->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - $request = (new ListRoutesRequest()) - ->setParent($formattedParent); + $request = (new ListRoutesRequest())->setParent($formattedParent); try { $gapicClient->listRoutes($request); // If the $gapicClient method call did not throw, fail the test @@ -1476,17 +1485,14 @@ public function listSpokesTest() // Mock response $nextPageToken = ''; $spokesElement = new Spoke(); - $spokes = [ - $spokesElement, - ]; + $spokes = [$spokesElement]; $expectedResponse = new ListSpokesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSpokes($spokes); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListSpokesRequest()) - ->setParent($formattedParent); + $request = (new ListSpokesRequest())->setParent($formattedParent); $response = $gapicClient->listSpokes($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1513,17 +1519,19 @@ public function listSpokesExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListSpokesRequest()) - ->setParent($formattedParent); + $request = (new ListSpokesRequest())->setParent($formattedParent); try { $gapicClient->listSpokes($request); // If the $gapicClient method call did not throw, fail the test @@ -1569,9 +1577,7 @@ public function rejectHubSpokeTest() // Mock request $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new RejectHubSpokeRequest()) - ->setName($formattedName) - ->setSpokeUri($formattedSpokeUri); + $request = (new RejectHubSpokeRequest())->setName($formattedName)->setSpokeUri($formattedSpokeUri); $response = $gapicClient->rejectHubSpoke($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1629,19 +1635,20 @@ public function rejectHubSpokeExceptionTest() $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); + $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->hubName('[PROJECT]', '[HUB]'); $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new RejectHubSpokeRequest()) - ->setName($formattedName) - ->setSpokeUri($formattedSpokeUri); + $request = (new RejectHubSpokeRequest())->setName($formattedName)->setSpokeUri($formattedSpokeUri); $response = $gapicClient->rejectHubSpoke($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1701,8 +1708,7 @@ public function updateHubTest() $operationsTransport->addResponse($completeOperation); // Mock request $hub = new Hub(); - $request = (new UpdateHubRequest()) - ->setHub($hub); + $request = (new UpdateHubRequest())->setHub($hub); $response = $gapicClient->updateHub($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1758,17 +1764,19 @@ public function updateHubExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $hub = new Hub(); - $request = (new UpdateHubRequest()) - ->setHub($hub); + $request = (new UpdateHubRequest())->setHub($hub); $response = $gapicClient->updateHub($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1832,8 +1840,7 @@ public function updateSpokeTest() $operationsTransport->addResponse($completeOperation); // Mock request $spoke = new Spoke(); - $request = (new UpdateSpokeRequest()) - ->setSpoke($spoke); + $request = (new UpdateSpokeRequest())->setSpoke($spoke); $response = $gapicClient->updateSpoke($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1889,17 +1896,19 @@ public function updateSpokeExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $spoke = new Spoke(); - $request = (new UpdateSpokeRequest()) - ->setSpoke($spoke); + $request = (new UpdateSpokeRequest())->setSpoke($spoke); $response = $gapicClient->updateSpoke($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1961,12 +1970,15 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -1993,9 +2005,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -2025,12 +2035,15 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -2063,8 +2076,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2088,17 +2100,19 @@ public function getIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -2130,9 +2144,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2158,19 +2170,20 @@ public function setIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -2198,9 +2211,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2226,19 +2237,20 @@ public function testIamPermissionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -2284,9 +2296,7 @@ public function acceptHubSpokeAsyncTest() // Mock request $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $request = (new AcceptHubSpokeRequest()) - ->setName($formattedName) - ->setSpokeUri($formattedSpokeUri); + $request = (new AcceptHubSpokeRequest())->setName($formattedName)->setSpokeUri($formattedSpokeUri); $response = $gapicClient->acceptHubSpokeAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); diff --git a/NetworkConnectivity/tests/Unit/V1/Client/PolicyBasedRoutingServiceClientTest.php b/NetworkConnectivity/tests/Unit/V1/Client/PolicyBasedRoutingServiceClientTest.php index 54706719f509..6610753d8227 100644 --- a/NetworkConnectivity/tests/Unit/V1/Client/PolicyBasedRoutingServiceClientTest.php +++ b/NetworkConnectivity/tests/Unit/V1/Client/PolicyBasedRoutingServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return PolicyBasedRoutingServiceClient */ @@ -146,7 +148,10 @@ public function createPolicyBasedRouteTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/CreatePolicyBasedRoute', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/CreatePolicyBasedRoute', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getPolicyBasedRouteId(); @@ -196,12 +201,15 @@ public function createPolicyBasedRouteExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -270,8 +278,7 @@ public function deletePolicyBasedRouteTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - $request = (new DeletePolicyBasedRouteRequest()) - ->setName($formattedName); + $request = (new DeletePolicyBasedRouteRequest())->setName($formattedName); $response = $gapicClient->deletePolicyBasedRoute($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -281,7 +288,10 @@ public function deletePolicyBasedRouteTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/DeletePolicyBasedRoute', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/DeletePolicyBasedRoute', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -327,17 +337,19 @@ public function deletePolicyBasedRouteExceptionTest() $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); + $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->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - $request = (new DeletePolicyBasedRouteRequest()) - ->setName($formattedName); + $request = (new DeletePolicyBasedRouteRequest())->setName($formattedName); $response = $gapicClient->deletePolicyBasedRoute($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -387,15 +399,17 @@ public function getPolicyBasedRouteTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - $request = (new GetPolicyBasedRouteRequest()) - ->setName($formattedName); + $request = (new GetPolicyBasedRouteRequest())->setName($formattedName); $response = $gapicClient->getPolicyBasedRoute($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.networkconnectivity.v1.PolicyBasedRoutingService/GetPolicyBasedRoute', $actualFuncCall); + $this->assertSame( + '/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/GetPolicyBasedRoute', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -412,17 +426,19 @@ public function getPolicyBasedRouteExceptionTest() $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); + $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->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - $request = (new GetPolicyBasedRouteRequest()) - ->setName($formattedName); + $request = (new GetPolicyBasedRouteRequest())->setName($formattedName); try { $gapicClient->getPolicyBasedRoute($request); // If the $gapicClient method call did not throw, fail the test @@ -447,17 +463,14 @@ public function listPolicyBasedRoutesTest() // Mock response $nextPageToken = ''; $policyBasedRoutesElement = new PolicyBasedRoute(); - $policyBasedRoutes = [ - $policyBasedRoutesElement, - ]; + $policyBasedRoutes = [$policyBasedRoutesElement]; $expectedResponse = new ListPolicyBasedRoutesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setPolicyBasedRoutes($policyBasedRoutes); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListPolicyBasedRoutesRequest()) - ->setParent($formattedParent); + $request = (new ListPolicyBasedRoutesRequest())->setParent($formattedParent); $response = $gapicClient->listPolicyBasedRoutes($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -467,7 +480,10 @@ public function listPolicyBasedRoutesTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/ListPolicyBasedRoutes', $actualFuncCall); + $this->assertSame( + '/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/ListPolicyBasedRoutes', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -484,17 +500,19 @@ public function listPolicyBasedRoutesExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListPolicyBasedRoutesRequest()) - ->setParent($formattedParent); + $request = (new ListPolicyBasedRoutesRequest())->setParent($formattedParent); try { $gapicClient->listPolicyBasedRoutes($request); // If the $gapicClient method call did not throw, fail the test @@ -547,12 +565,15 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -579,9 +600,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -611,12 +630,15 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -649,8 +671,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -674,17 +695,19 @@ public function getIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -716,9 +739,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -744,19 +765,20 @@ public function setIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -784,9 +806,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -812,19 +832,20 @@ public function testIamPermissionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -904,7 +925,10 @@ public function createPolicyBasedRouteAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/CreatePolicyBasedRoute', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/CreatePolicyBasedRoute', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getPolicyBasedRouteId(); diff --git a/NetworkConnectivity/tests/Unit/V1/HubServiceClientTest.php b/NetworkConnectivity/tests/Unit/V1/HubServiceClientTest.php deleted file mode 100644 index de5fb8232678..000000000000 --- a/NetworkConnectivity/tests/Unit/V1/HubServiceClientTest.php +++ /dev/null @@ -1,2122 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return HubServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new HubServiceClient($options); - } - - /** @test */ - public function acceptHubSpokeTest() - { - $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/acceptHubSpokeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new AcceptHubSpokeResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/acceptHubSpokeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $response = $gapicClient->acceptHubSpoke($formattedName, $formattedSpokeUri); - $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.networkconnectivity.v1.HubService/AcceptHubSpoke', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getSpokeUri(); - $this->assertProtobufEquals($formattedSpokeUri, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/acceptHubSpokeTest'); - $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 acceptHubSpokeExceptionTest() - { - $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/acceptHubSpokeTest'); - $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->hubName('[PROJECT]', '[HUB]'); - $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $response = $gapicClient->acceptHubSpoke($formattedName, $formattedSpokeUri); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/acceptHubSpokeTest'); - 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 createHubTest() - { - $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/createHubTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $uniqueId = 'uniqueId-538310583'; - $expectedResponse = new Hub(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setUniqueId($uniqueId); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createHubTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $hubId = 'hubId-1206469467'; - $hub = new Hub(); - $response = $gapicClient->createHub($formattedParent, $hubId, $hub); - $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.networkconnectivity.v1.HubService/CreateHub', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getHubId(); - $this->assertProtobufEquals($hubId, $actualValue); - $actualValue = $actualApiRequestObject->getHub(); - $this->assertProtobufEquals($hub, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createHubTest'); - $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 createHubExceptionTest() - { - $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/createHubTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $hubId = 'hubId-1206469467'; - $hub = new Hub(); - $response = $gapicClient->createHub($formattedParent, $hubId, $hub); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createHubTest'); - 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 createSpokeTest() - { - $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/createSpokeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $hub = 'hub103669'; - $group = 'group98629247'; - $uniqueId = 'uniqueId-538310583'; - $expectedResponse = new Spoke(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setHub($hub); - $expectedResponse->setGroup($group); - $expectedResponse->setUniqueId($uniqueId); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createSpokeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $spokeId = 'spokeId-1839321170'; - $spoke = new Spoke(); - $response = $gapicClient->createSpoke($formattedParent, $spokeId, $spoke); - $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.networkconnectivity.v1.HubService/CreateSpoke', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getSpokeId(); - $this->assertProtobufEquals($spokeId, $actualValue); - $actualValue = $actualApiRequestObject->getSpoke(); - $this->assertProtobufEquals($spoke, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createSpokeTest'); - $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 createSpokeExceptionTest() - { - $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/createSpokeTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $spokeId = 'spokeId-1839321170'; - $spoke = new Spoke(); - $response = $gapicClient->createSpoke($formattedParent, $spokeId, $spoke); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createSpokeTest'); - 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 deleteHubTest() - { - $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/deleteHubTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteHubTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $response = $gapicClient->deleteHub($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.networkconnectivity.v1.HubService/DeleteHub', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteHubTest'); - $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 deleteHubExceptionTest() - { - $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/deleteHubTest'); - $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->hubName('[PROJECT]', '[HUB]'); - $response = $gapicClient->deleteHub($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteHubTest'); - 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 deleteSpokeTest() - { - $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/deleteSpokeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteSpokeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $response = $gapicClient->deleteSpoke($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.networkconnectivity.v1.HubService/DeleteSpoke', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteSpokeTest'); - $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 deleteSpokeExceptionTest() - { - $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/deleteSpokeTest'); - $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->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $response = $gapicClient->deleteSpoke($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteSpokeTest'); - 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 getGroupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $uid = 'uid115792'; - $expectedResponse = new Group(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setUid($uid); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->groupName('[PROJECT]', '[HUB]', '[GROUP]'); - $response = $gapicClient->getGroup($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.networkconnectivity.v1.HubService/GetGroup', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getGroupExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $formattedName = $gapicClient->groupName('[PROJECT]', '[HUB]', '[GROUP]'); - try { - $gapicClient->getGroup($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 getHubTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $uniqueId = 'uniqueId-538310583'; - $expectedResponse = new Hub(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setUniqueId($uniqueId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $response = $gapicClient->getHub($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.networkconnectivity.v1.HubService/GetHub', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getHubExceptionTest() - { - $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->hubName('[PROJECT]', '[HUB]'); - try { - $gapicClient->getHub($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 getRouteTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $ipCidrRange = 'ipCidrRange-2049366326'; - $description = 'description-1724546052'; - $uid = 'uid115792'; - $spoke = 'spoke109651596'; - $location = 'location1901043637'; - $expectedResponse = new Route(); - $expectedResponse->setName($name2); - $expectedResponse->setIpCidrRange($ipCidrRange); - $expectedResponse->setDescription($description); - $expectedResponse->setUid($uid); - $expectedResponse->setSpoke($spoke); - $expectedResponse->setLocation($location); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->hubRouteName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]', '[ROUTE]'); - $response = $gapicClient->getRoute($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.networkconnectivity.v1.HubService/GetRoute', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getRouteExceptionTest() - { - $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->hubRouteName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]', '[ROUTE]'); - try { - $gapicClient->getRoute($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 getRouteTableTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $uid = 'uid115792'; - $expectedResponse = new RouteTable(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setUid($uid); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - $response = $gapicClient->getRouteTable($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.networkconnectivity.v1.HubService/GetRouteTable', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getRouteTableExceptionTest() - { - $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->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - try { - $gapicClient->getRouteTable($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 getSpokeTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $hub = 'hub103669'; - $group = 'group98629247'; - $uniqueId = 'uniqueId-538310583'; - $expectedResponse = new Spoke(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setHub($hub); - $expectedResponse->setGroup($group); - $expectedResponse->setUniqueId($uniqueId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $response = $gapicClient->getSpoke($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.networkconnectivity.v1.HubService/GetSpoke', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getSpokeExceptionTest() - { - $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->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - try { - $gapicClient->getSpoke($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 listGroupsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $groupsElement = new Group(); - $groups = [ - $groupsElement, - ]; - $expectedResponse = new ListGroupsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setGroups($groups); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $response = $gapicClient->listGroups($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getGroups()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.HubService/ListGroups', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listGroupsExceptionTest() - { - $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->hubName('[PROJECT]', '[HUB]'); - try { - $gapicClient->listGroups($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 listHubSpokesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $spokesElement = new Spoke(); - $spokes = [ - $spokesElement, - ]; - $expectedResponse = new ListHubSpokesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSpokes($spokes); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $response = $gapicClient->listHubSpokes($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSpokes()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.HubService/ListHubSpokes', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listHubSpokesExceptionTest() - { - $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->hubName('[PROJECT]', '[HUB]'); - try { - $gapicClient->listHubSpokes($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 listHubsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $hubsElement = new Hub(); - $hubs = [ - $hubsElement, - ]; - $expectedResponse = new ListHubsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setHubs($hubs); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listHubs($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getHubs()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.HubService/ListHubs', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listHubsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listHubs($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 listRouteTablesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $routeTablesElement = new RouteTable(); - $routeTables = [ - $routeTablesElement, - ]; - $expectedResponse = new ListRouteTablesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setRouteTables($routeTables); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $response = $gapicClient->listRouteTables($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getRouteTables()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.HubService/ListRouteTables', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listRouteTablesExceptionTest() - { - $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->hubName('[PROJECT]', '[HUB]'); - try { - $gapicClient->listRouteTables($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 listRoutesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $routesElement = new Route(); - $routes = [ - $routesElement, - ]; - $expectedResponse = new ListRoutesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setRoutes($routes); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - $response = $gapicClient->listRoutes($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getRoutes()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.HubService/ListRoutes', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listRoutesExceptionTest() - { - $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->routeTableName('[PROJECT]', '[HUB]', '[ROUTE_TABLE]'); - try { - $gapicClient->listRoutes($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 listSpokesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $spokesElement = new Spoke(); - $spokes = [ - $spokesElement, - ]; - $expectedResponse = new ListSpokesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSpokes($spokes); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listSpokes($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSpokes()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.HubService/ListSpokes', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listSpokesExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listSpokes($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 rejectHubSpokeTest() - { - $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/rejectHubSpokeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new RejectHubSpokeResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/rejectHubSpokeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->hubName('[PROJECT]', '[HUB]'); - $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $response = $gapicClient->rejectHubSpoke($formattedName, $formattedSpokeUri); - $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.networkconnectivity.v1.HubService/RejectHubSpoke', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getSpokeUri(); - $this->assertProtobufEquals($formattedSpokeUri, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/rejectHubSpokeTest'); - $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 rejectHubSpokeExceptionTest() - { - $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/rejectHubSpokeTest'); - $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->hubName('[PROJECT]', '[HUB]'); - $formattedSpokeUri = $gapicClient->spokeName('[PROJECT]', '[LOCATION]', '[SPOKE]'); - $response = $gapicClient->rejectHubSpoke($formattedName, $formattedSpokeUri); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/rejectHubSpokeTest'); - 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 updateHubTest() - { - $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/updateHubTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $uniqueId = 'uniqueId-538310583'; - $expectedResponse = new Hub(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setUniqueId($uniqueId); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateHubTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $hub = new Hub(); - $response = $gapicClient->updateHub($hub); - $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.networkconnectivity.v1.HubService/UpdateHub', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getHub(); - $this->assertProtobufEquals($hub, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateHubTest'); - $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 updateHubExceptionTest() - { - $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/updateHubTest'); - $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 - $hub = new Hub(); - $response = $gapicClient->updateHub($hub); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateHubTest'); - 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 updateSpokeTest() - { - $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/updateSpokeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $hub = 'hub103669'; - $group = 'group98629247'; - $uniqueId = 'uniqueId-538310583'; - $expectedResponse = new Spoke(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setHub($hub); - $expectedResponse->setGroup($group); - $expectedResponse->setUniqueId($uniqueId); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateSpokeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $spoke = new Spoke(); - $response = $gapicClient->updateSpoke($spoke); - $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.networkconnectivity.v1.HubService/UpdateSpoke', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getSpoke(); - $this->assertProtobufEquals($spoke, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateSpokeTest'); - $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 updateSpokeExceptionTest() - { - $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/updateSpokeTest'); - $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 - $spoke = new Spoke(); - $response = $gapicClient->updateSpoke($spoke); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateSpokeTest'); - 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 getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $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); - try { - $gapicClient->getLocation(); - // 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 listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $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); - try { - $gapicClient->listLocations(); - // 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 getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/NetworkConnectivity/tests/Unit/V1/PolicyBasedRoutingServiceClientTest.php b/NetworkConnectivity/tests/Unit/V1/PolicyBasedRoutingServiceClientTest.php deleted file mode 100644 index a69184953eb3..000000000000 --- a/NetworkConnectivity/tests/Unit/V1/PolicyBasedRoutingServiceClientTest.php +++ /dev/null @@ -1,791 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return PolicyBasedRoutingServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new PolicyBasedRoutingServiceClient($options); - } - - /** @test */ - public function createPolicyBasedRouteTest() - { - $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/createPolicyBasedRouteTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $nextHopIlbIp = 'nextHopIlbIp-1739392183'; - $name = 'name3373707'; - $description = 'description-1724546052'; - $network = 'network1843485230'; - $priority = 1165461084; - $selfLink = 'selfLink-1691268851'; - $kind = 'kind3292052'; - $expectedResponse = new PolicyBasedRoute(); - $expectedResponse->setNextHopIlbIp($nextHopIlbIp); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setNetwork($network); - $expectedResponse->setPriority($priority); - $expectedResponse->setSelfLink($selfLink); - $expectedResponse->setKind($kind); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createPolicyBasedRouteTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $policyBasedRouteId = 'policyBasedRouteId-103152502'; - $policyBasedRoute = new PolicyBasedRoute(); - $policyBasedRouteNetwork = $gapicClient->networkName('[PROJECT]', '[RESOURCE_ID]'); - $policyBasedRoute->setNetwork($policyBasedRouteNetwork); - $policyBasedRouteFilter = new Filter(); - $filterProtocolVersion = ProtocolVersion::PROTOCOL_VERSION_UNSPECIFIED; - $policyBasedRouteFilter->setProtocolVersion($filterProtocolVersion); - $policyBasedRoute->setFilter($policyBasedRouteFilter); - $response = $gapicClient->createPolicyBasedRoute($formattedParent, $policyBasedRouteId, $policyBasedRoute); - $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.networkconnectivity.v1.PolicyBasedRoutingService/CreatePolicyBasedRoute', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getPolicyBasedRouteId(); - $this->assertProtobufEquals($policyBasedRouteId, $actualValue); - $actualValue = $actualApiRequestObject->getPolicyBasedRoute(); - $this->assertProtobufEquals($policyBasedRoute, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createPolicyBasedRouteTest'); - $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 createPolicyBasedRouteExceptionTest() - { - $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/createPolicyBasedRouteTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $policyBasedRouteId = 'policyBasedRouteId-103152502'; - $policyBasedRoute = new PolicyBasedRoute(); - $policyBasedRouteNetwork = $gapicClient->networkName('[PROJECT]', '[RESOURCE_ID]'); - $policyBasedRoute->setNetwork($policyBasedRouteNetwork); - $policyBasedRouteFilter = new Filter(); - $filterProtocolVersion = ProtocolVersion::PROTOCOL_VERSION_UNSPECIFIED; - $policyBasedRouteFilter->setProtocolVersion($filterProtocolVersion); - $policyBasedRoute->setFilter($policyBasedRouteFilter); - $response = $gapicClient->createPolicyBasedRoute($formattedParent, $policyBasedRouteId, $policyBasedRoute); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createPolicyBasedRouteTest'); - 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 deletePolicyBasedRouteTest() - { - $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/deletePolicyBasedRouteTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deletePolicyBasedRouteTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - $response = $gapicClient->deletePolicyBasedRoute($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.networkconnectivity.v1.PolicyBasedRoutingService/DeletePolicyBasedRoute', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deletePolicyBasedRouteTest'); - $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 deletePolicyBasedRouteExceptionTest() - { - $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/deletePolicyBasedRouteTest'); - $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->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - $response = $gapicClient->deletePolicyBasedRoute($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deletePolicyBasedRouteTest'); - 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 getPolicyBasedRouteTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextHopIlbIp = 'nextHopIlbIp-1739392183'; - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $network = 'network1843485230'; - $priority = 1165461084; - $selfLink = 'selfLink-1691268851'; - $kind = 'kind3292052'; - $expectedResponse = new PolicyBasedRoute(); - $expectedResponse->setNextHopIlbIp($nextHopIlbIp); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setNetwork($network); - $expectedResponse->setPriority($priority); - $expectedResponse->setSelfLink($selfLink); - $expectedResponse->setKind($kind); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - $response = $gapicClient->getPolicyBasedRoute($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.networkconnectivity.v1.PolicyBasedRoutingService/GetPolicyBasedRoute', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getPolicyBasedRouteExceptionTest() - { - $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->policyBasedRouteName('[PROJECT]', '[POLICY_BASED_ROUTE]'); - try { - $gapicClient->getPolicyBasedRoute($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 listPolicyBasedRoutesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $policyBasedRoutesElement = new PolicyBasedRoute(); - $policyBasedRoutes = [ - $policyBasedRoutesElement, - ]; - $expectedResponse = new ListPolicyBasedRoutesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setPolicyBasedRoutes($policyBasedRoutes); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listPolicyBasedRoutes($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getPolicyBasedRoutes()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/ListPolicyBasedRoutes', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listPolicyBasedRoutesExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listPolicyBasedRoutes($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 getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $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); - try { - $gapicClient->getLocation(); - // 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 listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $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); - try { - $gapicClient->listLocations(); - // 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 getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/NetworkManagement/owlbot.py b/NetworkManagement/owlbot.py index 0db16c32873f..0ebe0e641ff6 100644 --- a/NetworkManagement/owlbot.py +++ b/NetworkManagement/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,32 +41,6 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - # format generated clients subprocess.run([ 'npm', @@ -82,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/NetworkManagement/src/V1/AbortInfo.php b/NetworkManagement/src/V1/AbortInfo.php index b593863f024f..6c89077243d9 100644 --- a/NetworkManagement/src/V1/AbortInfo.php +++ b/NetworkManagement/src/V1/AbortInfo.php @@ -20,19 +20,19 @@ class AbortInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.AbortInfo.Cause cause = 1; */ - private $cause = 0; + protected $cause = 0; /** * URI of the resource that caused the abort. * * Generated from protobuf field string resource_uri = 2; */ - private $resource_uri = ''; + protected $resource_uri = ''; /** * IP address that caused the abort. * * Generated from protobuf field string ip_address = 4 [(.google.api.field_info) = { */ - private $ip_address = ''; + protected $ip_address = ''; /** * List of project IDs the user specified in the request but lacks access to. * In this case, analysis is aborted with the PERMISSION_DENIED cause. diff --git a/NetworkManagement/src/V1/AppEngineVersionInfo.php b/NetworkManagement/src/V1/AppEngineVersionInfo.php index c0379845b847..070e54ea76de 100644 --- a/NetworkManagement/src/V1/AppEngineVersionInfo.php +++ b/NetworkManagement/src/V1/AppEngineVersionInfo.php @@ -20,25 +20,25 @@ class AppEngineVersionInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of an App Engine version. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * Runtime of the App Engine version. * * Generated from protobuf field string runtime = 3; */ - private $runtime = ''; + protected $runtime = ''; /** * App Engine execution environment for a version. * * Generated from protobuf field string environment = 4; */ - private $environment = ''; + protected $environment = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/Client/ReachabilityServiceClient.php b/NetworkManagement/src/V1/Client/ReachabilityServiceClient.php index 52e1d0c3166a..488d77ce1be7 100644 --- a/NetworkManagement/src/V1/Client/ReachabilityServiceClient.php +++ b/NetworkManagement/src/V1/Client/ReachabilityServiceClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a * connectivity_test resource. @@ -309,8 +328,10 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createConnectivityTest(CreateConnectivityTestRequest $request, array $callOptions = []): OperationResponse - { + public function createConnectivityTest( + CreateConnectivityTestRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CreateConnectivityTest', $request, $callOptions)->wait(); } @@ -336,8 +357,10 @@ public function createConnectivityTest(CreateConnectivityTestRequest $request, a * * @throws ApiException Thrown if the API call fails. */ - public function deleteConnectivityTest(DeleteConnectivityTestRequest $request, array $callOptions = []): OperationResponse - { + public function deleteConnectivityTest( + DeleteConnectivityTestRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('DeleteConnectivityTest', $request, $callOptions)->wait(); } @@ -390,8 +413,10 @@ public function getConnectivityTest(GetConnectivityTestRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function listConnectivityTests(ListConnectivityTestsRequest $request, array $callOptions = []): PagedListResponse - { + public function listConnectivityTests( + ListConnectivityTestsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListConnectivityTests', $request, $callOptions); } @@ -428,8 +453,10 @@ public function listConnectivityTests(ListConnectivityTestsRequest $request, arr * * @throws ApiException Thrown if the API call fails. */ - public function rerunConnectivityTest(RerunConnectivityTestRequest $request, array $callOptions = []): OperationResponse - { + public function rerunConnectivityTest( + RerunConnectivityTestRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('RerunConnectivityTest', $request, $callOptions)->wait(); } @@ -468,8 +495,10 @@ public function rerunConnectivityTest(RerunConnectivityTestRequest $request, arr * * @throws ApiException Thrown if the API call fails. */ - public function updateConnectivityTest(UpdateConnectivityTestRequest $request, array $callOptions = []): OperationResponse - { + public function updateConnectivityTest( + UpdateConnectivityTestRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('UpdateConnectivityTest', $request, $callOptions)->wait(); } @@ -610,8 +639,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/NetworkManagement/src/V1/CloudFunctionInfo.php b/NetworkManagement/src/V1/CloudFunctionInfo.php index 9613577f5ad8..0706272a11a9 100644 --- a/NetworkManagement/src/V1/CloudFunctionInfo.php +++ b/NetworkManagement/src/V1/CloudFunctionInfo.php @@ -20,25 +20,25 @@ class CloudFunctionInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a Cloud Function. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * Location in which the Cloud Function is deployed. * * Generated from protobuf field string location = 3; */ - private $location = ''; + protected $location = ''; /** * Latest successfully deployed version id of the Cloud Function. * * Generated from protobuf field int64 version_id = 4; */ - private $version_id = 0; + protected $version_id = 0; /** * Constructor. diff --git a/NetworkManagement/src/V1/CloudRunRevisionInfo.php b/NetworkManagement/src/V1/CloudRunRevisionInfo.php index 342ad18caaf1..4848d1718d60 100644 --- a/NetworkManagement/src/V1/CloudRunRevisionInfo.php +++ b/NetworkManagement/src/V1/CloudRunRevisionInfo.php @@ -20,25 +20,25 @@ class CloudRunRevisionInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a Cloud Run revision. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * Location in which this revision is deployed. * * Generated from protobuf field string location = 4; */ - private $location = ''; + protected $location = ''; /** * URI of Cloud Run service this revision belongs to. * * Generated from protobuf field string service_uri = 5; */ - private $service_uri = ''; + protected $service_uri = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/CloudSQLInstanceInfo.php b/NetworkManagement/src/V1/CloudSQLInstanceInfo.php index c13ffbfa563c..6dc47236ce8f 100644 --- a/NetworkManagement/src/V1/CloudSQLInstanceInfo.php +++ b/NetworkManagement/src/V1/CloudSQLInstanceInfo.php @@ -20,38 +20,38 @@ class CloudSQLInstanceInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a Cloud SQL instance. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * URI of a Cloud SQL instance network or empty string if the instance does * not have one. * * Generated from protobuf field string network_uri = 4; */ - private $network_uri = ''; + protected $network_uri = ''; /** * Internal IP address of a Cloud SQL instance. * * Generated from protobuf field string internal_ip = 5; */ - private $internal_ip = ''; + protected $internal_ip = ''; /** * External IP address of a Cloud SQL instance. * * Generated from protobuf field string external_ip = 6; */ - private $external_ip = ''; + protected $external_ip = ''; /** * Region in which the Cloud SQL instance is running. * * Generated from protobuf field string region = 7; */ - private $region = ''; + protected $region = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/ConnectivityTest.php b/NetworkManagement/src/V1/ConnectivityTest.php index b66913a23271..d2eb35c0ac04 100644 --- a/NetworkManagement/src/V1/ConnectivityTest.php +++ b/NetworkManagement/src/V1/ConnectivityTest.php @@ -21,14 +21,14 @@ class ConnectivityTest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * The user-supplied description of the Connectivity Test. * Maximum of 512 characters. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * Required. Source specification of the Connectivity Test. * You can use a combination of source IP address, virtual machine @@ -50,7 +50,7 @@ class ConnectivityTest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.Endpoint source = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $source = null; + protected $source = null; /** * Required. Destination specification of the Connectivity Test. * You can use a combination of destination IP address, Compute Engine @@ -69,13 +69,13 @@ class ConnectivityTest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.Endpoint destination = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $destination = null; + protected $destination = null; /** * IP Protocol of the test. When not provided, "TCP" is assumed. * * Generated from protobuf field string protocol = 5; */ - private $protocol = ''; + protected $protocol = ''; /** * Other projects that may be relevant for reachability analysis. * This is applicable to scenarios where a test can cross project boundaries. @@ -88,7 +88,7 @@ class ConnectivityTest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $display_name = ''; + protected $display_name = ''; /** * Resource labels to represent user-provided metadata. * @@ -100,13 +100,13 @@ class ConnectivityTest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time the test's configuration was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Output only. The reachability details of this test from the latest run. * The details are updated when creating a new test, updating an @@ -114,7 +114,7 @@ class ConnectivityTest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.ReachabilityDetails reachability_details = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $reachability_details = null; + protected $reachability_details = null; /** * Output only. The probing details of this test from the latest run, present * for applicable tests only. The details are updated when creating a new @@ -123,14 +123,14 @@ class ConnectivityTest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.ProbingDetails probing_details = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $probing_details = null; + protected $probing_details = null; /** * Whether the test should skip firewall checking. * If not provided, we assume false. * * Generated from protobuf field bool bypass_firewall_checks = 17; */ - private $bypass_firewall_checks = false; + protected $bypass_firewall_checks = false; /** * Constructor. diff --git a/NetworkManagement/src/V1/CreateConnectivityTestRequest.php b/NetworkManagement/src/V1/CreateConnectivityTestRequest.php index 4fd1e5ae471b..04926c31350f 100644 --- a/NetworkManagement/src/V1/CreateConnectivityTestRequest.php +++ b/NetworkManagement/src/V1/CreateConnectivityTestRequest.php @@ -21,7 +21,7 @@ class CreateConnectivityTestRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $parent = ''; + protected $parent = ''; /** * Required. The logical name of the Connectivity Test in your project * with the following restrictions: @@ -33,13 +33,13 @@ class CreateConnectivityTestRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string test_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $test_id = ''; + protected $test_id = ''; /** * Required. A `ConnectivityTest` resource * * Generated from protobuf field .google.cloud.networkmanagement.v1.ConnectivityTest resource = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $resource = null; + protected $resource = null; /** * @param string $parent Required. The parent resource of the Connectivity Test to create: diff --git a/NetworkManagement/src/V1/DeleteConnectivityTestRequest.php b/NetworkManagement/src/V1/DeleteConnectivityTestRequest.php index cbf12a6d6a56..e5318082aa1f 100644 --- a/NetworkManagement/src/V1/DeleteConnectivityTestRequest.php +++ b/NetworkManagement/src/V1/DeleteConnectivityTestRequest.php @@ -21,7 +21,7 @@ class DeleteConnectivityTestRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Connectivity Test resource name using the form: diff --git a/NetworkManagement/src/V1/DeliverInfo.php b/NetworkManagement/src/V1/DeliverInfo.php index 0db79fde2603..89bf7090122b 100644 --- a/NetworkManagement/src/V1/DeliverInfo.php +++ b/NetworkManagement/src/V1/DeliverInfo.php @@ -20,19 +20,19 @@ class DeliverInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.DeliverInfo.Target target = 1; */ - private $target = 0; + protected $target = 0; /** * URI of the resource that the packet is delivered to. * * Generated from protobuf field string resource_uri = 2; */ - private $resource_uri = ''; + protected $resource_uri = ''; /** * IP address of the target (if applicable). * * Generated from protobuf field string ip_address = 3 [(.google.api.field_info) = { */ - private $ip_address = ''; + protected $ip_address = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/DropInfo.php b/NetworkManagement/src/V1/DropInfo.php index 7c242bb56e5c..b8cb02168001 100644 --- a/NetworkManagement/src/V1/DropInfo.php +++ b/NetworkManagement/src/V1/DropInfo.php @@ -20,31 +20,31 @@ class DropInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.DropInfo.Cause cause = 1; */ - private $cause = 0; + protected $cause = 0; /** * URI of the resource that caused the drop. * * Generated from protobuf field string resource_uri = 2; */ - private $resource_uri = ''; + protected $resource_uri = ''; /** * Source IP address of the dropped packet (if relevant). * * Generated from protobuf field string source_ip = 3; */ - private $source_ip = ''; + protected $source_ip = ''; /** * Destination IP address of the dropped packet (if relevant). * * Generated from protobuf field string destination_ip = 4; */ - private $destination_ip = ''; + protected $destination_ip = ''; /** * Region of the dropped packet (if relevant). * * Generated from protobuf field string region = 5; */ - private $region = ''; + protected $region = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/Endpoint.php b/NetworkManagement/src/V1/Endpoint.php index 7dea81ef5bac..882249111f50 100644 --- a/NetworkManagement/src/V1/Endpoint.php +++ b/NetworkManagement/src/V1/Endpoint.php @@ -20,20 +20,20 @@ class Endpoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string ip_address = 1; */ - private $ip_address = ''; + protected $ip_address = ''; /** * The IP protocol port of the endpoint. * Only applicable when protocol is TCP or UDP. * * Generated from protobuf field int32 port = 2; */ - private $port = 0; + protected $port = 0; /** * A Compute Engine instance URI. * * Generated from protobuf field string instance = 3; */ - private $instance = ''; + protected $instance = ''; /** * A forwarding rule and its corresponding IP address represent the frontend * configuration of a Google Cloud load balancer. Forwarding rules are also @@ -44,65 +44,65 @@ class Endpoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string forwarding_rule = 13; */ - private $forwarding_rule = ''; + protected $forwarding_rule = ''; /** * Output only. Specifies the type of the target of the forwarding rule. * * Generated from protobuf field optional .google.cloud.networkmanagement.v1.Endpoint.ForwardingRuleTarget forwarding_rule_target = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $forwarding_rule_target = null; + protected $forwarding_rule_target = null; /** * Output only. ID of the load balancer the forwarding rule points to. Empty * for forwarding rules not related to load balancers. * * Generated from protobuf field optional string load_balancer_id = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $load_balancer_id = null; + protected $load_balancer_id = null; /** * Output only. Type of the load balancer the forwarding rule points to. * * Generated from protobuf field optional .google.cloud.networkmanagement.v1.LoadBalancerType load_balancer_type = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $load_balancer_type = null; + protected $load_balancer_type = null; /** * A cluster URI for [Google Kubernetes Engine * master](https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture). * * Generated from protobuf field string gke_master_cluster = 7; */ - private $gke_master_cluster = ''; + protected $gke_master_cluster = ''; /** * A [Cloud SQL](https://cloud.google.com/sql) instance URI. * * Generated from protobuf field string cloud_sql_instance = 8; */ - private $cloud_sql_instance = ''; + protected $cloud_sql_instance = ''; /** * A [Cloud Function](https://cloud.google.com/functions). * * Generated from protobuf field .google.cloud.networkmanagement.v1.Endpoint.CloudFunctionEndpoint cloud_function = 10; */ - private $cloud_function = null; + protected $cloud_function = null; /** * An [App Engine](https://cloud.google.com/appengine) [service * version](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions). * * Generated from protobuf field .google.cloud.networkmanagement.v1.Endpoint.AppEngineVersionEndpoint app_engine_version = 11; */ - private $app_engine_version = null; + protected $app_engine_version = null; /** * A [Cloud Run](https://cloud.google.com/run) * [revision](https://cloud.google.com/run/docs/reference/rest/v1/namespaces.revisions/get) * * Generated from protobuf field .google.cloud.networkmanagement.v1.Endpoint.CloudRunRevisionEndpoint cloud_run_revision = 12; */ - private $cloud_run_revision = null; + protected $cloud_run_revision = null; /** * A Compute Engine network URI. * * Generated from protobuf field string network = 4; */ - private $network = ''; + protected $network = ''; /** * Type of the network where the endpoint is located. * Applicable only to source endpoint, as destination network type can be @@ -110,7 +110,7 @@ class Endpoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.Endpoint.NetworkType network_type = 5; */ - private $network_type = 0; + protected $network_type = 0; /** * Project ID where the endpoint is located. * The Project ID can be derived from the URI if you provide a VM instance or @@ -124,7 +124,7 @@ class Endpoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string project_id = 6; */ - private $project_id = ''; + protected $project_id = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/Endpoint/AppEngineVersionEndpoint.php b/NetworkManagement/src/V1/Endpoint/AppEngineVersionEndpoint.php index 558dbd45a865..b4e0f24efe22 100644 --- a/NetworkManagement/src/V1/Endpoint/AppEngineVersionEndpoint.php +++ b/NetworkManagement/src/V1/Endpoint/AppEngineVersionEndpoint.php @@ -22,7 +22,7 @@ class AppEngineVersionEndpoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uri = 1; */ - private $uri = ''; + protected $uri = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/Endpoint/CloudFunctionEndpoint.php b/NetworkManagement/src/V1/Endpoint/CloudFunctionEndpoint.php index fd78e156970f..d8969f1df7e9 100644 --- a/NetworkManagement/src/V1/Endpoint/CloudFunctionEndpoint.php +++ b/NetworkManagement/src/V1/Endpoint/CloudFunctionEndpoint.php @@ -20,7 +20,7 @@ class CloudFunctionEndpoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uri = 1; */ - private $uri = ''; + protected $uri = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/Endpoint/CloudRunRevisionEndpoint.php b/NetworkManagement/src/V1/Endpoint/CloudRunRevisionEndpoint.php index 679c41dbf334..9851497d0f5f 100644 --- a/NetworkManagement/src/V1/Endpoint/CloudRunRevisionEndpoint.php +++ b/NetworkManagement/src/V1/Endpoint/CloudRunRevisionEndpoint.php @@ -23,7 +23,7 @@ class CloudRunRevisionEndpoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uri = 1; */ - private $uri = ''; + protected $uri = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/EndpointInfo.php b/NetworkManagement/src/V1/EndpointInfo.php index 2add6dc1f2a0..d87bc1cea5b2 100644 --- a/NetworkManagement/src/V1/EndpointInfo.php +++ b/NetworkManagement/src/V1/EndpointInfo.php @@ -22,49 +22,49 @@ class EndpointInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_ip = 1; */ - private $source_ip = ''; + protected $source_ip = ''; /** * Destination IP address. * * Generated from protobuf field string destination_ip = 2; */ - private $destination_ip = ''; + protected $destination_ip = ''; /** * IP protocol in string format, for example: "TCP", "UDP", "ICMP". * * Generated from protobuf field string protocol = 3; */ - private $protocol = ''; + protected $protocol = ''; /** * Source port. Only valid when protocol is TCP or UDP. * * Generated from protobuf field int32 source_port = 4; */ - private $source_port = 0; + protected $source_port = 0; /** * Destination port. Only valid when protocol is TCP or UDP. * * Generated from protobuf field int32 destination_port = 5; */ - private $destination_port = 0; + protected $destination_port = 0; /** * URI of the network where this packet originates from. * * Generated from protobuf field string source_network_uri = 6; */ - private $source_network_uri = ''; + protected $source_network_uri = ''; /** * URI of the network where this packet is sent to. * * Generated from protobuf field string destination_network_uri = 7; */ - private $destination_network_uri = ''; + protected $destination_network_uri = ''; /** * URI of the source telemetry agent this packet originates from. * * Generated from protobuf field string source_agent_uri = 8; */ - private $source_agent_uri = ''; + protected $source_agent_uri = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/FirewallInfo.php b/NetworkManagement/src/V1/FirewallInfo.php index ff173ddc6107..116158a17d76 100644 --- a/NetworkManagement/src/V1/FirewallInfo.php +++ b/NetworkManagement/src/V1/FirewallInfo.php @@ -22,39 +22,39 @@ class FirewallInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * The URI of the VPC firewall rule. This field is not applicable to * implied firewall rules or hierarchical firewall policy rules. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * Possible values: INGRESS, EGRESS * * Generated from protobuf field string direction = 3; */ - private $direction = ''; + protected $direction = ''; /** * Possible values: ALLOW, DENY, APPLY_SECURITY_PROFILE_GROUP * * Generated from protobuf field string action = 4; */ - private $action = ''; + protected $action = ''; /** * The priority of the firewall rule. * * Generated from protobuf field int32 priority = 5; */ - private $priority = 0; + protected $priority = 0; /** * The URI of the VPC network that the firewall rule is associated with. * This field is not applicable to hierarchical firewall policy rules. * * Generated from protobuf field string network_uri = 6; */ - private $network_uri = ''; + protected $network_uri = ''; /** * The target tags defined by the VPC firewall rule. This field is not * applicable to hierarchical firewall policy rules. @@ -74,13 +74,13 @@ class FirewallInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string policy = 9; */ - private $policy = ''; + protected $policy = ''; /** * The firewall rule's type. * * Generated from protobuf field .google.cloud.networkmanagement.v1.FirewallInfo.FirewallRuleType firewall_rule_type = 10; */ - private $firewall_rule_type = 0; + protected $firewall_rule_type = 0; /** * Constructor. diff --git a/NetworkManagement/src/V1/ForwardInfo.php b/NetworkManagement/src/V1/ForwardInfo.php index 4cf237f2a403..f2c3ac4705a2 100644 --- a/NetworkManagement/src/V1/ForwardInfo.php +++ b/NetworkManagement/src/V1/ForwardInfo.php @@ -20,19 +20,19 @@ class ForwardInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.ForwardInfo.Target target = 1; */ - private $target = 0; + protected $target = 0; /** * URI of the resource that the packet is forwarded to. * * Generated from protobuf field string resource_uri = 2; */ - private $resource_uri = ''; + protected $resource_uri = ''; /** * IP address of the target (if applicable). * * Generated from protobuf field string ip_address = 3 [(.google.api.field_info) = { */ - private $ip_address = ''; + protected $ip_address = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/ForwardingRuleInfo.php b/NetworkManagement/src/V1/ForwardingRuleInfo.php index 967312fd4eb5..14cffe6e3ef0 100644 --- a/NetworkManagement/src/V1/ForwardingRuleInfo.php +++ b/NetworkManagement/src/V1/ForwardingRuleInfo.php @@ -20,43 +20,43 @@ class ForwardingRuleInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a Compute Engine forwarding rule. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * Protocol defined in the forwarding rule that matches the test. * * Generated from protobuf field string matched_protocol = 3; */ - private $matched_protocol = ''; + protected $matched_protocol = ''; /** * Port range defined in the forwarding rule that matches the test. * * Generated from protobuf field string matched_port_range = 6; */ - private $matched_port_range = ''; + protected $matched_port_range = ''; /** * VIP of the forwarding rule. * * Generated from protobuf field string vip = 4; */ - private $vip = ''; + protected $vip = ''; /** * Target type of the forwarding rule. * * Generated from protobuf field string target = 5; */ - private $target = ''; + protected $target = ''; /** * Network URI. Only valid for Internal Load Balancer. * * Generated from protobuf field string network_uri = 7; */ - private $network_uri = ''; + protected $network_uri = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/GKEMasterInfo.php b/NetworkManagement/src/V1/GKEMasterInfo.php index c305efae19b8..f5973a802e12 100644 --- a/NetworkManagement/src/V1/GKEMasterInfo.php +++ b/NetworkManagement/src/V1/GKEMasterInfo.php @@ -21,25 +21,25 @@ class GKEMasterInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cluster_uri = 2; */ - private $cluster_uri = ''; + protected $cluster_uri = ''; /** * URI of a GKE cluster network. * * Generated from protobuf field string cluster_network_uri = 4; */ - private $cluster_network_uri = ''; + protected $cluster_network_uri = ''; /** * Internal IP address of a GKE cluster master. * * Generated from protobuf field string internal_ip = 5; */ - private $internal_ip = ''; + protected $internal_ip = ''; /** * External IP address of a GKE cluster master. * * Generated from protobuf field string external_ip = 6; */ - private $external_ip = ''; + protected $external_ip = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/Gapic/ReachabilityServiceGapicClient.php b/NetworkManagement/src/V1/Gapic/ReachabilityServiceGapicClient.php deleted file mode 100644 index 52fef47f01ae..000000000000 --- a/NetworkManagement/src/V1/Gapic/ReachabilityServiceGapicClient.php +++ /dev/null @@ -1,1202 +0,0 @@ -createConnectivityTest($parent, $testId, $resource); - * $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 = $reachabilityServiceClient->createConnectivityTest($parent, $testId, $resource); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $reachabilityServiceClient->resumeOperation($operationName, 'createConnectivityTest'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $reachabilityServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\NetworkManagement\V1\Client\ReachabilityServiceClient}. - */ -class ReachabilityServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.networkmanagement.v1.ReachabilityService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'networkmanagement.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'networkmanagement.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $connectivityTestNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getConnectivityTestNameTemplate() - { - if (self::$connectivityTestNameTemplate == null) { - self::$connectivityTestNameTemplate = new PathTemplate( - 'projects/{project}/locations/global/connectivityTests/{test}' - ); - } - - return self::$connectivityTestNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'connectivityTest' => self::getConnectivityTestNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $test) - { - return self::getConnectivityTestNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * 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. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $parent = 'parent'; - * $testId = 'test_id'; - * $resource = new ConnectivityTest(); - * $operationResponse = $reachabilityServiceClient->createConnectivityTest($parent, $testId, $resource); - * $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 = $reachabilityServiceClient->createConnectivityTest($parent, $testId, $resource); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $reachabilityServiceClient->resumeOperation($operationName, 'createConnectivityTest'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the Connectivity Test to create: - * `projects/{project_id}/locations/global` - * @param string $testId Required. The logical name of the Connectivity Test in your project - * with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project - * @param ConnectivityTest $resource Required. A `ConnectivityTest` resource - * @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 createConnectivityTest( - $parent, - $testId, - $resource, - array $optionalArgs = [] - ) { - $request = new CreateConnectivityTestRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTestId($testId); - $request->setResource($resource); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateConnectivityTest', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a specific `ConnectivityTest`. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $name = 'name'; - * $operationResponse = $reachabilityServiceClient->deleteConnectivityTest($name); - * $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 = $reachabilityServiceClient->deleteConnectivityTest($name); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $reachabilityServiceClient->resumeOperation($operationName, 'deleteConnectivityTest'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Connectivity Test resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_id}` - * @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 deleteConnectivityTest($name, array $optionalArgs = []) - { - $request = new DeleteConnectivityTestRequest(); - $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( - 'DeleteConnectivityTest', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets the details of a specific Connectivity Test. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $name = 'name'; - * $response = $reachabilityServiceClient->getConnectivityTest($name); - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param string $name Required. `ConnectivityTest` resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_id}` - * @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\NetworkManagement\V1\ConnectivityTest - * - * @throws ApiException if the remote call fails - */ - public function getConnectivityTest($name, array $optionalArgs = []) - { - $request = new GetConnectivityTestRequest(); - $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( - 'GetConnectivityTest', - ConnectivityTest::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists all Connectivity Tests owned by a project. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $parent = 'parent'; - * // Iterate over pages of elements - * $pagedResponse = $reachabilityServiceClient->listConnectivityTests($parent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $reachabilityServiceClient->listConnectivityTests($parent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource of the Connectivity Tests: - * `projects/{project_id}/locations/global` - * @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 string $filter - * Lists the `ConnectivityTests` that match the filter expression. A filter - * expression filters the resources listed in the response. The expression - * must be of the form ` ` where operators: `<`, `>`, - * `<=`, - * `>=`, - * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is - * roughly synonymous with equality). can refer to a proto or JSON - * field, or a synthetic field. Field names can be camelCase or snake_case. - * - * Examples: - * - Filter by name: - * name = "projects/proj-1/locations/global/connectivityTests/test-1 - * - * - Filter by labels: - * - Resources that have a key called `foo` - * labels.foo:* - * - Resources that have a key called `foo` whose value is `bar` - * labels.foo = bar - * @type string $orderBy - * Field to use to sort the list. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listConnectivityTests($parent, array $optionalArgs = []) - { - $request = new ListConnectivityTestsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListConnectivityTests', - $optionalArgs, - ListConnectivityTestsResponse::class, - $request - ); - } - - /** - * 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`. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $name = 'name'; - * $operationResponse = $reachabilityServiceClient->rerunConnectivityTest($name); - * $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 = $reachabilityServiceClient->rerunConnectivityTest($name); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $reachabilityServiceClient->resumeOperation($operationName, 'rerunConnectivityTest'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Connectivity Test resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_id}` - * @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 rerunConnectivityTest($name, array $optionalArgs = []) - { - $request = new RerunConnectivityTestRequest(); - $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( - 'RerunConnectivityTest', - $optionalArgs, - $request, - $this->getOperationsClient() - )->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. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $resource = new ConnectivityTest(); - * $operationResponse = $reachabilityServiceClient->updateConnectivityTest($updateMask, $resource); - * $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 = $reachabilityServiceClient->updateConnectivityTest($updateMask, $resource); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $reachabilityServiceClient->resumeOperation($operationName, 'updateConnectivityTest'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Mask of fields to update. At least one path must be supplied in - * this field. - * @param ConnectivityTest $resource Required. Only fields specified in update_mask are updated. - * @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 updateConnectivityTest( - $updateMask, - $resource, - array $optionalArgs = [] - ) { - $request = new UpdateConnectivityTestRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setResource($resource); - $requestParamHeaders['resource.name'] = $resource->getName(); - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateConnectivityTest', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $response = $reachabilityServiceClient->getLocation(); - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $reachabilityServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $reachabilityServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * 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 RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $resource = 'resource'; - * $response = $reachabilityServiceClient->getIamPolicy($resource); - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $reachabilityServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->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. - * - * Sample code: - * ``` - * $reachabilityServiceClient = new ReachabilityServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $reachabilityServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $reachabilityServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/NetworkManagement/src/V1/GetConnectivityTestRequest.php b/NetworkManagement/src/V1/GetConnectivityTestRequest.php index 6d6bbaa41ace..d85b7ebb7475 100644 --- a/NetworkManagement/src/V1/GetConnectivityTestRequest.php +++ b/NetworkManagement/src/V1/GetConnectivityTestRequest.php @@ -21,7 +21,7 @@ class GetConnectivityTestRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. `ConnectivityTest` resource name using the form: diff --git a/NetworkManagement/src/V1/GoogleServiceInfo.php b/NetworkManagement/src/V1/GoogleServiceInfo.php index 31fc1d500f54..d402ca6ee52f 100644 --- a/NetworkManagement/src/V1/GoogleServiceInfo.php +++ b/NetworkManagement/src/V1/GoogleServiceInfo.php @@ -24,13 +24,13 @@ class GoogleServiceInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_ip = 1; */ - private $source_ip = ''; + protected $source_ip = ''; /** * Recognized type of a Google Service. * * Generated from protobuf field .google.cloud.networkmanagement.v1.GoogleServiceInfo.GoogleServiceType google_service_type = 2; */ - private $google_service_type = 0; + protected $google_service_type = 0; /** * Constructor. diff --git a/NetworkManagement/src/V1/InstanceInfo.php b/NetworkManagement/src/V1/InstanceInfo.php index e944be278408..0dab4eebffcc 100644 --- a/NetworkManagement/src/V1/InstanceInfo.php +++ b/NetworkManagement/src/V1/InstanceInfo.php @@ -20,37 +20,37 @@ class InstanceInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a Compute Engine instance. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * Name of the network interface of a Compute Engine instance. * * Generated from protobuf field string interface = 3; */ - private $interface = ''; + protected $interface = ''; /** * URI of a Compute Engine network. * * Generated from protobuf field string network_uri = 4; */ - private $network_uri = ''; + protected $network_uri = ''; /** * Internal IP address of the network interface. * * Generated from protobuf field string internal_ip = 5; */ - private $internal_ip = ''; + protected $internal_ip = ''; /** * External IP address of the network interface. * * Generated from protobuf field string external_ip = 6; */ - private $external_ip = ''; + protected $external_ip = ''; /** * Network tags configured on the instance. * diff --git a/NetworkManagement/src/V1/LatencyPercentile.php b/NetworkManagement/src/V1/LatencyPercentile.php index 4e2fd48e530d..850e7f81bad8 100644 --- a/NetworkManagement/src/V1/LatencyPercentile.php +++ b/NetworkManagement/src/V1/LatencyPercentile.php @@ -20,7 +20,7 @@ class LatencyPercentile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 percent = 1; */ - private $percent = 0; + protected $percent = 0; /** * percent-th percentile of latency observed, in microseconds. * Fraction of percent/100 of samples have latency lower or @@ -28,7 +28,7 @@ class LatencyPercentile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 latency_micros = 2; */ - private $latency_micros = 0; + protected $latency_micros = 0; /** * Constructor. diff --git a/NetworkManagement/src/V1/ListConnectivityTestsRequest.php b/NetworkManagement/src/V1/ListConnectivityTestsRequest.php index d0d328a20473..caa5de5fb4f7 100644 --- a/NetworkManagement/src/V1/ListConnectivityTestsRequest.php +++ b/NetworkManagement/src/V1/ListConnectivityTestsRequest.php @@ -21,19 +21,19 @@ class ListConnectivityTestsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $parent = ''; + protected $parent = ''; /** * Number of `ConnectivityTests` to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Page token from an earlier query, as returned in `next_page_token`. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * Lists the `ConnectivityTests` that match the filter expression. A filter * expression filters the resources listed in the response. The expression @@ -54,13 +54,13 @@ class ListConnectivityTestsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * Field to use to sort the list. * * Generated from protobuf field string order_by = 5; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The parent resource of the Connectivity Tests: diff --git a/NetworkManagement/src/V1/ListConnectivityTestsResponse.php b/NetworkManagement/src/V1/ListConnectivityTestsResponse.php index 2c260c011020..c026cd03326a 100644 --- a/NetworkManagement/src/V1/ListConnectivityTestsResponse.php +++ b/NetworkManagement/src/V1/ListConnectivityTestsResponse.php @@ -26,7 +26,7 @@ class ListConnectivityTestsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations that could not be reached (when querying all locations with `-`). * diff --git a/NetworkManagement/src/V1/LoadBalancerBackend.php b/NetworkManagement/src/V1/LoadBalancerBackend.php index d52667fc1382..b4b0114164fb 100644 --- a/NetworkManagement/src/V1/LoadBalancerBackend.php +++ b/NetworkManagement/src/V1/LoadBalancerBackend.php @@ -20,19 +20,19 @@ class LoadBalancerBackend extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a Compute Engine instance or network endpoint. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * State of the health check firewall configuration. * * Generated from protobuf field .google.cloud.networkmanagement.v1.LoadBalancerBackend.HealthCheckFirewallState health_check_firewall_state = 3; */ - private $health_check_firewall_state = 0; + protected $health_check_firewall_state = 0; /** * A list of firewall rule URIs allowing probes from health check IP ranges. * diff --git a/NetworkManagement/src/V1/LoadBalancerBackendInfo.php b/NetworkManagement/src/V1/LoadBalancerBackendInfo.php index af3cbff5cd2c..0fb0d2efa27b 100644 --- a/NetworkManagement/src/V1/LoadBalancerBackendInfo.php +++ b/NetworkManagement/src/V1/LoadBalancerBackendInfo.php @@ -22,57 +22,57 @@ class LoadBalancerBackendInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * URI of the backend instance (if applicable). Populated for instance group * backends, and zonal NEG backends. * * Generated from protobuf field string instance_uri = 2; */ - private $instance_uri = ''; + protected $instance_uri = ''; /** * URI of the backend service this backend belongs to (if applicable). * * Generated from protobuf field string backend_service_uri = 3; */ - private $backend_service_uri = ''; + protected $backend_service_uri = ''; /** * URI of the instance group this backend belongs to (if applicable). * * Generated from protobuf field string instance_group_uri = 4; */ - private $instance_group_uri = ''; + protected $instance_group_uri = ''; /** * URI of the network endpoint group this backend belongs to (if applicable). * * Generated from protobuf field string network_endpoint_group_uri = 5; */ - private $network_endpoint_group_uri = ''; + protected $network_endpoint_group_uri = ''; /** * URI of the backend bucket this backend targets (if applicable). * * Generated from protobuf field string backend_bucket_uri = 8; */ - private $backend_bucket_uri = ''; + protected $backend_bucket_uri = ''; /** * URI of the PSC service attachment this PSC NEG backend targets (if * applicable). * * Generated from protobuf field string psc_service_attachment_uri = 9; */ - private $psc_service_attachment_uri = ''; + protected $psc_service_attachment_uri = ''; /** * PSC Google API target this PSC NEG backend targets (if applicable). * * Generated from protobuf field string psc_google_api_target = 10; */ - private $psc_google_api_target = ''; + protected $psc_google_api_target = ''; /** * URI of the health check attached to this backend (if applicable). * * Generated from protobuf field string health_check_uri = 6; */ - private $health_check_uri = ''; + protected $health_check_uri = ''; /** * Output only. Health check firewalls configuration state for the backend. * This is a result of the static firewall analysis (verifying that health @@ -83,7 +83,7 @@ class LoadBalancerBackendInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.LoadBalancerBackendInfo.HealthCheckFirewallsConfigState health_check_firewalls_config_state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $health_check_firewalls_config_state = 0; + protected $health_check_firewalls_config_state = 0; /** * Constructor. diff --git a/NetworkManagement/src/V1/LoadBalancerInfo.php b/NetworkManagement/src/V1/LoadBalancerInfo.php index f659cf4cadb4..a2d316979dcf 100644 --- a/NetworkManagement/src/V1/LoadBalancerInfo.php +++ b/NetworkManagement/src/V1/LoadBalancerInfo.php @@ -20,7 +20,7 @@ class LoadBalancerInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.LoadBalancerInfo.LoadBalancerType load_balancer_type = 1; */ - private $load_balancer_type = 0; + protected $load_balancer_type = 0; /** * URI of the health check for the load balancer. Deprecated and no longer * populated as different load balancer backends might have different health @@ -41,13 +41,13 @@ class LoadBalancerInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.LoadBalancerInfo.BackendType backend_type = 4; */ - private $backend_type = 0; + protected $backend_type = 0; /** * Backend configuration URI. * * Generated from protobuf field string backend_uri = 5; */ - private $backend_uri = ''; + protected $backend_uri = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/NatInfo.php b/NetworkManagement/src/V1/NatInfo.php index 10d6b416ca10..0b290c387878 100644 --- a/NetworkManagement/src/V1/NatInfo.php +++ b/NetworkManagement/src/V1/NatInfo.php @@ -20,81 +20,81 @@ class NatInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.NatInfo.Type type = 1; */ - private $type = 0; + protected $type = 0; /** * IP protocol in string format, for example: "TCP", "UDP", "ICMP". * * Generated from protobuf field string protocol = 2; */ - private $protocol = ''; + protected $protocol = ''; /** * URI of the network where NAT translation takes place. * * Generated from protobuf field string network_uri = 3; */ - private $network_uri = ''; + protected $network_uri = ''; /** * Source IP address before NAT translation. * * Generated from protobuf field string old_source_ip = 4; */ - private $old_source_ip = ''; + protected $old_source_ip = ''; /** * Source IP address after NAT translation. * * Generated from protobuf field string new_source_ip = 5; */ - private $new_source_ip = ''; + protected $new_source_ip = ''; /** * Destination IP address before NAT translation. * * Generated from protobuf field string old_destination_ip = 6; */ - private $old_destination_ip = ''; + protected $old_destination_ip = ''; /** * Destination IP address after NAT translation. * * Generated from protobuf field string new_destination_ip = 7; */ - private $new_destination_ip = ''; + protected $new_destination_ip = ''; /** * Source port before NAT translation. Only valid when protocol is TCP or UDP. * * Generated from protobuf field int32 old_source_port = 8; */ - private $old_source_port = 0; + protected $old_source_port = 0; /** * Source port after NAT translation. Only valid when protocol is TCP or UDP. * * Generated from protobuf field int32 new_source_port = 9; */ - private $new_source_port = 0; + protected $new_source_port = 0; /** * Destination port before NAT translation. Only valid when protocol is TCP or * UDP. * * Generated from protobuf field int32 old_destination_port = 10; */ - private $old_destination_port = 0; + protected $old_destination_port = 0; /** * Destination port after NAT translation. Only valid when protocol is TCP or * UDP. * * Generated from protobuf field int32 new_destination_port = 11; */ - private $new_destination_port = 0; + protected $new_destination_port = 0; /** * Uri of the Cloud Router. Only valid when type is CLOUD_NAT. * * Generated from protobuf field string router_uri = 12; */ - private $router_uri = ''; + protected $router_uri = ''; /** * The name of Cloud NAT Gateway. Only valid when type is CLOUD_NAT. * * Generated from protobuf field string nat_gateway_name = 13; */ - private $nat_gateway_name = ''; + protected $nat_gateway_name = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/NetworkInfo.php b/NetworkManagement/src/V1/NetworkInfo.php index 890a77ddcd68..55f66ee49157 100644 --- a/NetworkManagement/src/V1/NetworkInfo.php +++ b/NetworkManagement/src/V1/NetworkInfo.php @@ -20,19 +20,19 @@ class NetworkInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a Compute Engine network. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * The IP range that matches the test. * * Generated from protobuf field string matched_ip_range = 4; */ - private $matched_ip_range = ''; + protected $matched_ip_range = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/OperationMetadata.php b/NetworkManagement/src/V1/OperationMetadata.php index c3f8d7178c66..c063a6d1f374 100644 --- a/NetworkManagement/src/V1/OperationMetadata.php +++ b/NetworkManagement/src/V1/OperationMetadata.php @@ -20,44 +20,44 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; */ - private $create_time = null; + protected $create_time = null; /** * The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2; */ - private $end_time = null; + protected $end_time = null; /** * Target of the operation - for example * projects/project-1/locations/global/connectivityTests/test-1 * * Generated from protobuf field string target = 3; */ - private $target = ''; + protected $target = ''; /** * Name of the verb executed by the operation. * * Generated from protobuf field string verb = 4; */ - private $verb = ''; + protected $verb = ''; /** * Human-readable status of the operation, if any. * * Generated from protobuf field string status_detail = 5; */ - private $status_detail = ''; + protected $status_detail = ''; /** * Specifies if cancellation was requested for the operation. * * Generated from protobuf field bool cancel_requested = 6; */ - private $cancel_requested = false; + protected $cancel_requested = false; /** * API version. * * Generated from protobuf field string api_version = 7; */ - private $api_version = ''; + protected $api_version = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/ProbingDetails.php b/NetworkManagement/src/V1/ProbingDetails.php index b68b14636883..254b6271a30e 100644 --- a/NetworkManagement/src/V1/ProbingDetails.php +++ b/NetworkManagement/src/V1/ProbingDetails.php @@ -20,51 +20,51 @@ class ProbingDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.ProbingDetails.ProbingResult result = 1; */ - private $result = 0; + protected $result = 0; /** * The time that reachability was assessed through active probing. * * Generated from protobuf field .google.protobuf.Timestamp verify_time = 2; */ - private $verify_time = null; + protected $verify_time = null; /** * Details about an internal failure or the cancellation of active probing. * * Generated from protobuf field .google.rpc.Status error = 3; */ - private $error = null; + protected $error = null; /** * The reason probing was aborted. * * Generated from protobuf field .google.cloud.networkmanagement.v1.ProbingDetails.ProbingAbortCause abort_cause = 4; */ - private $abort_cause = 0; + protected $abort_cause = 0; /** * Number of probes sent. * * Generated from protobuf field int32 sent_probe_count = 5; */ - private $sent_probe_count = 0; + protected $sent_probe_count = 0; /** * Number of probes that reached the destination. * * Generated from protobuf field int32 successful_probe_count = 6; */ - private $successful_probe_count = 0; + protected $successful_probe_count = 0; /** * The source and destination endpoints derived from the test input and used * for active probing. * * Generated from protobuf field .google.cloud.networkmanagement.v1.EndpointInfo endpoint_info = 7; */ - private $endpoint_info = null; + protected $endpoint_info = null; /** * Latency as measured by active probing in one direction: * from the source to the destination endpoint. * * Generated from protobuf field .google.cloud.networkmanagement.v1.LatencyDistribution probing_latency = 8; */ - private $probing_latency = null; + protected $probing_latency = null; /** * The EdgeLocation from which a packet destined for/originating from the * internet will egress/ingress the Google network. @@ -75,7 +75,7 @@ class ProbingDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.ProbingDetails.EdgeLocation destination_egress_location = 9; */ - private $destination_egress_location = null; + protected $destination_egress_location = null; /** * Constructor. diff --git a/NetworkManagement/src/V1/ProbingDetails/EdgeLocation.php b/NetworkManagement/src/V1/ProbingDetails/EdgeLocation.php index 0308a318b40c..2e3c00534849 100644 --- a/NetworkManagement/src/V1/ProbingDetails/EdgeLocation.php +++ b/NetworkManagement/src/V1/ProbingDetails/EdgeLocation.php @@ -21,7 +21,7 @@ class EdgeLocation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string metropolitan_area = 1; */ - private $metropolitan_area = ''; + protected $metropolitan_area = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/ProxyConnectionInfo.php b/NetworkManagement/src/V1/ProxyConnectionInfo.php index 2ba21b514f95..feb1c10943c7 100644 --- a/NetworkManagement/src/V1/ProxyConnectionInfo.php +++ b/NetworkManagement/src/V1/ProxyConnectionInfo.php @@ -20,70 +20,70 @@ class ProxyConnectionInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string protocol = 1; */ - private $protocol = ''; + protected $protocol = ''; /** * Source IP address of an original connection. * * Generated from protobuf field string old_source_ip = 2; */ - private $old_source_ip = ''; + protected $old_source_ip = ''; /** * Source IP address of a new connection. * * Generated from protobuf field string new_source_ip = 3; */ - private $new_source_ip = ''; + protected $new_source_ip = ''; /** * Destination IP address of an original connection * * Generated from protobuf field string old_destination_ip = 4; */ - private $old_destination_ip = ''; + protected $old_destination_ip = ''; /** * Destination IP address of a new connection. * * Generated from protobuf field string new_destination_ip = 5; */ - private $new_destination_ip = ''; + protected $new_destination_ip = ''; /** * Source port of an original connection. Only valid when protocol is TCP or * UDP. * * Generated from protobuf field int32 old_source_port = 6; */ - private $old_source_port = 0; + protected $old_source_port = 0; /** * Source port of a new connection. Only valid when protocol is TCP or UDP. * * Generated from protobuf field int32 new_source_port = 7; */ - private $new_source_port = 0; + protected $new_source_port = 0; /** * Destination port of an original connection. Only valid when protocol is TCP * or UDP. * * Generated from protobuf field int32 old_destination_port = 8; */ - private $old_destination_port = 0; + protected $old_destination_port = 0; /** * Destination port of a new connection. Only valid when protocol is TCP or * UDP. * * Generated from protobuf field int32 new_destination_port = 9; */ - private $new_destination_port = 0; + protected $new_destination_port = 0; /** * Uri of proxy subnet. * * Generated from protobuf field string subnet_uri = 10; */ - private $subnet_uri = ''; + protected $subnet_uri = ''; /** * URI of the network where connection is proxied. * * Generated from protobuf field string network_uri = 11; */ - private $network_uri = ''; + protected $network_uri = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/ReachabilityDetails.php b/NetworkManagement/src/V1/ReachabilityDetails.php index 519d4c017825..487aecd9228d 100644 --- a/NetworkManagement/src/V1/ReachabilityDetails.php +++ b/NetworkManagement/src/V1/ReachabilityDetails.php @@ -20,19 +20,19 @@ class ReachabilityDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.ReachabilityDetails.Result result = 1; */ - private $result = 0; + protected $result = 0; /** * The time of the configuration analysis. * * Generated from protobuf field .google.protobuf.Timestamp verify_time = 2; */ - private $verify_time = null; + protected $verify_time = null; /** * The details of a failure or a cancellation of reachability analysis. * * Generated from protobuf field .google.rpc.Status error = 3; */ - private $error = null; + protected $error = null; /** * Result may contain a list of traces if a test has multiple possible * paths in the network, such as when destination endpoint is a load balancer diff --git a/NetworkManagement/src/V1/ReachabilityServiceClient.php b/NetworkManagement/src/V1/ReachabilityServiceClient.php deleted file mode 100644 index af55de7df01f..000000000000 --- a/NetworkManagement/src/V1/ReachabilityServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/RouteInfo.php b/NetworkManagement/src/V1/RouteInfo.php index 7fea7ff7cfea..adbf221856b8 100644 --- a/NetworkManagement/src/V1/RouteInfo.php +++ b/NetworkManagement/src/V1/RouteInfo.php @@ -20,25 +20,25 @@ class RouteInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.RouteInfo.RouteType route_type = 8; */ - private $route_type = 0; + protected $route_type = 0; /** * Type of next hop. * * Generated from protobuf field .google.cloud.networkmanagement.v1.RouteInfo.NextHopType next_hop_type = 9; */ - private $next_hop_type = 0; + protected $next_hop_type = 0; /** * Indicates where route is applicable. * * Generated from protobuf field .google.cloud.networkmanagement.v1.RouteInfo.RouteScope route_scope = 14; */ - private $route_scope = 0; + protected $route_scope = 0; /** * Name of a route. * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a route. * Dynamic, peering static and peering dynamic routes do not have an URI. @@ -47,31 +47,31 @@ class RouteInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * Destination IP range of the route. * * Generated from protobuf field string dest_ip_range = 3; */ - private $dest_ip_range = ''; + protected $dest_ip_range = ''; /** * Next hop of the route. * * Generated from protobuf field string next_hop = 4; */ - private $next_hop = ''; + protected $next_hop = ''; /** * URI of a Compute Engine network. NETWORK routes only. * * Generated from protobuf field string network_uri = 5; */ - private $network_uri = ''; + protected $network_uri = ''; /** * Priority of the route. * * Generated from protobuf field int32 priority = 6; */ - private $priority = 0; + protected $priority = 0; /** * Instance tags of the route. * @@ -83,7 +83,7 @@ class RouteInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string src_ip_range = 10; */ - private $src_ip_range = ''; + protected $src_ip_range = ''; /** * Destination port ranges of the route. Policy based routes only. * @@ -107,13 +107,13 @@ class RouteInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string ncc_hub_uri = 15; */ - private $ncc_hub_uri = null; + protected $ncc_hub_uri = null; /** * URI of a NCC Spoke. NCC_HUB routes only. * * Generated from protobuf field optional string ncc_spoke_uri = 16; */ - private $ncc_spoke_uri = null; + protected $ncc_spoke_uri = null; /** * Constructor. diff --git a/NetworkManagement/src/V1/Step.php b/NetworkManagement/src/V1/Step.php index 752ae80eabf1..84600bb5a6e7 100644 --- a/NetworkManagement/src/V1/Step.php +++ b/NetworkManagement/src/V1/Step.php @@ -21,25 +21,25 @@ class Step extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 1; */ - private $description = ''; + protected $description = ''; /** * Each step is in one of the pre-defined states. * * Generated from protobuf field .google.cloud.networkmanagement.v1.Step.State state = 2; */ - private $state = 0; + protected $state = 0; /** * This is a step that leads to the final state Drop. * * Generated from protobuf field bool causes_drop = 3; */ - private $causes_drop = false; + protected $causes_drop = false; /** * Project ID that contains the configuration this step is validating. * * Generated from protobuf field string project_id = 4; */ - private $project_id = ''; + protected $project_id = ''; protected $step_info; /** diff --git a/NetworkManagement/src/V1/StorageBucketInfo.php b/NetworkManagement/src/V1/StorageBucketInfo.php index 668c5a5420fd..58b34cf98567 100644 --- a/NetworkManagement/src/V1/StorageBucketInfo.php +++ b/NetworkManagement/src/V1/StorageBucketInfo.php @@ -20,7 +20,7 @@ class StorageBucketInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string bucket = 1; */ - private $bucket = ''; + protected $bucket = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/Trace.php b/NetworkManagement/src/V1/Trace.php index b446a439f1d8..02548d666c07 100644 --- a/NetworkManagement/src/V1/Trace.php +++ b/NetworkManagement/src/V1/Trace.php @@ -32,7 +32,7 @@ class Trace extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.networkmanagement.v1.EndpointInfo endpoint_info = 1; */ - private $endpoint_info = null; + protected $endpoint_info = null; /** * A trace of a test contains multiple steps from the initial state to the * final state (delivered, dropped, forwarded, or aborted). @@ -50,7 +50,7 @@ class Trace extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 forward_trace_id = 4; */ - private $forward_trace_id = 0; + protected $forward_trace_id = 0; /** * Constructor. diff --git a/NetworkManagement/src/V1/UpdateConnectivityTestRequest.php b/NetworkManagement/src/V1/UpdateConnectivityTestRequest.php index 440001b0b176..095a3a882e67 100644 --- a/NetworkManagement/src/V1/UpdateConnectivityTestRequest.php +++ b/NetworkManagement/src/V1/UpdateConnectivityTestRequest.php @@ -21,13 +21,13 @@ class UpdateConnectivityTestRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. Only fields specified in update_mask are updated. * * Generated from protobuf field .google.cloud.networkmanagement.v1.ConnectivityTest resource = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $resource = null; + protected $resource = null; /** * @param \Google\Protobuf\FieldMask $updateMask Required. Mask of fields to update. At least one path must be supplied in diff --git a/NetworkManagement/src/V1/VpcConnectorInfo.php b/NetworkManagement/src/V1/VpcConnectorInfo.php index 84f272f1d10d..c96a59d85686 100644 --- a/NetworkManagement/src/V1/VpcConnectorInfo.php +++ b/NetworkManagement/src/V1/VpcConnectorInfo.php @@ -20,19 +20,19 @@ class VpcConnectorInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a VPC connector. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * Location in which the VPC connector is deployed. * * Generated from protobuf field string location = 3; */ - private $location = ''; + protected $location = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/VpnGatewayInfo.php b/NetworkManagement/src/V1/VpnGatewayInfo.php index d43827cb1e31..61f964197e52 100644 --- a/NetworkManagement/src/V1/VpnGatewayInfo.php +++ b/NetworkManagement/src/V1/VpnGatewayInfo.php @@ -20,25 +20,25 @@ class VpnGatewayInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a VPN gateway. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * URI of a Compute Engine network where the VPN gateway is configured. * * Generated from protobuf field string network_uri = 3; */ - private $network_uri = ''; + protected $network_uri = ''; /** * IP address of the VPN gateway. * * Generated from protobuf field string ip_address = 4; */ - private $ip_address = ''; + protected $ip_address = ''; /** * A VPN tunnel that is associated with this VPN gateway. * There may be multiple VPN tunnels configured on a VPN gateway, and only @@ -46,13 +46,13 @@ class VpnGatewayInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string vpn_tunnel_uri = 5; */ - private $vpn_tunnel_uri = ''; + protected $vpn_tunnel_uri = ''; /** * Name of a Google Cloud region where this VPN gateway is configured. * * Generated from protobuf field string region = 6; */ - private $region = ''; + protected $region = ''; /** * Constructor. diff --git a/NetworkManagement/src/V1/VpnTunnelInfo.php b/NetworkManagement/src/V1/VpnTunnelInfo.php index 36423fc84274..8785392491d0 100644 --- a/NetworkManagement/src/V1/VpnTunnelInfo.php +++ b/NetworkManagement/src/V1/VpnTunnelInfo.php @@ -20,55 +20,55 @@ class VpnTunnelInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * URI of a VPN tunnel. * * Generated from protobuf field string uri = 2; */ - private $uri = ''; + protected $uri = ''; /** * URI of the VPN gateway at local end of the tunnel. * * Generated from protobuf field string source_gateway = 3; */ - private $source_gateway = ''; + protected $source_gateway = ''; /** * URI of a VPN gateway at remote end of the tunnel. * * Generated from protobuf field string remote_gateway = 4; */ - private $remote_gateway = ''; + protected $remote_gateway = ''; /** * Remote VPN gateway's IP address. * * Generated from protobuf field string remote_gateway_ip = 5; */ - private $remote_gateway_ip = ''; + protected $remote_gateway_ip = ''; /** * Local VPN gateway's IP address. * * Generated from protobuf field string source_gateway_ip = 6; */ - private $source_gateway_ip = ''; + protected $source_gateway_ip = ''; /** * URI of a Compute Engine network where the VPN tunnel is configured. * * Generated from protobuf field string network_uri = 7; */ - private $network_uri = ''; + protected $network_uri = ''; /** * Name of a Google Cloud region where this VPN tunnel is configured. * * Generated from protobuf field string region = 8; */ - private $region = ''; + protected $region = ''; /** * Type of the routing policy. * * Generated from protobuf field .google.cloud.networkmanagement.v1.VpnTunnelInfo.RoutingType routing_type = 9; */ - private $routing_type = 0; + protected $routing_type = 0; /** * Constructor. diff --git a/NetworkManagement/tests/Unit/V1/Client/ReachabilityServiceClientTest.php b/NetworkManagement/tests/Unit/V1/Client/ReachabilityServiceClientTest.php index bca71d4b45f9..e059b6463d73 100644 --- a/NetworkManagement/tests/Unit/V1/Client/ReachabilityServiceClientTest.php +++ b/NetworkManagement/tests/Unit/V1/Client/ReachabilityServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ReachabilityServiceClient */ @@ -144,7 +146,10 @@ public function createConnectivityTestTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkmanagement.v1.ReachabilityService/CreateConnectivityTest', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.networkmanagement.v1.ReachabilityService/CreateConnectivityTest', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($parent, $actualValue); $actualValue = $actualApiRequestObject->getTestId(); @@ -194,12 +199,15 @@ public function createConnectivityTestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $parent = 'parent-995424086'; @@ -268,8 +276,7 @@ public function deleteConnectivityTestTest() $operationsTransport->addResponse($completeOperation); // Mock request $name = 'name3373707'; - $request = (new DeleteConnectivityTestRequest()) - ->setName($name); + $request = (new DeleteConnectivityTestRequest())->setName($name); $response = $gapicClient->deleteConnectivityTest($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -279,7 +286,10 @@ public function deleteConnectivityTestTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkmanagement.v1.ReachabilityService/DeleteConnectivityTest', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.networkmanagement.v1.ReachabilityService/DeleteConnectivityTest', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($name, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -325,17 +335,19 @@ public function deleteConnectivityTestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $name = 'name3373707'; - $request = (new DeleteConnectivityTestRequest()) - ->setName($name); + $request = (new DeleteConnectivityTestRequest())->setName($name); $response = $gapicClient->deleteConnectivityTest($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -381,15 +393,17 @@ public function getConnectivityTestTest() $transport->addResponse($expectedResponse); // Mock request $name = 'name3373707'; - $request = (new GetConnectivityTestRequest()) - ->setName($name); + $request = (new GetConnectivityTestRequest())->setName($name); $response = $gapicClient->getConnectivityTest($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.networkmanagement.v1.ReachabilityService/GetConnectivityTest', $actualFuncCall); + $this->assertSame( + '/google.cloud.networkmanagement.v1.ReachabilityService/GetConnectivityTest', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -406,17 +420,19 @@ public function getConnectivityTestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $name = 'name3373707'; - $request = (new GetConnectivityTestRequest()) - ->setName($name); + $request = (new GetConnectivityTestRequest())->setName($name); try { $gapicClient->getConnectivityTest($request); // If the $gapicClient method call did not throw, fail the test @@ -441,17 +457,14 @@ public function listConnectivityTestsTest() // Mock response $nextPageToken = ''; $resourcesElement = new ConnectivityTest(); - $resources = [ - $resourcesElement, - ]; + $resources = [$resourcesElement]; $expectedResponse = new ListConnectivityTestsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setResources($resources); $transport->addResponse($expectedResponse); // Mock request $parent = 'parent-995424086'; - $request = (new ListConnectivityTestsRequest()) - ->setParent($parent); + $request = (new ListConnectivityTestsRequest())->setParent($parent); $response = $gapicClient->listConnectivityTests($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -461,7 +474,10 @@ public function listConnectivityTestsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkmanagement.v1.ReachabilityService/ListConnectivityTests', $actualFuncCall); + $this->assertSame( + '/google.cloud.networkmanagement.v1.ReachabilityService/ListConnectivityTests', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($parent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -478,17 +494,19 @@ public function listConnectivityTestsExceptionTest() $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); + $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 ListConnectivityTestsRequest()) - ->setParent($parent); + $request = (new ListConnectivityTestsRequest())->setParent($parent); try { $gapicClient->listConnectivityTests($request); // If the $gapicClient method call did not throw, fail the test @@ -543,8 +561,7 @@ public function rerunConnectivityTestTest() $operationsTransport->addResponse($completeOperation); // Mock request $name = 'name3373707'; - $request = (new RerunConnectivityTestRequest()) - ->setName($name); + $request = (new RerunConnectivityTestRequest())->setName($name); $response = $gapicClient->rerunConnectivityTest($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -554,7 +571,10 @@ public function rerunConnectivityTestTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkmanagement.v1.ReachabilityService/RerunConnectivityTest', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.networkmanagement.v1.ReachabilityService/RerunConnectivityTest', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($name, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -600,17 +620,19 @@ public function rerunConnectivityTestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $name = 'name3373707'; - $request = (new RerunConnectivityTestRequest()) - ->setName($name); + $request = (new RerunConnectivityTestRequest())->setName($name); $response = $gapicClient->rerunConnectivityTest($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -681,9 +703,7 @@ public function updateConnectivityTestTest() $resource->setSource($resourceSource); $resourceDestination = new Endpoint(); $resource->setDestination($resourceDestination); - $request = (new UpdateConnectivityTestRequest()) - ->setUpdateMask($updateMask) - ->setResource($resource); + $request = (new UpdateConnectivityTestRequest())->setUpdateMask($updateMask)->setResource($resource); $response = $gapicClient->updateConnectivityTest($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -693,7 +713,10 @@ public function updateConnectivityTestTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkmanagement.v1.ReachabilityService/UpdateConnectivityTest', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.networkmanagement.v1.ReachabilityService/UpdateConnectivityTest', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getUpdateMask(); $this->assertProtobufEquals($updateMask, $actualValue); $actualValue = $actualApiRequestObject->getResource(); @@ -741,12 +764,15 @@ public function updateConnectivityTestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $updateMask = new FieldMask(); @@ -757,9 +783,7 @@ public function updateConnectivityTestExceptionTest() $resource->setSource($resourceSource); $resourceDestination = new Endpoint(); $resource->setDestination($resourceDestination); - $request = (new UpdateConnectivityTestRequest()) - ->setUpdateMask($updateMask) - ->setResource($resource); + $request = (new UpdateConnectivityTestRequest())->setUpdateMask($updateMask)->setResource($resource); $response = $gapicClient->updateConnectivityTest($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -821,12 +845,15 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -853,9 +880,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -885,12 +910,15 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -923,8 +951,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -948,17 +975,19 @@ public function getIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -990,9 +1019,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1018,19 +1045,20 @@ public function setIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -1058,9 +1086,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1086,19 +1112,20 @@ public function testIamPermissionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -1174,7 +1201,10 @@ public function createConnectivityTestAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkmanagement.v1.ReachabilityService/CreateConnectivityTest', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.networkmanagement.v1.ReachabilityService/CreateConnectivityTest', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($parent, $actualValue); $actualValue = $actualApiRequestObject->getTestId(); diff --git a/NetworkManagement/tests/Unit/V1/ReachabilityServiceClientTest.php b/NetworkManagement/tests/Unit/V1/ReachabilityServiceClientTest.php deleted file mode 100644 index b65580ea02ff..000000000000 --- a/NetworkManagement/tests/Unit/V1/ReachabilityServiceClientTest.php +++ /dev/null @@ -1,1053 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ReachabilityServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ReachabilityServiceClient($options); - } - - /** @test */ - public function createConnectivityTestTest() - { - $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/createConnectivityTestTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $protocol = 'protocol-989163880'; - $displayName = 'displayName1615086568'; - $bypassFirewallChecks = false; - $expectedResponse = new ConnectivityTest(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setProtocol($protocol); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setBypassFirewallChecks($bypassFirewallChecks); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createConnectivityTestTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $parent = 'parent-995424086'; - $testId = 'testId-1422455832'; - $resource = new ConnectivityTest(); - $resourceName = 'resourceName-384566343'; - $resource->setName($resourceName); - $resourceSource = new Endpoint(); - $resource->setSource($resourceSource); - $resourceDestination = new Endpoint(); - $resource->setDestination($resourceDestination); - $response = $gapicClient->createConnectivityTest($parent, $testId, $resource); - $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.networkmanagement.v1.ReachabilityService/CreateConnectivityTest', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($parent, $actualValue); - $actualValue = $actualApiRequestObject->getTestId(); - $this->assertProtobufEquals($testId, $actualValue); - $actualValue = $actualApiRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createConnectivityTestTest'); - $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 createConnectivityTestExceptionTest() - { - $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/createConnectivityTestTest'); - $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 - $parent = 'parent-995424086'; - $testId = 'testId-1422455832'; - $resource = new ConnectivityTest(); - $resourceName = 'resourceName-384566343'; - $resource->setName($resourceName); - $resourceSource = new Endpoint(); - $resource->setSource($resourceSource); - $resourceDestination = new Endpoint(); - $resource->setDestination($resourceDestination); - $response = $gapicClient->createConnectivityTest($parent, $testId, $resource); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createConnectivityTestTest'); - 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 deleteConnectivityTestTest() - { - $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/deleteConnectivityTestTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteConnectivityTestTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $name = 'name3373707'; - $response = $gapicClient->deleteConnectivityTest($name); - $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.networkmanagement.v1.ReachabilityService/DeleteConnectivityTest', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteConnectivityTestTest'); - $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 deleteConnectivityTestExceptionTest() - { - $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/deleteConnectivityTestTest'); - $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 - $name = 'name3373707'; - $response = $gapicClient->deleteConnectivityTest($name); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteConnectivityTestTest'); - 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 getConnectivityTestTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $protocol = 'protocol-989163880'; - $displayName = 'displayName1615086568'; - $bypassFirewallChecks = false; - $expectedResponse = new ConnectivityTest(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setProtocol($protocol); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setBypassFirewallChecks($bypassFirewallChecks); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $response = $gapicClient->getConnectivityTest($name); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkmanagement.v1.ReachabilityService/GetConnectivityTest', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getConnectivityTestExceptionTest() - { - $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 - $name = 'name3373707'; - try { - $gapicClient->getConnectivityTest($name); - // 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 listConnectivityTestsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $resourcesElement = new ConnectivityTest(); - $resources = [ - $resourcesElement, - ]; - $expectedResponse = new ListConnectivityTestsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setResources($resources); - $transport->addResponse($expectedResponse); - // Mock request - $parent = 'parent-995424086'; - $response = $gapicClient->listConnectivityTests($parent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getResources()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.networkmanagement.v1.ReachabilityService/ListConnectivityTests', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($parent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listConnectivityTestsExceptionTest() - { - $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'; - try { - $gapicClient->listConnectivityTests($parent); - // 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 rerunConnectivityTestTest() - { - $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/rerunConnectivityTestTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $protocol = 'protocol-989163880'; - $displayName = 'displayName1615086568'; - $bypassFirewallChecks = false; - $expectedResponse = new ConnectivityTest(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setProtocol($protocol); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setBypassFirewallChecks($bypassFirewallChecks); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/rerunConnectivityTestTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $name = 'name3373707'; - $response = $gapicClient->rerunConnectivityTest($name); - $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.networkmanagement.v1.ReachabilityService/RerunConnectivityTest', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/rerunConnectivityTestTest'); - $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 rerunConnectivityTestExceptionTest() - { - $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/rerunConnectivityTestTest'); - $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 - $name = 'name3373707'; - $response = $gapicClient->rerunConnectivityTest($name); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/rerunConnectivityTestTest'); - 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 updateConnectivityTestTest() - { - $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/updateConnectivityTestTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $description = 'description-1724546052'; - $protocol = 'protocol-989163880'; - $displayName = 'displayName1615086568'; - $bypassFirewallChecks = false; - $expectedResponse = new ConnectivityTest(); - $expectedResponse->setName($name); - $expectedResponse->setDescription($description); - $expectedResponse->setProtocol($protocol); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setBypassFirewallChecks($bypassFirewallChecks); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateConnectivityTestTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $resource = new ConnectivityTest(); - $resourceName = 'resourceName-384566343'; - $resource->setName($resourceName); - $resourceSource = new Endpoint(); - $resource->setSource($resourceSource); - $resourceDestination = new Endpoint(); - $resource->setDestination($resourceDestination); - $response = $gapicClient->updateConnectivityTest($updateMask, $resource); - $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.networkmanagement.v1.ReachabilityService/UpdateConnectivityTest', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateConnectivityTestTest'); - $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 updateConnectivityTestExceptionTest() - { - $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/updateConnectivityTestTest'); - $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 - $updateMask = new FieldMask(); - $resource = new ConnectivityTest(); - $resourceName = 'resourceName-384566343'; - $resource->setName($resourceName); - $resourceSource = new Endpoint(); - $resource->setSource($resourceSource); - $resourceDestination = new Endpoint(); - $resource->setDestination($resourceDestination); - $response = $gapicClient->updateConnectivityTest($updateMask, $resource); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateConnectivityTestTest'); - 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 getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $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); - try { - $gapicClient->getLocation(); - // 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 listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $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); - try { - $gapicClient->listLocations(); - // 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 getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/OrchestrationAirflow/owlbot.py b/OrchestrationAirflow/owlbot.py index 522314d65e40..58c13745a887 100644 --- a/OrchestrationAirflow/owlbot.py +++ b/OrchestrationAirflow/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,32 +41,6 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - # format generated clients subprocess.run([ 'npm', @@ -82,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/OrchestrationAirflow/src/V1/CheckUpgradeResponse.php b/OrchestrationAirflow/src/V1/CheckUpgradeResponse.php index e1fe2dc71e8a..e62502ad25a1 100644 --- a/OrchestrationAirflow/src/V1/CheckUpgradeResponse.php +++ b/OrchestrationAirflow/src/V1/CheckUpgradeResponse.php @@ -21,26 +21,26 @@ class CheckUpgradeResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string build_log_uri = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $build_log_uri = ''; + protected $build_log_uri = ''; /** * Output only. Whether build has succeeded or failed on modules conflicts. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.CheckUpgradeResponse.ConflictResult contains_pypi_modules_conflict = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $contains_pypi_modules_conflict = 0; + protected $contains_pypi_modules_conflict = 0; /** * Output only. Extract from a docker image build log containing information * about pypi modules conflicts. * * Generated from protobuf field string pypi_conflict_build_log_extract = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $pypi_conflict_build_log_extract = ''; + protected $pypi_conflict_build_log_extract = ''; /** * Composer image for which the build was happening. * * Generated from protobuf field string image_version = 5; */ - private $image_version = ''; + protected $image_version = ''; /** * Pypi dependencies specified in the environment configuration, at the time * when the build was triggered. diff --git a/OrchestrationAirflow/src/V1/Client/EnvironmentsClient.php b/OrchestrationAirflow/src/V1/Client/EnvironmentsClient.php index 3b26f5881572..894308615f43 100644 --- a/OrchestrationAirflow/src/V1/Client/EnvironmentsClient.php +++ b/OrchestrationAirflow/src/V1/Client/EnvironmentsClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a environment * resource. @@ -212,8 +231,12 @@ public static function environmentName(string $project, string $location, string * * @return string The formatted user_workloads_config_map resource. */ - public static function userWorkloadsConfigMapName(string $project, string $location, string $environment, string $userWorkloadsConfigMap): string - { + public static function userWorkloadsConfigMapName( + string $project, + string $location, + string $environment, + string $userWorkloadsConfigMap + ): string { return self::getPathTemplate('userWorkloadsConfigMap')->render([ 'project' => $project, 'location' => $location, @@ -233,8 +256,12 @@ public static function userWorkloadsConfigMapName(string $project, string $locat * * @return string The formatted user_workloads_secret resource. */ - public static function userWorkloadsSecretName(string $project, string $location, string $environment, string $userWorkloadsSecret): string - { + public static function userWorkloadsSecretName( + string $project, + string $location, + string $environment, + string $userWorkloadsSecret + ): string { return self::getPathTemplate('userWorkloadsSecret')->render([ 'project' => $project, 'location' => $location, @@ -392,8 +419,10 @@ public function createEnvironment(CreateEnvironmentRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function createUserWorkloadsConfigMap(CreateUserWorkloadsConfigMapRequest $request, array $callOptions = []): UserWorkloadsConfigMap - { + public function createUserWorkloadsConfigMap( + CreateUserWorkloadsConfigMapRequest $request, + array $callOptions = [] + ): UserWorkloadsConfigMap { return $this->startApiCall('CreateUserWorkloadsConfigMap', $request, $callOptions)->wait(); } @@ -422,8 +451,10 @@ public function createUserWorkloadsConfigMap(CreateUserWorkloadsConfigMapRequest * * @throws ApiException Thrown if the API call fails. */ - public function createUserWorkloadsSecret(CreateUserWorkloadsSecretRequest $request, array $callOptions = []): UserWorkloadsSecret - { + public function createUserWorkloadsSecret( + CreateUserWorkloadsSecretRequest $request, + array $callOptions = [] + ): UserWorkloadsSecret { return $this->startApiCall('CreateUserWorkloadsSecret', $request, $callOptions)->wait(); } @@ -502,8 +533,10 @@ public function deleteEnvironment(DeleteEnvironmentRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function deleteUserWorkloadsConfigMap(DeleteUserWorkloadsConfigMapRequest $request, array $callOptions = []): void - { + public function deleteUserWorkloadsConfigMap( + DeleteUserWorkloadsConfigMapRequest $request, + array $callOptions = [] + ): void { $this->startApiCall('DeleteUserWorkloadsConfigMap', $request, $callOptions)->wait(); } @@ -556,8 +589,10 @@ public function deleteUserWorkloadsSecret(DeleteUserWorkloadsSecretRequest $requ * * @throws ApiException Thrown if the API call fails. */ - public function executeAirflowCommand(ExecuteAirflowCommandRequest $request, array $callOptions = []): ExecuteAirflowCommandResponse - { + public function executeAirflowCommand( + ExecuteAirflowCommandRequest $request, + array $callOptions = [] + ): ExecuteAirflowCommandResponse { return $this->startApiCall('ExecuteAirflowCommand', $request, $callOptions)->wait(); } @@ -582,8 +617,10 @@ public function executeAirflowCommand(ExecuteAirflowCommandRequest $request, arr * * @throws ApiException Thrown if the API call fails. */ - public function fetchDatabaseProperties(FetchDatabasePropertiesRequest $request, array $callOptions = []): FetchDatabasePropertiesResponse - { + public function fetchDatabaseProperties( + FetchDatabasePropertiesRequest $request, + array $callOptions = [] + ): FetchDatabasePropertiesResponse { return $this->startApiCall('FetchDatabaseProperties', $request, $callOptions)->wait(); } @@ -638,8 +675,10 @@ public function getEnvironment(GetEnvironmentRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function getUserWorkloadsConfigMap(GetUserWorkloadsConfigMapRequest $request, array $callOptions = []): UserWorkloadsConfigMap - { + public function getUserWorkloadsConfigMap( + GetUserWorkloadsConfigMapRequest $request, + array $callOptions = [] + ): UserWorkloadsConfigMap { return $this->startApiCall('GetUserWorkloadsConfigMap', $request, $callOptions)->wait(); } @@ -668,8 +707,10 @@ public function getUserWorkloadsConfigMap(GetUserWorkloadsConfigMapRequest $requ * * @throws ApiException Thrown if the API call fails. */ - public function getUserWorkloadsSecret(GetUserWorkloadsSecretRequest $request, array $callOptions = []): UserWorkloadsSecret - { + public function getUserWorkloadsSecret( + GetUserWorkloadsSecretRequest $request, + array $callOptions = [] + ): UserWorkloadsSecret { return $this->startApiCall('GetUserWorkloadsSecret', $request, $callOptions)->wait(); } @@ -724,8 +765,10 @@ public function listEnvironments(ListEnvironmentsRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function listUserWorkloadsConfigMaps(ListUserWorkloadsConfigMapsRequest $request, array $callOptions = []): PagedListResponse - { + public function listUserWorkloadsConfigMaps( + ListUserWorkloadsConfigMapsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListUserWorkloadsConfigMaps', $request, $callOptions); } @@ -754,8 +797,10 @@ public function listUserWorkloadsConfigMaps(ListUserWorkloadsConfigMapsRequest $ * * @throws ApiException Thrown if the API call fails. */ - public function listUserWorkloadsSecrets(ListUserWorkloadsSecretsRequest $request, array $callOptions = []): PagedListResponse - { + public function listUserWorkloadsSecrets( + ListUserWorkloadsSecretsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListUserWorkloadsSecrets', $request, $callOptions); } @@ -839,8 +884,10 @@ public function loadSnapshot(LoadSnapshotRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function pollAirflowCommand(PollAirflowCommandRequest $request, array $callOptions = []): PollAirflowCommandResponse - { + public function pollAirflowCommand( + PollAirflowCommandRequest $request, + array $callOptions = [] + ): PollAirflowCommandResponse { return $this->startApiCall('PollAirflowCommand', $request, $callOptions)->wait(); } @@ -894,8 +941,10 @@ public function saveSnapshot(SaveSnapshotRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function stopAirflowCommand(StopAirflowCommandRequest $request, array $callOptions = []): StopAirflowCommandResponse - { + public function stopAirflowCommand( + StopAirflowCommandRequest $request, + array $callOptions = [] + ): StopAirflowCommandResponse { return $this->startApiCall('StopAirflowCommand', $request, $callOptions)->wait(); } @@ -950,8 +999,10 @@ public function updateEnvironment(UpdateEnvironmentRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function updateUserWorkloadsConfigMap(UpdateUserWorkloadsConfigMapRequest $request, array $callOptions = []): UserWorkloadsConfigMap - { + public function updateUserWorkloadsConfigMap( + UpdateUserWorkloadsConfigMapRequest $request, + array $callOptions = [] + ): UserWorkloadsConfigMap { return $this->startApiCall('UpdateUserWorkloadsConfigMap', $request, $callOptions)->wait(); } @@ -980,8 +1031,10 @@ public function updateUserWorkloadsConfigMap(UpdateUserWorkloadsConfigMapRequest * * @throws ApiException Thrown if the API call fails. */ - public function updateUserWorkloadsSecret(UpdateUserWorkloadsSecretRequest $request, array $callOptions = []): UserWorkloadsSecret - { + public function updateUserWorkloadsSecret( + UpdateUserWorkloadsSecretRequest $request, + array $callOptions = [] + ): UserWorkloadsSecret { return $this->startApiCall('UpdateUserWorkloadsSecret', $request, $callOptions)->wait(); } } diff --git a/OrchestrationAirflow/src/V1/Client/ImageVersionsClient.php b/OrchestrationAirflow/src/V1/Client/ImageVersionsClient.php index 23fb2a0c3fac..a6f866bfa7cc 100644 --- a/OrchestrationAirflow/src/V1/Client/ImageVersionsClient.php +++ b/OrchestrationAirflow/src/V1/Client/ImageVersionsClient.php @@ -1,6 +1,6 @@ bool enabled = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enabled = false; + protected $enabled = false; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/CreateEnvironmentRequest.php b/OrchestrationAirflow/src/V1/CreateEnvironmentRequest.php index fbc3278e4724..c18885d24d38 100644 --- a/OrchestrationAirflow/src/V1/CreateEnvironmentRequest.php +++ b/OrchestrationAirflow/src/V1/CreateEnvironmentRequest.php @@ -21,13 +21,13 @@ class CreateEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1; */ - private $parent = ''; + protected $parent = ''; /** * The environment to create. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.Environment environment = 2; */ - private $environment = null; + protected $environment = null; /** * @param string $parent The parent must be of the form diff --git a/OrchestrationAirflow/src/V1/CreateUserWorkloadsConfigMapRequest.php b/OrchestrationAirflow/src/V1/CreateUserWorkloadsConfigMapRequest.php index 987f58143f15..3c9d6d95fcba 100644 --- a/OrchestrationAirflow/src/V1/CreateUserWorkloadsConfigMapRequest.php +++ b/OrchestrationAirflow/src/V1/CreateUserWorkloadsConfigMapRequest.php @@ -21,13 +21,13 @@ class CreateUserWorkloadsConfigMapRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. User workloads ConfigMap to create. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.UserWorkloadsConfigMap user_workloads_config_map = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $user_workloads_config_map = null; + protected $user_workloads_config_map = null; /** * @param string $parent Required. The environment name to create a ConfigMap for, in the form: diff --git a/OrchestrationAirflow/src/V1/CreateUserWorkloadsSecretRequest.php b/OrchestrationAirflow/src/V1/CreateUserWorkloadsSecretRequest.php index f9c4fbd8d713..483f8bb4f3c3 100644 --- a/OrchestrationAirflow/src/V1/CreateUserWorkloadsSecretRequest.php +++ b/OrchestrationAirflow/src/V1/CreateUserWorkloadsSecretRequest.php @@ -21,13 +21,13 @@ class CreateUserWorkloadsSecretRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. User workloads Secret to create. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.UserWorkloadsSecret user_workloads_secret = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $user_workloads_secret = null; + protected $user_workloads_secret = null; /** * @param string $parent Required. The environment name to create a Secret for, in the form: diff --git a/OrchestrationAirflow/src/V1/DataRetentionConfig.php b/OrchestrationAirflow/src/V1/DataRetentionConfig.php index 1d4e55588ca6..872d17553d54 100644 --- a/OrchestrationAirflow/src/V1/DataRetentionConfig.php +++ b/OrchestrationAirflow/src/V1/DataRetentionConfig.php @@ -20,7 +20,7 @@ class DataRetentionConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.TaskLogsRetentionConfig task_logs_retention_config = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $task_logs_retention_config = null; + protected $task_logs_retention_config = null; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/DatabaseConfig.php b/OrchestrationAirflow/src/V1/DatabaseConfig.php index 2ae75a0e191a..bc15000dc1a5 100644 --- a/OrchestrationAirflow/src/V1/DatabaseConfig.php +++ b/OrchestrationAirflow/src/V1/DatabaseConfig.php @@ -25,7 +25,7 @@ class DatabaseConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string machine_type = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $machine_type = ''; + protected $machine_type = ''; /** * Optional. The Compute Engine zone where the Airflow database is created. If * zone is provided, it must be in the region selected for the environment. If @@ -35,7 +35,7 @@ class DatabaseConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string zone = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $zone = ''; + protected $zone = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/DatabaseFailoverRequest.php b/OrchestrationAirflow/src/V1/DatabaseFailoverRequest.php index 7573bebb4f34..ab6e640265f2 100644 --- a/OrchestrationAirflow/src/V1/DatabaseFailoverRequest.php +++ b/OrchestrationAirflow/src/V1/DatabaseFailoverRequest.php @@ -22,7 +22,7 @@ class DatabaseFailoverRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string environment = 1; */ - private $environment = ''; + protected $environment = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/DeleteEnvironmentRequest.php b/OrchestrationAirflow/src/V1/DeleteEnvironmentRequest.php index c29cbf44ada5..dbecadf7a50f 100644 --- a/OrchestrationAirflow/src/V1/DeleteEnvironmentRequest.php +++ b/OrchestrationAirflow/src/V1/DeleteEnvironmentRequest.php @@ -21,7 +21,7 @@ class DeleteEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * @param string $name The environment to delete, in the form: diff --git a/OrchestrationAirflow/src/V1/DeleteUserWorkloadsConfigMapRequest.php b/OrchestrationAirflow/src/V1/DeleteUserWorkloadsConfigMapRequest.php index b566cbaeebe7..45de5167d11a 100644 --- a/OrchestrationAirflow/src/V1/DeleteUserWorkloadsConfigMapRequest.php +++ b/OrchestrationAirflow/src/V1/DeleteUserWorkloadsConfigMapRequest.php @@ -21,7 +21,7 @@ class DeleteUserWorkloadsConfigMapRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The ConfigMap to delete, in the form: diff --git a/OrchestrationAirflow/src/V1/DeleteUserWorkloadsSecretRequest.php b/OrchestrationAirflow/src/V1/DeleteUserWorkloadsSecretRequest.php index e597f76dd967..eca0bab9c9fb 100644 --- a/OrchestrationAirflow/src/V1/DeleteUserWorkloadsSecretRequest.php +++ b/OrchestrationAirflow/src/V1/DeleteUserWorkloadsSecretRequest.php @@ -21,7 +21,7 @@ class DeleteUserWorkloadsSecretRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The Secret to delete, in the form: diff --git a/OrchestrationAirflow/src/V1/EncryptionConfig.php b/OrchestrationAirflow/src/V1/EncryptionConfig.php index f8d32c239a5b..c8d5d8e29fc8 100644 --- a/OrchestrationAirflow/src/V1/EncryptionConfig.php +++ b/OrchestrationAirflow/src/V1/EncryptionConfig.php @@ -24,7 +24,7 @@ class EncryptionConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string kms_key_name = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $kms_key_name = ''; + protected $kms_key_name = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/Environment.php b/OrchestrationAirflow/src/V1/Environment.php index 4405ed5b6052..90b22da46eac 100644 --- a/OrchestrationAirflow/src/V1/Environment.php +++ b/OrchestrationAirflow/src/V1/Environment.php @@ -23,38 +23,38 @@ class Environment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Configuration parameters for this environment. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.EnvironmentConfig config = 2; */ - private $config = null; + protected $config = null; /** * Output only. The UUID (Universally Unique IDentifier) associated with this * environment. This value is generated when the environment is created. * * Generated from protobuf field string uuid = 3; */ - private $uuid = ''; + protected $uuid = ''; /** * The current state of the environment. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.Environment.State state = 4; */ - private $state = 0; + protected $state = 0; /** * Output only. The time at which this environment was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 5; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time at which this environment was last modified. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 6; */ - private $update_time = null; + protected $update_time = null; /** * Optional. User-defined labels for this environment. * The labels map can contain no more than 64 entries. Entries of the labels @@ -72,13 +72,13 @@ class Environment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool satisfies_pzs = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $satisfies_pzs = false; + protected $satisfies_pzs = false; /** * Optional. Storage configuration for this environment. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.StorageConfig storage_config = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - private $storage_config = null; + protected $storage_config = null; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/EnvironmentConfig.php b/OrchestrationAirflow/src/V1/EnvironmentConfig.php index a105e75b1814..65a69ece12d8 100644 --- a/OrchestrationAirflow/src/V1/EnvironmentConfig.php +++ b/OrchestrationAirflow/src/V1/EnvironmentConfig.php @@ -20,7 +20,7 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string gke_cluster = 1; */ - private $gke_cluster = ''; + protected $gke_cluster = ''; /** * Output only. The Cloud Storage prefix of the DAGs for this environment. * Although Cloud Storage objects reside in a flat namespace, a hierarchical @@ -30,7 +30,7 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string dag_gcs_prefix = 2; */ - private $dag_gcs_prefix = ''; + protected $dag_gcs_prefix = ''; /** * The number of nodes in the Kubernetes Engine cluster that will be * used to run this environment. @@ -39,25 +39,25 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 node_count = 3; */ - private $node_count = 0; + protected $node_count = 0; /** * The configuration settings for software inside the environment. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.SoftwareConfig software_config = 4; */ - private $software_config = null; + protected $software_config = null; /** * The configuration used for the Kubernetes Engine cluster. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.NodeConfig node_config = 5; */ - private $node_config = null; + protected $node_config = null; /** * The configuration used for the Private IP Cloud Composer environment. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.PrivateEnvironmentConfig private_environment_config = 7; */ - private $private_environment_config = null; + protected $private_environment_config = null; /** * Optional. The network-level access control policy for the Airflow web * server. If unspecified, no network-level access restrictions will be @@ -65,28 +65,28 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.WebServerNetworkAccessControl web_server_network_access_control = 8 [(.google.api.field_behavior) = OPTIONAL]; */ - private $web_server_network_access_control = null; + protected $web_server_network_access_control = null; /** * Optional. The configuration settings for Cloud SQL instance used internally * by Apache Airflow software. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.DatabaseConfig database_config = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - private $database_config = null; + protected $database_config = null; /** * Optional. The configuration settings for the Airflow web server App Engine * instance. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.WebServerConfig web_server_config = 10 [(.google.api.field_behavior) = OPTIONAL]; */ - private $web_server_config = null; + protected $web_server_config = null; /** * Optional. The encryption options for the Cloud Composer environment * and its dependencies. Cannot be updated. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.EncryptionConfig encryption_config = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $encryption_config = null; + protected $encryption_config = null; /** * Optional. The maintenance window is the period when Cloud Composer * components may undergo maintenance. It is defined so that maintenance is @@ -102,7 +102,7 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.MaintenanceWindow maintenance_window = 12 [(.google.api.field_behavior) = OPTIONAL]; */ - private $maintenance_window = null; + protected $maintenance_window = null; /** * Optional. The workloads configuration settings for the GKE cluster * associated with the Cloud Composer environment. The GKE cluster runs @@ -112,7 +112,7 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.WorkloadsConfig workloads_config = 15 [(.google.api.field_behavior) = OPTIONAL]; */ - private $workloads_config = null; + protected $workloads_config = null; /** * Optional. The size of the Cloud Composer environment. * This field is supported for Cloud Composer environments in versions @@ -120,25 +120,25 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.EnvironmentConfig.EnvironmentSize environment_size = 16 [(.google.api.field_behavior) = OPTIONAL]; */ - private $environment_size = 0; + protected $environment_size = 0; /** * Output only. The URI of the Apache Airflow Web UI hosted within this * environment (see [Airflow web - * interface](https://cloud.google.com/composer/docs/how-to/accessing/airflow-web-interface)). + * interface](/composer/docs/how-to/accessing/airflow-web-interface)). * * Generated from protobuf field string airflow_uri = 6; */ - private $airflow_uri = ''; + protected $airflow_uri = ''; /** * Output only. The 'bring your own identity' variant of the URI of the Apache * Airflow Web UI hosted within this environment, to be accessed with external * identities using workforce identity federation (see [Access environments * with workforce identity - * federation](https://cloud.google.com/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). + * federation](/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). * * Generated from protobuf field string airflow_byoid_uri = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $airflow_byoid_uri = ''; + protected $airflow_byoid_uri = ''; /** * Optional. The configuration options for GKE cluster master authorized * networks. By default master authorized networks feature is: @@ -148,7 +148,7 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.MasterAuthorizedNetworksConfig master_authorized_networks_config = 17 [(.google.api.field_behavior) = OPTIONAL]; */ - private $master_authorized_networks_config = null; + protected $master_authorized_networks_config = null; /** * Optional. The Recovery settings configuration of an environment. * This field is supported for Cloud Composer environments in versions @@ -156,7 +156,7 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.RecoveryConfig recovery_config = 18 [(.google.api.field_behavior) = OPTIONAL]; */ - private $recovery_config = null; + protected $recovery_config = null; /** * Optional. Resilience mode of the Cloud Composer Environment. * This field is supported for Cloud Composer environments in versions @@ -164,14 +164,14 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.EnvironmentConfig.ResilienceMode resilience_mode = 19 [(.google.api.field_behavior) = OPTIONAL]; */ - private $resilience_mode = 0; + protected $resilience_mode = 0; /** * Optional. The configuration setting for Airflow database data retention * mechanism. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.DataRetentionConfig data_retention_config = 21 [(.google.api.field_behavior) = OPTIONAL]; */ - private $data_retention_config = null; + protected $data_retention_config = null; /** * Constructor. @@ -236,13 +236,13 @@ class EnvironmentConfig extends \Google\Protobuf\Internal\Message * @type string $airflow_uri * Output only. The URI of the Apache Airflow Web UI hosted within this * environment (see [Airflow web - * interface](https://cloud.google.com/composer/docs/how-to/accessing/airflow-web-interface)). + * interface](/composer/docs/how-to/accessing/airflow-web-interface)). * @type string $airflow_byoid_uri * Output only. The 'bring your own identity' variant of the URI of the Apache * Airflow Web UI hosted within this environment, to be accessed with external * identities using workforce identity federation (see [Access environments * with workforce identity - * federation](https://cloud.google.com/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). + * federation](/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). * @type \Google\Cloud\Orchestration\Airflow\Service\V1\MasterAuthorizedNetworksConfig $master_authorized_networks_config * Optional. The configuration options for GKE cluster master authorized * networks. By default master authorized networks feature is: @@ -754,7 +754,7 @@ public function setEnvironmentSize($var) /** * Output only. The URI of the Apache Airflow Web UI hosted within this * environment (see [Airflow web - * interface](https://cloud.google.com/composer/docs/how-to/accessing/airflow-web-interface)). + * interface](/composer/docs/how-to/accessing/airflow-web-interface)). * * Generated from protobuf field string airflow_uri = 6; * @return string @@ -767,7 +767,7 @@ public function getAirflowUri() /** * Output only. The URI of the Apache Airflow Web UI hosted within this * environment (see [Airflow web - * interface](https://cloud.google.com/composer/docs/how-to/accessing/airflow-web-interface)). + * interface](/composer/docs/how-to/accessing/airflow-web-interface)). * * Generated from protobuf field string airflow_uri = 6; * @param string $var @@ -786,7 +786,7 @@ public function setAirflowUri($var) * Airflow Web UI hosted within this environment, to be accessed with external * identities using workforce identity federation (see [Access environments * with workforce identity - * federation](https://cloud.google.com/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). + * federation](/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). * * Generated from protobuf field string airflow_byoid_uri = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return string @@ -801,7 +801,7 @@ public function getAirflowByoidUri() * Airflow Web UI hosted within this environment, to be accessed with external * identities using workforce identity federation (see [Access environments * with workforce identity - * federation](https://cloud.google.com/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). + * federation](/composer/docs/composer-2/access-environments-with-workforce-identity-federation)). * * Generated from protobuf field string airflow_byoid_uri = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param string $var diff --git a/OrchestrationAirflow/src/V1/EnvironmentsClient.php b/OrchestrationAirflow/src/V1/EnvironmentsClient.php deleted file mode 100644 index eb02f650d317..000000000000 --- a/OrchestrationAirflow/src/V1/EnvironmentsClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string environment = 1; */ - private $environment = ''; + protected $environment = ''; /** * Airflow command. * * Generated from protobuf field string command = 2; */ - private $command = ''; + protected $command = ''; /** * Airflow subcommand. * * Generated from protobuf field string subcommand = 3; */ - private $subcommand = ''; + protected $subcommand = ''; /** * Parameters for the Airflow command/subcommand as an array of arguments. * It may contain positional arguments like `["my-dag-id"]`, key-value diff --git a/OrchestrationAirflow/src/V1/ExecuteAirflowCommandResponse.php b/OrchestrationAirflow/src/V1/ExecuteAirflowCommandResponse.php index 7978c32c2493..7652aa34183c 100644 --- a/OrchestrationAirflow/src/V1/ExecuteAirflowCommandResponse.php +++ b/OrchestrationAirflow/src/V1/ExecuteAirflowCommandResponse.php @@ -20,25 +20,25 @@ class ExecuteAirflowCommandResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string execution_id = 1; */ - private $execution_id = ''; + protected $execution_id = ''; /** * The name of the pod where the command is executed. * * Generated from protobuf field string pod = 2; */ - private $pod = ''; + protected $pod = ''; /** * The namespace of the pod where the command is executed. * * Generated from protobuf field string pod_namespace = 3; */ - private $pod_namespace = ''; + protected $pod_namespace = ''; /** * Error message. Empty if there was no error. * * Generated from protobuf field string error = 4; */ - private $error = ''; + protected $error = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/FetchDatabasePropertiesRequest.php b/OrchestrationAirflow/src/V1/FetchDatabasePropertiesRequest.php index 17608650b0ed..ac136a7d9c93 100644 --- a/OrchestrationAirflow/src/V1/FetchDatabasePropertiesRequest.php +++ b/OrchestrationAirflow/src/V1/FetchDatabasePropertiesRequest.php @@ -21,7 +21,7 @@ class FetchDatabasePropertiesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string environment = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $environment = ''; + protected $environment = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/FetchDatabasePropertiesResponse.php b/OrchestrationAirflow/src/V1/FetchDatabasePropertiesResponse.php index afd29547dddb..a2c147998912 100644 --- a/OrchestrationAirflow/src/V1/FetchDatabasePropertiesResponse.php +++ b/OrchestrationAirflow/src/V1/FetchDatabasePropertiesResponse.php @@ -20,14 +20,14 @@ class FetchDatabasePropertiesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string primary_gce_zone = 1; */ - private $primary_gce_zone = ''; + protected $primary_gce_zone = ''; /** * The Compute Engine zone that the failover instance is currently serving * from for a regional Cloud SQL instance. * * Generated from protobuf field string secondary_gce_zone = 2; */ - private $secondary_gce_zone = ''; + protected $secondary_gce_zone = ''; /** * The availability status of the failover replica. A false status indicates * that the failover replica is out of sync. The primary instance can only @@ -35,7 +35,7 @@ class FetchDatabasePropertiesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool is_failover_replica_available = 3; */ - private $is_failover_replica_available = false; + protected $is_failover_replica_available = false; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/Gapic/EnvironmentsGapicClient.php b/OrchestrationAirflow/src/V1/Gapic/EnvironmentsGapicClient.php deleted file mode 100644 index af4c7e1c0cea..000000000000 --- a/OrchestrationAirflow/src/V1/Gapic/EnvironmentsGapicClient.php +++ /dev/null @@ -1,2200 +0,0 @@ -createEnvironment(); - * $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 = $environmentsClient->createEnvironment(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'createEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Orchestration\Airflow\Service\V1\Client\EnvironmentsClient}. - */ -class EnvironmentsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.orchestration.airflow.service.v1.Environments'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'composer.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'composer.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $environmentNameTemplate; - - private static $userWorkloadsConfigMapNameTemplate; - - private static $userWorkloadsSecretNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getEnvironmentNameTemplate() - { - if (self::$environmentNameTemplate == null) { - self::$environmentNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/environments/{environment}' - ); - } - - return self::$environmentNameTemplate; - } - - private static function getUserWorkloadsConfigMapNameTemplate() - { - if (self::$userWorkloadsConfigMapNameTemplate == null) { - self::$userWorkloadsConfigMapNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/environments/{environment}/userWorkloadsConfigMaps/{user_workloads_config_map}' - ); - } - - return self::$userWorkloadsConfigMapNameTemplate; - } - - private static function getUserWorkloadsSecretNameTemplate() - { - if (self::$userWorkloadsSecretNameTemplate == null) { - self::$userWorkloadsSecretNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/environments/{environment}/userWorkloadsSecrets/{user_workloads_secret}' - ); - } - - return self::$userWorkloadsSecretNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'environment' => self::getEnvironmentNameTemplate(), - 'userWorkloadsConfigMap' => self::getUserWorkloadsConfigMapNameTemplate(), - 'userWorkloadsSecret' => self::getUserWorkloadsSecretNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location, $environment) - { - return self::getEnvironmentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * user_workloads_config_map resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $userWorkloadsConfigMap - * - * @return string The formatted user_workloads_config_map resource. - */ - public static function userWorkloadsConfigMapName( - $project, - $location, - $environment, - $userWorkloadsConfigMap - ) { - return self::getUserWorkloadsConfigMapNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user_workloads_config_map' => $userWorkloadsConfigMap, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * user_workloads_secret resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $userWorkloadsSecret - * - * @return string The formatted user_workloads_secret resource. - */ - public static function userWorkloadsSecretName( - $project, - $location, - $environment, - $userWorkloadsSecret - ) { - return self::getUserWorkloadsSecretNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user_workloads_secret' => $userWorkloadsSecret, - ]); - } - - /** - * 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} - * - userWorkloadsConfigMap: projects/{project}/locations/{location}/environments/{environment}/userWorkloadsConfigMaps/{user_workloads_config_map} - * - userWorkloadsSecret: projects/{project}/locations/{location}/environments/{environment}/userWorkloadsSecrets/{user_workloads_secret} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Create a new environment. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $operationResponse = $environmentsClient->createEnvironment(); - * $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 = $environmentsClient->createEnvironment(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'createEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * The parent must be of the form - * "projects/{projectId}/locations/{locationId}". - * @type Environment $environment - * The environment to create. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 createEnvironment(array $optionalArgs = []) - { - $request = new CreateEnvironmentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['parent']; - } - - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateEnvironment', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Creates a user workloads ConfigMap. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedParent = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - * $userWorkloadsConfigMap = new UserWorkloadsConfigMap(); - * $response = $environmentsClient->createUserWorkloadsConfigMap($formattedParent, $userWorkloadsConfigMap); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The environment name to create a ConfigMap for, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param UserWorkloadsConfigMap $userWorkloadsConfigMap Required. User workloads ConfigMap to create. - * @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\Orchestration\Airflow\Service\V1\UserWorkloadsConfigMap - * - * @throws ApiException if the remote call fails - */ - public function createUserWorkloadsConfigMap( - $parent, - $userWorkloadsConfigMap, - array $optionalArgs = [] - ) { - $request = new CreateUserWorkloadsConfigMapRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setUserWorkloadsConfigMap($userWorkloadsConfigMap); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateUserWorkloadsConfigMap', - UserWorkloadsConfigMap::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Creates a user workloads Secret. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedParent = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - * $userWorkloadsSecret = new UserWorkloadsSecret(); - * $response = $environmentsClient->createUserWorkloadsSecret($formattedParent, $userWorkloadsSecret); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The environment name to create a Secret for, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @param UserWorkloadsSecret $userWorkloadsSecret Required. User workloads Secret to create. - * @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\Orchestration\Airflow\Service\V1\UserWorkloadsSecret - * - * @throws ApiException if the remote call fails - */ - public function createUserWorkloadsSecret( - $parent, - $userWorkloadsSecret, - array $optionalArgs = [] - ) { - $request = new CreateUserWorkloadsSecretRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setUserWorkloadsSecret($userWorkloadsSecret); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateUserWorkloadsSecret', - UserWorkloadsSecret::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Triggers database failover (only for highly resilient environments). - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $operationResponse = $environmentsClient->databaseFailover(); - * $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 = $environmentsClient->databaseFailover(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'databaseFailover'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * Target environment: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 databaseFailover(array $optionalArgs = []) - { - $request = new DatabaseFailoverRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - $requestParamHeaders['environment'] = $optionalArgs['environment']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DatabaseFailover', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Delete an environment. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $operationResponse = $environmentsClient->deleteEnvironment(); - * $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 = $environmentsClient->deleteEnvironment(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'deleteEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The environment to delete, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 deleteEnvironment(array $optionalArgs = []) - { - $request = new DeleteEnvironmentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteEnvironment', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a user workloads ConfigMap. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedName = $environmentsClient->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - * $environmentsClient->deleteUserWorkloadsConfigMap($formattedName); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $name Required. The ConfigMap to delete, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}/userWorkloadsConfigMaps/{userWorkloadsConfigMapId}" - * @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 deleteUserWorkloadsConfigMap( - $name, - array $optionalArgs = [] - ) { - $request = new DeleteUserWorkloadsConfigMapRequest(); - $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( - 'DeleteUserWorkloadsConfigMap', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a user workloads Secret. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedName = $environmentsClient->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - * $environmentsClient->deleteUserWorkloadsSecret($formattedName); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $name Required. The Secret to delete, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}/userWorkloadsSecrets/{userWorkloadsSecretId}" - * @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 deleteUserWorkloadsSecret($name, array $optionalArgs = []) - { - $request = new DeleteUserWorkloadsSecretRequest(); - $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( - 'DeleteUserWorkloadsSecret', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Executes Airflow CLI command. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $response = $environmentsClient->executeAirflowCommand(); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - * @type string $command - * Airflow command. - * @type string $subcommand - * Airflow subcommand. - * @type string[] $parameters - * Parameters for the Airflow command/subcommand as an array of arguments. - * It may contain positional arguments like `["my-dag-id"]`, key-value - * parameters like `["--foo=bar"]` or `["--foo","bar"]`, - * or other flags like `["-f"]`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Orchestration\Airflow\Service\V1\ExecuteAirflowCommandResponse - * - * @throws ApiException if the remote call fails - */ - public function executeAirflowCommand(array $optionalArgs = []) - { - $request = new ExecuteAirflowCommandRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - $requestParamHeaders['environment'] = $optionalArgs['environment']; - } - - if (isset($optionalArgs['command'])) { - $request->setCommand($optionalArgs['command']); - } - - if (isset($optionalArgs['subcommand'])) { - $request->setSubcommand($optionalArgs['subcommand']); - } - - if (isset($optionalArgs['parameters'])) { - $request->setParameters($optionalArgs['parameters']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'ExecuteAirflowCommand', - ExecuteAirflowCommandResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Fetches database properties. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedEnvironment = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - * $response = $environmentsClient->fetchDatabaseProperties($formattedEnvironment); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $environment Required. The resource name of the environment, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @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\Orchestration\Airflow\Service\V1\FetchDatabasePropertiesResponse - * - * @throws ApiException if the remote call fails - */ - public function fetchDatabaseProperties( - $environment, - array $optionalArgs = [] - ) { - $request = new FetchDatabasePropertiesRequest(); - $requestParamHeaders = []; - $request->setEnvironment($environment); - $requestParamHeaders['environment'] = $environment; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'FetchDatabaseProperties', - FetchDatabasePropertiesResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get an existing environment. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $response = $environmentsClient->getEnvironment(); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource name of the environment to get, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Orchestration\Airflow\Service\V1\Environment - * - * @throws ApiException if the remote call fails - */ - public function getEnvironment(array $optionalArgs = []) - { - $request = new GetEnvironmentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetEnvironment', - Environment::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets an existing user workloads ConfigMap. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedName = $environmentsClient->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - * $response = $environmentsClient->getUserWorkloadsConfigMap($formattedName); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the ConfigMap to get, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}/userWorkloadsConfigMaps/{userWorkloadsConfigMapId}" - * @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\Orchestration\Airflow\Service\V1\UserWorkloadsConfigMap - * - * @throws ApiException if the remote call fails - */ - public function getUserWorkloadsConfigMap($name, array $optionalArgs = []) - { - $request = new GetUserWorkloadsConfigMapRequest(); - $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( - 'GetUserWorkloadsConfigMap', - UserWorkloadsConfigMap::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets an existing user workloads Secret. - * Values of the "data" field in the response are cleared. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedName = $environmentsClient->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - * $response = $environmentsClient->getUserWorkloadsSecret($formattedName); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the Secret to get, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}/userWorkloadsSecrets/{userWorkloadsSecretId}" - * @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\Orchestration\Airflow\Service\V1\UserWorkloadsSecret - * - * @throws ApiException if the remote call fails - */ - public function getUserWorkloadsSecret($name, array $optionalArgs = []) - { - $request = new GetUserWorkloadsSecretRequest(); - $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( - 'GetUserWorkloadsSecret', - UserWorkloadsSecret::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * List environments. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $environmentsClient->listEnvironments(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $environmentsClient->listEnvironments(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * List environments in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @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 listEnvironments(array $optionalArgs = []) - { - $request = new ListEnvironmentsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['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( - 'ListEnvironments', - $optionalArgs, - ListEnvironmentsResponse::class, - $request - ); - } - - /** - * Lists user workloads ConfigMaps. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedParent = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - * // Iterate over pages of elements - * $pagedResponse = $environmentsClient->listUserWorkloadsConfigMaps($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $environmentsClient->listUserWorkloadsConfigMaps($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $parent Required. List ConfigMaps in the given environment, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @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 listUserWorkloadsConfigMaps( - $parent, - array $optionalArgs = [] - ) { - $request = new ListUserWorkloadsConfigMapsRequest(); - $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( - 'ListUserWorkloadsConfigMaps', - $optionalArgs, - ListUserWorkloadsConfigMapsResponse::class, - $request - ); - } - - /** - * Lists user workloads Secrets. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedParent = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - * // Iterate over pages of elements - * $pagedResponse = $environmentsClient->listUserWorkloadsSecrets($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $environmentsClient->listUserWorkloadsSecrets($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $parent Required. List Secrets in the given environment, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @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 listUserWorkloadsSecrets($parent, array $optionalArgs = []) - { - $request = new ListUserWorkloadsSecretsRequest(); - $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( - 'ListUserWorkloadsSecrets', - $optionalArgs, - ListUserWorkloadsSecretsResponse::class, - $request - ); - } - - /** - * Lists workloads in a Cloud Composer environment. Workload is a unit that - * runs a single Composer component. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedParent = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - * // Iterate over pages of elements - * $pagedResponse = $environmentsClient->listWorkloads($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $environmentsClient->listWorkloads($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The environment name to get workloads for, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @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 string $filter - * Optional. The list filter. - * Currently only supports equality on the type field. The value of a field - * specified in the filter expression must be one ComposerWorkloadType enum - * option. It's possible to get multiple types using "OR" operator, e.g.: - * "type=SCHEDULER OR type=CELERY_WORKER". If not specified, all items are - * returned. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listWorkloads($parent, array $optionalArgs = []) - { - $request = new ListWorkloadsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListWorkloads', - $optionalArgs, - ListWorkloadsResponse::class, - $request - ); - } - - /** - * 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. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $operationResponse = $environmentsClient->loadSnapshot(); - * $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 = $environmentsClient->loadSnapshot(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'loadSnapshot'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * The resource name of the target environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @type string $snapshotPath - * A Cloud Storage path to a snapshot to load, e.g.: - * "gs://my-bucket/snapshots/project_location_environment_timestamp". - * @type bool $skipPypiPackagesInstallation - * Whether or not to skip installing Pypi packages when loading the - * environment's state. - * @type bool $skipEnvironmentVariablesSetting - * Whether or not to skip setting environment variables when loading the - * environment's state. - * @type bool $skipAirflowOverridesSetting - * Whether or not to skip setting Airflow overrides when loading the - * environment's state. - * @type bool $skipGcsDataCopying - * Whether or not to skip copying Cloud Storage data when loading the - * environment's state. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 loadSnapshot(array $optionalArgs = []) - { - $request = new LoadSnapshotRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - $requestParamHeaders['environment'] = $optionalArgs['environment']; - } - - if (isset($optionalArgs['snapshotPath'])) { - $request->setSnapshotPath($optionalArgs['snapshotPath']); - } - - if (isset($optionalArgs['skipPypiPackagesInstallation'])) { - $request->setSkipPypiPackagesInstallation( - $optionalArgs['skipPypiPackagesInstallation'] - ); - } - - if (isset($optionalArgs['skipEnvironmentVariablesSetting'])) { - $request->setSkipEnvironmentVariablesSetting( - $optionalArgs['skipEnvironmentVariablesSetting'] - ); - } - - if (isset($optionalArgs['skipAirflowOverridesSetting'])) { - $request->setSkipAirflowOverridesSetting( - $optionalArgs['skipAirflowOverridesSetting'] - ); - } - - if (isset($optionalArgs['skipGcsDataCopying'])) { - $request->setSkipGcsDataCopying( - $optionalArgs['skipGcsDataCopying'] - ); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'LoadSnapshot', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Polls Airflow CLI command execution and fetches logs. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $response = $environmentsClient->pollAirflowCommand(); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @type string $executionId - * The unique ID of the command execution. - * @type string $pod - * The name of the pod where the command is executed. - * @type string $podNamespace - * The namespace of the pod where the command is executed. - * @type int $nextLineNumber - * Line number from which new logs should be fetched. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Orchestration\Airflow\Service\V1\PollAirflowCommandResponse - * - * @throws ApiException if the remote call fails - */ - public function pollAirflowCommand(array $optionalArgs = []) - { - $request = new PollAirflowCommandRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - $requestParamHeaders['environment'] = $optionalArgs['environment']; - } - - if (isset($optionalArgs['executionId'])) { - $request->setExecutionId($optionalArgs['executionId']); - } - - if (isset($optionalArgs['pod'])) { - $request->setPod($optionalArgs['pod']); - } - - if (isset($optionalArgs['podNamespace'])) { - $request->setPodNamespace($optionalArgs['podNamespace']); - } - - if (isset($optionalArgs['nextLineNumber'])) { - $request->setNextLineNumber($optionalArgs['nextLineNumber']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'PollAirflowCommand', - PollAirflowCommandResponse::class, - $optionalArgs, - $request - )->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. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $operationResponse = $environmentsClient->saveSnapshot(); - * $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 = $environmentsClient->saveSnapshot(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'saveSnapshot'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * The resource name of the source environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @type string $snapshotLocation - * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: - * "gs://my-bucket/snapshots". - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 saveSnapshot(array $optionalArgs = []) - { - $request = new SaveSnapshotRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - $requestParamHeaders['environment'] = $optionalArgs['environment']; - } - - if (isset($optionalArgs['snapshotLocation'])) { - $request->setSnapshotLocation($optionalArgs['snapshotLocation']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'SaveSnapshot', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Stops Airflow CLI command execution. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $response = $environmentsClient->stopAirflowCommand(); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * The resource name of the environment in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}". - * @type string $executionId - * The unique ID of the command execution. - * @type string $pod - * The name of the pod where the command is executed. - * @type string $podNamespace - * The namespace of the pod where the command is executed. - * @type bool $force - * If true, the execution is terminated forcefully (SIGKILL). If false, the - * execution is stopped gracefully, giving it time for cleanup. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Orchestration\Airflow\Service\V1\StopAirflowCommandResponse - * - * @throws ApiException if the remote call fails - */ - public function stopAirflowCommand(array $optionalArgs = []) - { - $request = new StopAirflowCommandRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - $requestParamHeaders['environment'] = $optionalArgs['environment']; - } - - if (isset($optionalArgs['executionId'])) { - $request->setExecutionId($optionalArgs['executionId']); - } - - if (isset($optionalArgs['pod'])) { - $request->setPod($optionalArgs['pod']); - } - - if (isset($optionalArgs['podNamespace'])) { - $request->setPodNamespace($optionalArgs['podNamespace']); - } - - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'StopAirflowCommand', - StopAirflowCommandResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Update an environment. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $operationResponse = $environmentsClient->updateEnvironment(); - * $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 = $environmentsClient->updateEnvironment(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'updateEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The relative resource name of the environment to update, in the form: - * "projects/{projectId}/locations/{locationId}/environments/{environmentId}" - * @type Environment $environment - * A patch environment. Fields specified by the `updateMask` will be copied - * from the patch environment into the environment under update. - * @type FieldMask $updateMask - * Required. A comma-separated list of paths, relative to `Environment`, of - * fields to update. - * For example, to set the version of scikit-learn to install in the - * environment to 0.19.0 and to remove an existing installation of - * numpy, the `updateMask` parameter would include the following two - * `paths` values: "config.softwareConfig.pypiPackages.scikit-learn" and - * "config.softwareConfig.pypiPackages.numpy". The included patch - * environment would specify the scikit-learn version as follows: - * - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "scikit-learn":"==0.19.0" - * } - * } - * } - * } - * - * Note that in the above example, any existing PyPI packages - * other than scikit-learn and numpy will be unaffected. - * - * Only one update type may be included in a single request's `updateMask`. - * For example, one cannot update both the PyPI packages and - * labels in the same request. However, it is possible to update multiple - * members of a map field simultaneously in the same request. For example, - * to set the labels "label1" and "label2" while clearing "label3" (assuming - * it already exists), one can - * provide the paths "labels.label1", "labels.label2", and "labels.label3" - * and populate the patch environment as follows: - * - * { - * "labels":{ - * "label1":"new-label1-value" - * "label2":"new-label2-value" - * } - * } - * - * Note that in the above example, any existing labels that are not - * included in the `updateMask` will be unaffected. - * - * It is also possible to replace an entire map field by providing the - * map field's path in the `updateMask`. The new value of the field will - * be that which is provided in the patch environment. For example, to - * delete all pre-existing user-specified PyPI packages and - * install botocore at version 1.7.14, the `updateMask` would contain - * the path "config.softwareConfig.pypiPackages", and - * the patch environment would be the following: - * - * { - * "config":{ - * "softwareConfig":{ - * "pypiPackages":{ - * "botocore":"==1.7.14" - * } - * } - * } - * } - * - * **Note:** Only the following fields can be updated: - * - * * `config.softwareConfig.pypiPackages` - * * Replace all custom custom PyPI packages. If a replacement - * package map is not included in `environment`, all custom - * PyPI packages are cleared. It is an error to provide both - * this mask and a mask specifying an individual package. - * * `config.softwareConfig.pypiPackages.`packagename - * * Update the custom PyPI package *packagename*, - * preserving other packages. To delete the package, include it in - * `updateMask`, and omit the mapping for it in - * `environment.config.softwareConfig.pypiPackages`. It is an error - * to provide both a mask of this form and the - * `config.softwareConfig.pypiPackages` mask. - * * `labels` - * * Replace all environment labels. If a replacement labels map is not - * included in `environment`, all labels are cleared. It is an error to - * provide both this mask and a mask specifying one or more individual - * labels. - * * `labels.`labelName - * * Set the label named *labelName*, while preserving other - * labels. To delete the label, include it in `updateMask` and omit its - * mapping in `environment.labels`. It is an error to provide both a - * mask of this form and the `labels` mask. - * * `config.nodeCount` - * * Horizontally scale the number of nodes in the environment. An integer - * greater than or equal to 3 must be provided in the `config.nodeCount` - * field. Supported for Cloud Composer environments in versions - * composer-1.*.*-airflow-*.*.*. - * * `config.webServerNetworkAccessControl` - * * Replace the environment's current `WebServerNetworkAccessControl`. - * * `config.softwareConfig.airflowConfigOverrides` - * * Replace all Apache Airflow config overrides. If a replacement config - * overrides map is not included in `environment`, all config overrides - * are cleared. - * It is an error to provide both this mask and a mask specifying one or - * more individual config overrides. - * * `config.softwareConfig.airflowConfigOverrides.`section-name - * * Override the Apache Airflow config property *name* in the - * section named *section*, preserving other properties. To - * delete the property override, include it in `updateMask` and omit its - * mapping in - * `environment.config.softwareConfig.airflowConfigOverrides`. - * It is an error to provide both a mask of this form and the - * `config.softwareConfig.airflowConfigOverrides` mask. - * * `config.softwareConfig.envVariables` - * * Replace all environment variables. If a replacement environment - * variable map is not included in `environment`, all custom environment - * variables are cleared. - * * `config.softwareConfig.schedulerCount` - * * Horizontally scale the number of schedulers in Airflow. A positive - * integer not greater than the number of nodes must be provided in the - * `config.softwareConfig.schedulerCount` field. Supported for Cloud - * Composer environments in versions composer-1.*.*-airflow-2.*.*. - * * `config.databaseConfig.machineType` - * * Cloud SQL machine type used by Airflow database. - * It has to be one of: db-n1-standard-2, db-n1-standard-4, - * db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer - * environments in versions composer-1.*.*-airflow-*.*.*. - * * `config.webServerConfig.machineType` - * * Machine type on which Airflow web server is running. - * It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 - * or composer-n1-webserver-8. Supported for Cloud Composer environments - * in versions composer-1.*.*-airflow-*.*.*. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 updateEnvironment(array $optionalArgs = []) - { - $request = new UpdateEnvironmentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - } - - 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->startOperationsCall( - 'UpdateEnvironment', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Updates a user workloads ConfigMap. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $response = $environmentsClient->updateUserWorkloadsConfigMap(); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type UserWorkloadsConfigMap $userWorkloadsConfigMap - * Optional. User workloads ConfigMap to override. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Orchestration\Airflow\Service\V1\UserWorkloadsConfigMap - * - * @throws ApiException if the remote call fails - */ - public function updateUserWorkloadsConfigMap(array $optionalArgs = []) - { - $request = new UpdateUserWorkloadsConfigMapRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['userWorkloadsConfigMap'])) { - $request->setUserWorkloadsConfigMap( - $optionalArgs['userWorkloadsConfigMap'] - ); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'UpdateUserWorkloadsConfigMap', - UserWorkloadsConfigMap::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates a user workloads Secret. - * - * This method is supported for Cloud Composer environments in versions - * composer-3.*.*-airflow-*.*.* and newer. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $response = $environmentsClient->updateUserWorkloadsSecret(); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type UserWorkloadsSecret $userWorkloadsSecret - * Optional. User workloads Secret to override. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Orchestration\Airflow\Service\V1\UserWorkloadsSecret - * - * @throws ApiException if the remote call fails - */ - public function updateUserWorkloadsSecret(array $optionalArgs = []) - { - $request = new UpdateUserWorkloadsSecretRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['userWorkloadsSecret'])) { - $request->setUserWorkloadsSecret( - $optionalArgs['userWorkloadsSecret'] - ); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'UpdateUserWorkloadsSecret', - UserWorkloadsSecret::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/OrchestrationAirflow/src/V1/Gapic/ImageVersionsGapicClient.php b/OrchestrationAirflow/src/V1/Gapic/ImageVersionsGapicClient.php deleted file mode 100644 index 8d9cd7582af1..000000000000 --- a/OrchestrationAirflow/src/V1/Gapic/ImageVersionsGapicClient.php +++ /dev/null @@ -1,268 +0,0 @@ -listImageVersions(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $imageVersionsClient->listImageVersions(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $imageVersionsClient->close(); - * } - * ``` - * - * @deprecated Please use the new service client {@see \Google\Cloud\Orchestration\Airflow\Service\V1\Client\ImageVersionsClient}. - */ -class ImageVersionsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.orchestration.airflow.service.v1.ImageVersions'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'composer.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'composer.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static 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); - } - - /** - * List ImageVersions for provided location. - * - * Sample code: - * ``` - * $imageVersionsClient = new ImageVersionsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $imageVersionsClient->listImageVersions(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $imageVersionsClient->listImageVersions(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $imageVersionsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * List ImageVersions in the given project and location, in the form: - * "projects/{projectId}/locations/{locationId}" - * @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 bool $includePastReleases - * Whether or not image versions from old releases should be included. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listImageVersions(array $optionalArgs = []) - { - $request = new ListImageVersionsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['parent']; - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['includePastReleases'])) { - $request->setIncludePastReleases( - $optionalArgs['includePastReleases'] - ); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListImageVersions', - $optionalArgs, - ListImageVersionsResponse::class, - $request - ); - } -} diff --git a/OrchestrationAirflow/src/V1/GetEnvironmentRequest.php b/OrchestrationAirflow/src/V1/GetEnvironmentRequest.php index 0581f5d13848..fc67aee19860 100644 --- a/OrchestrationAirflow/src/V1/GetEnvironmentRequest.php +++ b/OrchestrationAirflow/src/V1/GetEnvironmentRequest.php @@ -21,7 +21,7 @@ class GetEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * @param string $name The resource name of the environment to get, in the form: diff --git a/OrchestrationAirflow/src/V1/GetUserWorkloadsConfigMapRequest.php b/OrchestrationAirflow/src/V1/GetUserWorkloadsConfigMapRequest.php index 7c6b16533a91..bd1ec8a5330a 100644 --- a/OrchestrationAirflow/src/V1/GetUserWorkloadsConfigMapRequest.php +++ b/OrchestrationAirflow/src/V1/GetUserWorkloadsConfigMapRequest.php @@ -21,7 +21,7 @@ class GetUserWorkloadsConfigMapRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The resource name of the ConfigMap to get, in the form: diff --git a/OrchestrationAirflow/src/V1/GetUserWorkloadsSecretRequest.php b/OrchestrationAirflow/src/V1/GetUserWorkloadsSecretRequest.php index c99a8ac79b23..e1cdc05d0b68 100644 --- a/OrchestrationAirflow/src/V1/GetUserWorkloadsSecretRequest.php +++ b/OrchestrationAirflow/src/V1/GetUserWorkloadsSecretRequest.php @@ -21,7 +21,7 @@ class GetUserWorkloadsSecretRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The resource name of the Secret to get, in the form: diff --git a/OrchestrationAirflow/src/V1/IPAllocationPolicy.php b/OrchestrationAirflow/src/V1/IPAllocationPolicy.php index b6677ae025af..184b6d0ef50e 100644 --- a/OrchestrationAirflow/src/V1/IPAllocationPolicy.php +++ b/OrchestrationAirflow/src/V1/IPAllocationPolicy.php @@ -25,7 +25,7 @@ class IPAllocationPolicy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool use_ip_aliases = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $use_ip_aliases = false; + protected $use_ip_aliases = false; protected $cluster_ip_allocation; protected $services_ip_allocation; diff --git a/OrchestrationAirflow/src/V1/ImageVersion.php b/OrchestrationAirflow/src/V1/ImageVersion.php index 86e6fdfc235b..405feff4278e 100644 --- a/OrchestrationAirflow/src/V1/ImageVersion.php +++ b/OrchestrationAirflow/src/V1/ImageVersion.php @@ -21,14 +21,14 @@ class ImageVersion extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string image_version_id = 1; */ - private $image_version_id = ''; + protected $image_version_id = ''; /** * Whether this is the default ImageVersion used by Composer during * environment creation if no input ImageVersion is specified. * * Generated from protobuf field bool is_default = 2; */ - private $is_default = false; + protected $is_default = false; /** * supported python versions * @@ -40,20 +40,20 @@ class ImageVersion extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.type.Date release_date = 4; */ - private $release_date = null; + protected $release_date = null; /** * Whether it is impossible to create an environment with the image version. * * Generated from protobuf field bool creation_disabled = 5; */ - private $creation_disabled = false; + protected $creation_disabled = false; /** * Whether it is impossible to upgrade an environment running with the image * version. * * Generated from protobuf field bool upgrade_disabled = 6; */ - private $upgrade_disabled = false; + protected $upgrade_disabled = false; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/ImageVersionsClient.php b/OrchestrationAirflow/src/V1/ImageVersionsClient.php deleted file mode 100644 index 92e80a6e67a9..000000000000 --- a/OrchestrationAirflow/src/V1/ImageVersionsClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string parent = 1; */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of environments to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value returned from a previous List request, if any. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent List environments in the given project and location, in the form: diff --git a/OrchestrationAirflow/src/V1/ListEnvironmentsResponse.php b/OrchestrationAirflow/src/V1/ListEnvironmentsResponse.php index d8a6388d2c34..11adef627138 100644 --- a/OrchestrationAirflow/src/V1/ListEnvironmentsResponse.php +++ b/OrchestrationAirflow/src/V1/ListEnvironmentsResponse.php @@ -26,7 +26,7 @@ class ListEnvironmentsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/ListImageVersionsRequest.php b/OrchestrationAirflow/src/V1/ListImageVersionsRequest.php index 607302a852f3..a89e8c354f52 100644 --- a/OrchestrationAirflow/src/V1/ListImageVersionsRequest.php +++ b/OrchestrationAirflow/src/V1/ListImageVersionsRequest.php @@ -21,25 +21,25 @@ class ListImageVersionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1; */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of image_versions to return. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The next_page_token value returned from a previous List request, if any. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * Whether or not image versions from old releases should be included. * * Generated from protobuf field bool include_past_releases = 4; */ - private $include_past_releases = false; + protected $include_past_releases = false; /** * @param string $parent List ImageVersions in the given project and location, in the form: diff --git a/OrchestrationAirflow/src/V1/ListImageVersionsResponse.php b/OrchestrationAirflow/src/V1/ListImageVersionsResponse.php index 39773336f1a3..96b637d44898 100644 --- a/OrchestrationAirflow/src/V1/ListImageVersionsResponse.php +++ b/OrchestrationAirflow/src/V1/ListImageVersionsResponse.php @@ -26,7 +26,7 @@ class ListImageVersionsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/ListUserWorkloadsConfigMapsRequest.php b/OrchestrationAirflow/src/V1/ListUserWorkloadsConfigMapsRequest.php index 2e68e3af8c18..2046af856140 100644 --- a/OrchestrationAirflow/src/V1/ListUserWorkloadsConfigMapsRequest.php +++ b/OrchestrationAirflow/src/V1/ListUserWorkloadsConfigMapsRequest.php @@ -21,20 +21,20 @@ class ListUserWorkloadsConfigMapsRequest extends \Google\Protobuf\Internal\Messa * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. The maximum number of ConfigMaps to return. * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The next_page_token value returned from a previous List request, * if any. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. List ConfigMaps in the given environment, in the form: diff --git a/OrchestrationAirflow/src/V1/ListUserWorkloadsConfigMapsResponse.php b/OrchestrationAirflow/src/V1/ListUserWorkloadsConfigMapsResponse.php index da9adf0ce9d1..2f724620a158 100644 --- a/OrchestrationAirflow/src/V1/ListUserWorkloadsConfigMapsResponse.php +++ b/OrchestrationAirflow/src/V1/ListUserWorkloadsConfigMapsResponse.php @@ -26,7 +26,7 @@ class ListUserWorkloadsConfigMapsResponse extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/ListUserWorkloadsSecretsRequest.php b/OrchestrationAirflow/src/V1/ListUserWorkloadsSecretsRequest.php index eb4a3f982c84..2033ac139f94 100644 --- a/OrchestrationAirflow/src/V1/ListUserWorkloadsSecretsRequest.php +++ b/OrchestrationAirflow/src/V1/ListUserWorkloadsSecretsRequest.php @@ -21,20 +21,20 @@ class ListUserWorkloadsSecretsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. The maximum number of Secrets to return. * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The next_page_token value returned from a previous List request, * if any. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. List Secrets in the given environment, in the form: diff --git a/OrchestrationAirflow/src/V1/ListUserWorkloadsSecretsResponse.php b/OrchestrationAirflow/src/V1/ListUserWorkloadsSecretsResponse.php index 1067194676db..0719870695d3 100644 --- a/OrchestrationAirflow/src/V1/ListUserWorkloadsSecretsResponse.php +++ b/OrchestrationAirflow/src/V1/ListUserWorkloadsSecretsResponse.php @@ -26,7 +26,7 @@ class ListUserWorkloadsSecretsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/ListWorkloadsRequest.php b/OrchestrationAirflow/src/V1/ListWorkloadsRequest.php index b041aad01683..b52f55294277 100644 --- a/OrchestrationAirflow/src/V1/ListWorkloadsRequest.php +++ b/OrchestrationAirflow/src/V1/ListWorkloadsRequest.php @@ -21,20 +21,20 @@ class ListWorkloadsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. The maximum number of environments to return. * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The next_page_token value returned from a previous List request, * if any. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. The list filter. * Currently only supports equality on the type field. The value of a field @@ -45,7 +45,7 @@ class ListWorkloadsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The environment name to get workloads for, in the form: diff --git a/OrchestrationAirflow/src/V1/ListWorkloadsResponse.php b/OrchestrationAirflow/src/V1/ListWorkloadsResponse.php index 543810788f2c..4e83ea12af70 100644 --- a/OrchestrationAirflow/src/V1/ListWorkloadsResponse.php +++ b/OrchestrationAirflow/src/V1/ListWorkloadsResponse.php @@ -26,7 +26,7 @@ class ListWorkloadsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/ListWorkloadsResponse/ComposerWorkload.php b/OrchestrationAirflow/src/V1/ListWorkloadsResponse/ComposerWorkload.php index 232d4a65f485..9fb3f129d98e 100644 --- a/OrchestrationAirflow/src/V1/ListWorkloadsResponse/ComposerWorkload.php +++ b/OrchestrationAirflow/src/V1/ListWorkloadsResponse/ComposerWorkload.php @@ -20,19 +20,19 @@ class ComposerWorkload extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Type of a workload. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.ListWorkloadsResponse.ComposerWorkloadType type = 2; */ - private $type = 0; + protected $type = 0; /** * Output only. Status of a workload. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.ListWorkloadsResponse.ComposerWorkloadStatus status = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $status = null; + protected $status = null; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/ListWorkloadsResponse/ComposerWorkloadStatus.php b/OrchestrationAirflow/src/V1/ListWorkloadsResponse/ComposerWorkloadStatus.php index d8b16368cd7f..41d0f4bc1164 100644 --- a/OrchestrationAirflow/src/V1/ListWorkloadsResponse/ComposerWorkloadStatus.php +++ b/OrchestrationAirflow/src/V1/ListWorkloadsResponse/ComposerWorkloadStatus.php @@ -20,19 +20,19 @@ class ComposerWorkloadStatus extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.ListWorkloadsResponse.ComposerWorkloadState state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. Text to provide more descriptive status. * * Generated from protobuf field string status_message = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $status_message = ''; + protected $status_message = ''; /** * Output only. Detailed message of the status. * * Generated from protobuf field string detailed_status_message = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $detailed_status_message = ''; + protected $detailed_status_message = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/LoadSnapshotRequest.php b/OrchestrationAirflow/src/V1/LoadSnapshotRequest.php index dfe10d7983f5..fe4126d9df59 100644 --- a/OrchestrationAirflow/src/V1/LoadSnapshotRequest.php +++ b/OrchestrationAirflow/src/V1/LoadSnapshotRequest.php @@ -21,42 +21,42 @@ class LoadSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string environment = 1; */ - private $environment = ''; + protected $environment = ''; /** * A Cloud Storage path to a snapshot to load, e.g.: * "gs://my-bucket/snapshots/project_location_environment_timestamp". * * Generated from protobuf field string snapshot_path = 2; */ - private $snapshot_path = ''; + protected $snapshot_path = ''; /** * Whether or not to skip installing Pypi packages when loading the * environment's state. * * Generated from protobuf field bool skip_pypi_packages_installation = 3; */ - private $skip_pypi_packages_installation = false; + protected $skip_pypi_packages_installation = false; /** * Whether or not to skip setting environment variables when loading the * environment's state. * * Generated from protobuf field bool skip_environment_variables_setting = 4; */ - private $skip_environment_variables_setting = false; + protected $skip_environment_variables_setting = false; /** * Whether or not to skip setting Airflow overrides when loading the * environment's state. * * Generated from protobuf field bool skip_airflow_overrides_setting = 5; */ - private $skip_airflow_overrides_setting = false; + protected $skip_airflow_overrides_setting = false; /** * Whether or not to skip copying Cloud Storage data when loading the * environment's state. * * Generated from protobuf field bool skip_gcs_data_copying = 6; */ - private $skip_gcs_data_copying = false; + protected $skip_gcs_data_copying = false; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/MaintenanceWindow.php b/OrchestrationAirflow/src/V1/MaintenanceWindow.php index 99b41d5109df..da4c28d1f6e9 100644 --- a/OrchestrationAirflow/src/V1/MaintenanceWindow.php +++ b/OrchestrationAirflow/src/V1/MaintenanceWindow.php @@ -30,7 +30,7 @@ class MaintenanceWindow extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp start_time = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $start_time = null; + protected $start_time = null; /** * Required. Maintenance window end time. It is used only to calculate the * duration of the maintenance window. The value for end-time must be in the @@ -38,7 +38,7 @@ class MaintenanceWindow extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $end_time = null; + protected $end_time = null; /** * Required. Maintenance window recurrence. Format is a subset of * [RFC-5545](https://tools.ietf.org/html/rfc5545) `RRULE`. The only allowed @@ -47,7 +47,7 @@ class MaintenanceWindow extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string recurrence = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $recurrence = ''; + protected $recurrence = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/MasterAuthorizedNetworksConfig.php b/OrchestrationAirflow/src/V1/MasterAuthorizedNetworksConfig.php index 46802b08f4a0..e7c09c6da662 100644 --- a/OrchestrationAirflow/src/V1/MasterAuthorizedNetworksConfig.php +++ b/OrchestrationAirflow/src/V1/MasterAuthorizedNetworksConfig.php @@ -23,7 +23,7 @@ class MasterAuthorizedNetworksConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enabled = 1; */ - private $enabled = false; + protected $enabled = false; /** * Up to 50 external networks that could access Kubernetes master through * HTTPS. diff --git a/OrchestrationAirflow/src/V1/MasterAuthorizedNetworksConfig/CidrBlock.php b/OrchestrationAirflow/src/V1/MasterAuthorizedNetworksConfig/CidrBlock.php index fce3435fee7d..3cfc812211bf 100644 --- a/OrchestrationAirflow/src/V1/MasterAuthorizedNetworksConfig/CidrBlock.php +++ b/OrchestrationAirflow/src/V1/MasterAuthorizedNetworksConfig/CidrBlock.php @@ -20,13 +20,13 @@ class CidrBlock extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * CIDR block that must be specified in CIDR notation. * * Generated from protobuf field string cidr_block = 2; */ - private $cidr_block = ''; + protected $cidr_block = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/NetworkingConfig.php b/OrchestrationAirflow/src/V1/NetworkingConfig.php index 37e72aef7e91..104b52d25dc8 100644 --- a/OrchestrationAirflow/src/V1/NetworkingConfig.php +++ b/OrchestrationAirflow/src/V1/NetworkingConfig.php @@ -23,7 +23,7 @@ class NetworkingConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.NetworkingConfig.ConnectionType connection_type = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $connection_type = 0; + protected $connection_type = 0; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/NodeConfig.php b/OrchestrationAirflow/src/V1/NodeConfig.php index eb028aff5725..f10507266864 100644 --- a/OrchestrationAirflow/src/V1/NodeConfig.php +++ b/OrchestrationAirflow/src/V1/NodeConfig.php @@ -17,10 +17,10 @@ class NodeConfig extends \Google\Protobuf\Internal\Message { /** - * Optional. The Compute Engine [zone](https://cloud.google.com/compute/docs/regions-zones) in which + * Optional. The Compute Engine [zone](/compute/docs/regions-zones) in which * to deploy the VMs used to run the Apache Airflow software, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/zones/{zoneId}". * This `location` must belong to the enclosing environment's project and * location. If both this field and `nodeConfig.machineType` are specified, @@ -35,13 +35,13 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string location = 1; */ - private $location = ''; + protected $location = ''; /** * Optional. The Compute Engine - * [machine type](https://cloud.google.com/compute/docs/machine-types) used for cluster instances, + * [machine type](/compute/docs/machine-types) used for cluster instances, * specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/zones/{zoneId}/machineTypes/{machineTypeId}". * The `machineType` must belong to the enclosing environment's project and * location. If both this field and `nodeConfig.location` are specified, @@ -52,7 +52,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * specified, the location information from the specified field will be * propagated to the unspecified field. * The `machineTypeId` must not be a [shared-core machine - * type](https://cloud.google.com/compute/docs/machine-types#sharedcore). + * type](/compute/docs/machine-types#sharedcore). * If this field is unspecified, the `machineTypeId` defaults * to "n1-standard-1". * This field is supported for Cloud Composer environments in versions @@ -60,27 +60,27 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string machine_type = 2; */ - private $machine_type = ''; + protected $machine_type = ''; /** * Optional. The Compute Engine network to be used for machine * communications, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/global/networks/{networkId}". * If unspecified, the "default" network ID in the environment's project is - * used. If a [Custom Subnet Network](https://cloud.google.com/vpc/docs/vpc#vpc_networks_and_subnets) + * used. If a [Custom Subnet Network](/vpc/docs/vpc#vpc_networks_and_subnets) * is provided, `nodeConfig.subnetwork` must also be provided. For - * [Shared VPC](https://cloud.google.com/vpc/docs/shared-vpc) subnetwork requirements, see + * [Shared VPC](/vpc/docs/shared-vpc) subnetwork requirements, see * `nodeConfig.subnetwork`. * * Generated from protobuf field string network = 3; */ - private $network = ''; + protected $network = ''; /** * Optional. The Compute Engine subnetwork to be used for machine * communications, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/regions/{regionId}/subnetworks/{subnetworkId}" * If a subnetwork is provided, `nodeConfig.network` must also be provided, * and the subnetwork must belong to the enclosing environment's project and @@ -88,7 +88,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string subnetwork = 4; */ - private $subnetwork = ''; + protected $subnetwork = ''; /** * Optional. The disk size in GB used for node VMs. Minimum size is 30GB. * If unspecified, defaults to 100GB. Cannot be updated. @@ -97,7 +97,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 disk_size_gb = 5; */ - private $disk_size_gb = 0; + protected $disk_size_gb = 0; /** * Optional. The set of Google API scopes to be made available on all * node VMs. If `oauth_scopes` is empty, defaults to @@ -115,7 +115,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string service_account = 7; */ - private $service_account = ''; + protected $service_account = ''; /** * Optional. The list of instance tags applied to all node VMs. Tags are used * to identify valid sources or targets for network firewalls. Each tag within @@ -131,7 +131,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.IPAllocationPolicy ip_allocation_policy = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - private $ip_allocation_policy = null; + protected $ip_allocation_policy = null; /** * Optional. Deploys 'ip-masq-agent' daemon set in the GKE cluster and defines * nonMasqueradeCIDRs equals to pod IP range so IP masquerading is used for @@ -141,7 +141,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_ip_masq_agent = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enable_ip_masq_agent = false; + protected $enable_ip_masq_agent = false; /** * Optional. Network Attachment that Cloud Composer environment is connected * to, which provides connectivity with a user's VPC network. Takes precedence @@ -156,7 +156,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string composer_network_attachment = 12 [(.google.api.field_behavior) = OPTIONAL]; */ - private $composer_network_attachment = ''; + protected $composer_network_attachment = ''; /** * Optional. The IP range in CIDR notation to use internally by Cloud * Composer. IP addresses are not reserved - and the same range can be used by @@ -168,7 +168,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string composer_internal_ipv4_cidr_block = 13 [(.google.api.field_behavior) = OPTIONAL]; */ - private $composer_internal_ipv4_cidr_block = ''; + protected $composer_internal_ipv4_cidr_block = ''; /** * Constructor. @@ -177,10 +177,10 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $location - * Optional. The Compute Engine [zone](https://cloud.google.com/compute/docs/regions-zones) in which + * Optional. The Compute Engine [zone](/compute/docs/regions-zones) in which * to deploy the VMs used to run the Apache Airflow software, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/zones/{zoneId}". * This `location` must belong to the enclosing environment's project and * location. If both this field and `nodeConfig.machineType` are specified, @@ -194,10 +194,10 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * composer-1.*.*-airflow-*.*.*. * @type string $machine_type * Optional. The Compute Engine - * [machine type](https://cloud.google.com/compute/docs/machine-types) used for cluster instances, + * [machine type](/compute/docs/machine-types) used for cluster instances, * specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/zones/{zoneId}/machineTypes/{machineTypeId}". * The `machineType` must belong to the enclosing environment's project and * location. If both this field and `nodeConfig.location` are specified, @@ -208,7 +208,7 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * specified, the location information from the specified field will be * propagated to the unspecified field. * The `machineTypeId` must not be a [shared-core machine - * type](https://cloud.google.com/compute/docs/machine-types#sharedcore). + * type](/compute/docs/machine-types#sharedcore). * If this field is unspecified, the `machineTypeId` defaults * to "n1-standard-1". * This field is supported for Cloud Composer environments in versions @@ -217,18 +217,18 @@ class NodeConfig extends \Google\Protobuf\Internal\Message * Optional. The Compute Engine network to be used for machine * communications, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/global/networks/{networkId}". * If unspecified, the "default" network ID in the environment's project is - * used. If a [Custom Subnet Network](https://cloud.google.com/vpc/docs/vpc#vpc_networks_and_subnets) + * used. If a [Custom Subnet Network](/vpc/docs/vpc#vpc_networks_and_subnets) * is provided, `nodeConfig.subnetwork` must also be provided. For - * [Shared VPC](https://cloud.google.com/vpc/docs/shared-vpc) subnetwork requirements, see + * [Shared VPC](/vpc/docs/shared-vpc) subnetwork requirements, see * `nodeConfig.subnetwork`. * @type string $subnetwork * Optional. The Compute Engine subnetwork to be used for machine * communications, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/regions/{regionId}/subnetworks/{subnetworkId}" * If a subnetwork is provided, `nodeConfig.network` must also be provided, * and the subnetwork must belong to the enclosing environment's project and @@ -289,10 +289,10 @@ public function __construct($data = NULL) { } /** - * Optional. The Compute Engine [zone](https://cloud.google.com/compute/docs/regions-zones) in which + * Optional. The Compute Engine [zone](/compute/docs/regions-zones) in which * to deploy the VMs used to run the Apache Airflow software, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/zones/{zoneId}". * This `location` must belong to the enclosing environment's project and * location. If both this field and `nodeConfig.machineType` are specified, @@ -314,10 +314,10 @@ public function getLocation() } /** - * Optional. The Compute Engine [zone](https://cloud.google.com/compute/docs/regions-zones) in which + * Optional. The Compute Engine [zone](/compute/docs/regions-zones) in which * to deploy the VMs used to run the Apache Airflow software, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/zones/{zoneId}". * This `location` must belong to the enclosing environment's project and * location. If both this field and `nodeConfig.machineType` are specified, @@ -344,10 +344,10 @@ public function setLocation($var) /** * Optional. The Compute Engine - * [machine type](https://cloud.google.com/compute/docs/machine-types) used for cluster instances, + * [machine type](/compute/docs/machine-types) used for cluster instances, * specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/zones/{zoneId}/machineTypes/{machineTypeId}". * The `machineType` must belong to the enclosing environment's project and * location. If both this field and `nodeConfig.location` are specified, @@ -358,7 +358,7 @@ public function setLocation($var) * specified, the location information from the specified field will be * propagated to the unspecified field. * The `machineTypeId` must not be a [shared-core machine - * type](https://cloud.google.com/compute/docs/machine-types#sharedcore). + * type](/compute/docs/machine-types#sharedcore). * If this field is unspecified, the `machineTypeId` defaults * to "n1-standard-1". * This field is supported for Cloud Composer environments in versions @@ -374,10 +374,10 @@ public function getMachineType() /** * Optional. The Compute Engine - * [machine type](https://cloud.google.com/compute/docs/machine-types) used for cluster instances, + * [machine type](/compute/docs/machine-types) used for cluster instances, * specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/zones/{zoneId}/machineTypes/{machineTypeId}". * The `machineType` must belong to the enclosing environment's project and * location. If both this field and `nodeConfig.location` are specified, @@ -388,7 +388,7 @@ public function getMachineType() * specified, the location information from the specified field will be * propagated to the unspecified field. * The `machineTypeId` must not be a [shared-core machine - * type](https://cloud.google.com/compute/docs/machine-types#sharedcore). + * type](/compute/docs/machine-types#sharedcore). * If this field is unspecified, the `machineTypeId` defaults * to "n1-standard-1". * This field is supported for Cloud Composer environments in versions @@ -410,12 +410,12 @@ public function setMachineType($var) * Optional. The Compute Engine network to be used for machine * communications, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/global/networks/{networkId}". * If unspecified, the "default" network ID in the environment's project is - * used. If a [Custom Subnet Network](https://cloud.google.com/vpc/docs/vpc#vpc_networks_and_subnets) + * used. If a [Custom Subnet Network](/vpc/docs/vpc#vpc_networks_and_subnets) * is provided, `nodeConfig.subnetwork` must also be provided. For - * [Shared VPC](https://cloud.google.com/vpc/docs/shared-vpc) subnetwork requirements, see + * [Shared VPC](/vpc/docs/shared-vpc) subnetwork requirements, see * `nodeConfig.subnetwork`. * * Generated from protobuf field string network = 3; @@ -430,12 +430,12 @@ public function getNetwork() * Optional. The Compute Engine network to be used for machine * communications, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/global/networks/{networkId}". * If unspecified, the "default" network ID in the environment's project is - * used. If a [Custom Subnet Network](https://cloud.google.com/vpc/docs/vpc#vpc_networks_and_subnets) + * used. If a [Custom Subnet Network](/vpc/docs/vpc#vpc_networks_and_subnets) * is provided, `nodeConfig.subnetwork` must also be provided. For - * [Shared VPC](https://cloud.google.com/vpc/docs/shared-vpc) subnetwork requirements, see + * [Shared VPC](/vpc/docs/shared-vpc) subnetwork requirements, see * `nodeConfig.subnetwork`. * * Generated from protobuf field string network = 3; @@ -454,7 +454,7 @@ public function setNetwork($var) * Optional. The Compute Engine subnetwork to be used for machine * communications, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/regions/{regionId}/subnetworks/{subnetworkId}" * If a subnetwork is provided, `nodeConfig.network` must also be provided, * and the subnetwork must belong to the enclosing environment's project and @@ -472,7 +472,7 @@ public function getSubnetwork() * Optional. The Compute Engine subnetwork to be used for machine * communications, specified as a * [relative resource - * name](https://cloud.google.com/apis/design/resource_names#relative_resource_name). For example: + * name](/apis/design/resource_names#relative_resource_name). For example: * "projects/{projectId}/regions/{regionId}/subnetworks/{subnetworkId}" * If a subnetwork is provided, `nodeConfig.network` must also be provided, * and the subnetwork must belong to the enclosing environment's project and diff --git a/OrchestrationAirflow/src/V1/OperationMetadata.php b/OrchestrationAirflow/src/V1/OperationMetadata.php index 6d5e43aee5b1..ae698a9c0bd0 100644 --- a/OrchestrationAirflow/src/V1/OperationMetadata.php +++ b/OrchestrationAirflow/src/V1/OperationMetadata.php @@ -20,39 +20,39 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.OperationMetadata.State state = 1; */ - private $state = 0; + protected $state = 0; /** * Output only. The type of operation being performed. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.OperationMetadata.Type operation_type = 2; */ - private $operation_type = 0; + protected $operation_type = 0; /** * Output only. The resource being operated on, as a [relative resource name]( * /apis/design/resource_names#relative_resource_name). * * Generated from protobuf field string resource = 3; */ - private $resource = ''; + protected $resource = ''; /** * Output only. The UUID of the resource being operated on. * * Generated from protobuf field string resource_uuid = 4; */ - private $resource_uuid = ''; + protected $resource_uuid = ''; /** * Output only. The time the operation was submitted to the server. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 5; */ - private $create_time = null; + protected $create_time = null; /** * Output only. The time when the operation terminated, regardless of its * success. This field is unset if the operation is still ongoing. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 6; */ - private $end_time = null; + protected $end_time = null; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/PollAirflowCommandRequest.php b/OrchestrationAirflow/src/V1/PollAirflowCommandRequest.php index 5b64612a08c1..e7ed7e645030 100644 --- a/OrchestrationAirflow/src/V1/PollAirflowCommandRequest.php +++ b/OrchestrationAirflow/src/V1/PollAirflowCommandRequest.php @@ -21,31 +21,31 @@ class PollAirflowCommandRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string environment = 1; */ - private $environment = ''; + protected $environment = ''; /** * The unique ID of the command execution. * * Generated from protobuf field string execution_id = 2; */ - private $execution_id = ''; + protected $execution_id = ''; /** * The name of the pod where the command is executed. * * Generated from protobuf field string pod = 3; */ - private $pod = ''; + protected $pod = ''; /** * The namespace of the pod where the command is executed. * * Generated from protobuf field string pod_namespace = 4; */ - private $pod_namespace = ''; + protected $pod_namespace = ''; /** * Line number from which new logs should be fetched. * * Generated from protobuf field int32 next_line_number = 5; */ - private $next_line_number = 0; + protected $next_line_number = 0; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/PollAirflowCommandResponse.php b/OrchestrationAirflow/src/V1/PollAirflowCommandResponse.php index 9f299615ecaf..b08a1b04456c 100644 --- a/OrchestrationAirflow/src/V1/PollAirflowCommandResponse.php +++ b/OrchestrationAirflow/src/V1/PollAirflowCommandResponse.php @@ -27,13 +27,13 @@ class PollAirflowCommandResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool output_end = 2; */ - private $output_end = false; + protected $output_end = false; /** * The result exit status of the command. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.PollAirflowCommandResponse.ExitInfo exit_info = 3; */ - private $exit_info = null; + protected $exit_info = null; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/PollAirflowCommandResponse/ExitInfo.php b/OrchestrationAirflow/src/V1/PollAirflowCommandResponse/ExitInfo.php index a744b573987b..cabad23bd3e3 100644 --- a/OrchestrationAirflow/src/V1/PollAirflowCommandResponse/ExitInfo.php +++ b/OrchestrationAirflow/src/V1/PollAirflowCommandResponse/ExitInfo.php @@ -20,13 +20,13 @@ class ExitInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 exit_code = 1; */ - private $exit_code = 0; + protected $exit_code = 0; /** * Error message. Empty if there was no error. * * Generated from protobuf field string error = 2; */ - private $error = ''; + protected $error = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/PollAirflowCommandResponse/Line.php b/OrchestrationAirflow/src/V1/PollAirflowCommandResponse/Line.php index 945c1041080f..2e5e3f3ef441 100644 --- a/OrchestrationAirflow/src/V1/PollAirflowCommandResponse/Line.php +++ b/OrchestrationAirflow/src/V1/PollAirflowCommandResponse/Line.php @@ -20,13 +20,13 @@ class Line extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 line_number = 1; */ - private $line_number = 0; + protected $line_number = 0; /** * Text content of the log line. * * Generated from protobuf field string content = 2; */ - private $content = ''; + protected $content = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/PrivateClusterConfig.php b/OrchestrationAirflow/src/V1/PrivateClusterConfig.php index 985c2daf47d0..0748584cbe17 100644 --- a/OrchestrationAirflow/src/V1/PrivateClusterConfig.php +++ b/OrchestrationAirflow/src/V1/PrivateClusterConfig.php @@ -22,14 +22,14 @@ class PrivateClusterConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_private_endpoint = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enable_private_endpoint = false; + protected $enable_private_endpoint = false; /** * Optional. The CIDR block from which IPv4 range for GKE master will be * reserved. If left blank, the default value of '172.16.0.0/23' is used. * * Generated from protobuf field string master_ipv4_cidr_block = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $master_ipv4_cidr_block = ''; + protected $master_ipv4_cidr_block = ''; /** * Output only. The IP range in CIDR notation to use for the hosted master * network. This range is used for assigning internal IP addresses to the GKE @@ -39,7 +39,7 @@ class PrivateClusterConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string master_ipv4_reserved_range = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $master_ipv4_reserved_range = ''; + protected $master_ipv4_reserved_range = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/PrivateEnvironmentConfig.php b/OrchestrationAirflow/src/V1/PrivateEnvironmentConfig.php index 464c4ba4f848..0ede8e0f8b6b 100644 --- a/OrchestrationAirflow/src/V1/PrivateEnvironmentConfig.php +++ b/OrchestrationAirflow/src/V1/PrivateEnvironmentConfig.php @@ -24,7 +24,7 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_private_environment = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enable_private_environment = false; + protected $enable_private_environment = false; /** * Optional. If `true`, builds performed during operations that install Python * packages have only private connectivity to Google services (including @@ -37,14 +37,14 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_private_builds_only = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enable_private_builds_only = false; + protected $enable_private_builds_only = false; /** * Optional. Configuration for the private GKE cluster for a Private IP * Cloud Composer environment. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.PrivateClusterConfig private_cluster_config = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $private_cluster_config = null; + protected $private_cluster_config = null; /** * Optional. The CIDR block from which IP range for web server will be * reserved. Needs to be disjoint from @@ -55,7 +55,7 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string web_server_ipv4_cidr_block = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $web_server_ipv4_cidr_block = ''; + protected $web_server_ipv4_cidr_block = ''; /** * Optional. The CIDR block from which IP range in tenant project will be * reserved for Cloud SQL. Needs to be disjoint from @@ -63,7 +63,7 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cloud_sql_ipv4_cidr_block = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cloud_sql_ipv4_cidr_block = ''; + protected $cloud_sql_ipv4_cidr_block = ''; /** * Output only. The IP range reserved for the tenant project's App Engine VMs. * This field is supported for Cloud Composer environments in versions @@ -71,7 +71,7 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string web_server_ipv4_reserved_range = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $web_server_ipv4_reserved_range = ''; + protected $web_server_ipv4_reserved_range = ''; /** * Optional. The CIDR block from which IP range for Cloud Composer Network in * tenant project will be reserved. Needs to be disjoint from @@ -82,7 +82,7 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cloud_composer_network_ipv4_cidr_block = 7 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cloud_composer_network_ipv4_cidr_block = ''; + protected $cloud_composer_network_ipv4_cidr_block = ''; /** * Output only. The IP range reserved for the tenant project's Cloud Composer * network. @@ -91,7 +91,7 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cloud_composer_network_ipv4_reserved_range = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $cloud_composer_network_ipv4_reserved_range = ''; + protected $cloud_composer_network_ipv4_reserved_range = ''; /** * Optional. When enabled, IPs from public (non-RFC1918) ranges can be used * for `IPAllocationPolicy.cluster_ipv4_cidr_block` and @@ -99,7 +99,7 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_privately_used_public_ips = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enable_privately_used_public_ips = false; + protected $enable_privately_used_public_ips = false; /** * Optional. When specified, the environment will use Private Service Connect * instead of VPC peerings to connect to Cloud SQL in the Tenant Project, @@ -108,14 +108,14 @@ class PrivateEnvironmentConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cloud_composer_connection_subnetwork = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cloud_composer_connection_subnetwork = ''; + protected $cloud_composer_connection_subnetwork = ''; /** * Optional. Configuration for the network connections configuration in the * environment. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.NetworkingConfig networking_config = 10 [(.google.api.field_behavior) = OPTIONAL]; */ - private $networking_config = null; + protected $networking_config = null; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/RecoveryConfig.php b/OrchestrationAirflow/src/V1/RecoveryConfig.php index d95ef8fe9fbc..28d0684e7aad 100644 --- a/OrchestrationAirflow/src/V1/RecoveryConfig.php +++ b/OrchestrationAirflow/src/V1/RecoveryConfig.php @@ -20,7 +20,7 @@ class RecoveryConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.ScheduledSnapshotsConfig scheduled_snapshots_config = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $scheduled_snapshots_config = null; + protected $scheduled_snapshots_config = null; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/SaveSnapshotRequest.php b/OrchestrationAirflow/src/V1/SaveSnapshotRequest.php index 6004586658b3..ceda45d81c94 100644 --- a/OrchestrationAirflow/src/V1/SaveSnapshotRequest.php +++ b/OrchestrationAirflow/src/V1/SaveSnapshotRequest.php @@ -21,14 +21,14 @@ class SaveSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string environment = 1; */ - private $environment = ''; + protected $environment = ''; /** * Location in a Cloud Storage where the snapshot is going to be stored, e.g.: * "gs://my-bucket/snapshots". * * Generated from protobuf field string snapshot_location = 2; */ - private $snapshot_location = ''; + protected $snapshot_location = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/SaveSnapshotResponse.php b/OrchestrationAirflow/src/V1/SaveSnapshotResponse.php index fbfd8745760f..769393e4eae8 100644 --- a/OrchestrationAirflow/src/V1/SaveSnapshotResponse.php +++ b/OrchestrationAirflow/src/V1/SaveSnapshotResponse.php @@ -23,7 +23,7 @@ class SaveSnapshotResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string snapshot_path = 1; */ - private $snapshot_path = ''; + protected $snapshot_path = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/ScheduledSnapshotsConfig.php b/OrchestrationAirflow/src/V1/ScheduledSnapshotsConfig.php index 027604992ceb..ee16abe92c52 100644 --- a/OrchestrationAirflow/src/V1/ScheduledSnapshotsConfig.php +++ b/OrchestrationAirflow/src/V1/ScheduledSnapshotsConfig.php @@ -20,14 +20,14 @@ class ScheduledSnapshotsConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enabled = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enabled = false; + protected $enabled = false; /** * Optional. The Cloud Storage location for storing automatically created * snapshots. * * Generated from protobuf field string snapshot_location = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $snapshot_location = ''; + protected $snapshot_location = ''; /** * Optional. The cron expression representing the time when snapshots creation * mechanism runs. This field is subject to additional validation around @@ -35,14 +35,14 @@ class ScheduledSnapshotsConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string snapshot_creation_schedule = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $snapshot_creation_schedule = ''; + protected $snapshot_creation_schedule = ''; /** * Optional. Time zone that sets the context to interpret * snapshot_creation_schedule. * * Generated from protobuf field string time_zone = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $time_zone = ''; + protected $time_zone = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/SoftwareConfig.php b/OrchestrationAirflow/src/V1/SoftwareConfig.php index 8592e5e13e23..dafc6d7948fd 100644 --- a/OrchestrationAirflow/src/V1/SoftwareConfig.php +++ b/OrchestrationAirflow/src/V1/SoftwareConfig.php @@ -34,12 +34,12 @@ class SoftwareConfig extends \Google\Protobuf\Internal\Message * version. * In all cases, the resolved image version is stored in the same field. * See also [version - * list](https://cloud.google.com/composer/docs/concepts/versioning/composer-versions) and [versioning - * overview](https://cloud.google.com/composer/docs/concepts/versioning/composer-versioning-overview). + * list](/composer/docs/concepts/versioning/composer-versions) and [versioning + * overview](/composer/docs/concepts/versioning/composer-versioning-overview). * * Generated from protobuf field string image_version = 1; */ - private $image_version = ''; + protected $image_version = ''; /** * Optional. Apache Airflow configuration properties to override. * Property keys contain the section and property names, separated by a @@ -52,7 +52,7 @@ class SoftwareConfig extends \Google\Protobuf\Internal\Message * [snake_case](https://en.wikipedia.org/wiki/Snake_case). Property values can * contain any character, and can be written in any lower/upper case format. * Certain Apache Airflow configuration property values are - * [blocked](https://cloud.google.com/composer/docs/concepts/airflow-configurations), + * [blocked](/composer/docs/concepts/airflow-configurations), * and cannot be overridden. * * Generated from protobuf field map airflow_config_overrides = 2; @@ -106,7 +106,7 @@ class SoftwareConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string python_version = 6; */ - private $python_version = ''; + protected $python_version = ''; /** * Optional. The number of schedulers for Airflow. * This field is supported for Cloud Composer environments in versions @@ -114,13 +114,13 @@ class SoftwareConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 scheduler_count = 7 [(.google.api.field_behavior) = OPTIONAL]; */ - private $scheduler_count = 0; + protected $scheduler_count = 0; /** * Optional. The configuration for Cloud Data Lineage integration. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.CloudDataLineageIntegration cloud_data_lineage_integration = 8 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cloud_data_lineage_integration = null; + protected $cloud_data_lineage_integration = null; /** * Optional. Whether or not the web server uses custom plugins. * If unspecified, the field defaults to `PLUGINS_ENABLED`. @@ -129,7 +129,7 @@ class SoftwareConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.SoftwareConfig.WebServerPluginsMode web_server_plugins_mode = 10 [(.google.api.field_behavior) = OPTIONAL]; */ - private $web_server_plugins_mode = 0; + protected $web_server_plugins_mode = 0; /** * Constructor. @@ -156,8 +156,8 @@ class SoftwareConfig extends \Google\Protobuf\Internal\Message * version. * In all cases, the resolved image version is stored in the same field. * See also [version - * list](https://cloud.google.com/composer/docs/concepts/versioning/composer-versions) and [versioning - * overview](https://cloud.google.com/composer/docs/concepts/versioning/composer-versioning-overview). + * list](/composer/docs/concepts/versioning/composer-versions) and [versioning + * overview](/composer/docs/concepts/versioning/composer-versioning-overview). * @type array|\Google\Protobuf\Internal\MapField $airflow_config_overrides * Optional. Apache Airflow configuration properties to override. * Property keys contain the section and property names, separated by a @@ -170,7 +170,7 @@ class SoftwareConfig extends \Google\Protobuf\Internal\Message * [snake_case](https://en.wikipedia.org/wiki/Snake_case). Property values can * contain any character, and can be written in any lower/upper case format. * Certain Apache Airflow configuration property values are - * [blocked](https://cloud.google.com/composer/docs/concepts/airflow-configurations), + * [blocked](/composer/docs/concepts/airflow-configurations), * and cannot be overridden. * @type array|\Google\Protobuf\Internal\MapField $pypi_packages * Optional. Custom Python Package Index (PyPI) packages to be installed in @@ -246,8 +246,8 @@ public function __construct($data = NULL) { * version. * In all cases, the resolved image version is stored in the same field. * See also [version - * list](https://cloud.google.com/composer/docs/concepts/versioning/composer-versions) and [versioning - * overview](https://cloud.google.com/composer/docs/concepts/versioning/composer-versioning-overview). + * list](/composer/docs/concepts/versioning/composer-versions) and [versioning + * overview](/composer/docs/concepts/versioning/composer-versioning-overview). * * Generated from protobuf field string image_version = 1; * @return string @@ -276,8 +276,8 @@ public function getImageVersion() * version. * In all cases, the resolved image version is stored in the same field. * See also [version - * list](https://cloud.google.com/composer/docs/concepts/versioning/composer-versions) and [versioning - * overview](https://cloud.google.com/composer/docs/concepts/versioning/composer-versioning-overview). + * list](/composer/docs/concepts/versioning/composer-versions) and [versioning + * overview](/composer/docs/concepts/versioning/composer-versioning-overview). * * Generated from protobuf field string image_version = 1; * @param string $var @@ -303,7 +303,7 @@ public function setImageVersion($var) * [snake_case](https://en.wikipedia.org/wiki/Snake_case). Property values can * contain any character, and can be written in any lower/upper case format. * Certain Apache Airflow configuration property values are - * [blocked](https://cloud.google.com/composer/docs/concepts/airflow-configurations), + * [blocked](/composer/docs/concepts/airflow-configurations), * and cannot be overridden. * * Generated from protobuf field map airflow_config_overrides = 2; @@ -326,7 +326,7 @@ public function getAirflowConfigOverrides() * [snake_case](https://en.wikipedia.org/wiki/Snake_case). Property values can * contain any character, and can be written in any lower/upper case format. * Certain Apache Airflow configuration property values are - * [blocked](https://cloud.google.com/composer/docs/concepts/airflow-configurations), + * [blocked](/composer/docs/concepts/airflow-configurations), * and cannot be overridden. * * Generated from protobuf field map airflow_config_overrides = 2; diff --git a/OrchestrationAirflow/src/V1/StopAirflowCommandRequest.php b/OrchestrationAirflow/src/V1/StopAirflowCommandRequest.php index 2a008a268c34..01cc5c8be841 100644 --- a/OrchestrationAirflow/src/V1/StopAirflowCommandRequest.php +++ b/OrchestrationAirflow/src/V1/StopAirflowCommandRequest.php @@ -21,32 +21,32 @@ class StopAirflowCommandRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string environment = 1; */ - private $environment = ''; + protected $environment = ''; /** * The unique ID of the command execution. * * Generated from protobuf field string execution_id = 2; */ - private $execution_id = ''; + protected $execution_id = ''; /** * The name of the pod where the command is executed. * * Generated from protobuf field string pod = 3; */ - private $pod = ''; + protected $pod = ''; /** * The namespace of the pod where the command is executed. * * Generated from protobuf field string pod_namespace = 4; */ - private $pod_namespace = ''; + protected $pod_namespace = ''; /** * If true, the execution is terminated forcefully (SIGKILL). If false, the * execution is stopped gracefully, giving it time for cleanup. * * Generated from protobuf field bool force = 5; */ - private $force = false; + protected $force = false; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/StopAirflowCommandResponse.php b/OrchestrationAirflow/src/V1/StopAirflowCommandResponse.php index d48587bc5141..89e52c6e0492 100644 --- a/OrchestrationAirflow/src/V1/StopAirflowCommandResponse.php +++ b/OrchestrationAirflow/src/V1/StopAirflowCommandResponse.php @@ -20,7 +20,7 @@ class StopAirflowCommandResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool is_done = 1; */ - private $is_done = false; + protected $is_done = false; /** * Output message from stopping execution request. * diff --git a/OrchestrationAirflow/src/V1/StorageConfig.php b/OrchestrationAirflow/src/V1/StorageConfig.php index 35a8de9070ad..20976333720f 100644 --- a/OrchestrationAirflow/src/V1/StorageConfig.php +++ b/OrchestrationAirflow/src/V1/StorageConfig.php @@ -21,7 +21,7 @@ class StorageConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string bucket = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $bucket = ''; + protected $bucket = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/TaskLogsRetentionConfig.php b/OrchestrationAirflow/src/V1/TaskLogsRetentionConfig.php index 8143ae796adb..4634b2b367e3 100644 --- a/OrchestrationAirflow/src/V1/TaskLogsRetentionConfig.php +++ b/OrchestrationAirflow/src/V1/TaskLogsRetentionConfig.php @@ -21,7 +21,7 @@ class TaskLogsRetentionConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.TaskLogsRetentionConfig.TaskLogsStorageMode storage_mode = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $storage_mode = 0; + protected $storage_mode = 0; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/UpdateEnvironmentRequest.php b/OrchestrationAirflow/src/V1/UpdateEnvironmentRequest.php index 5844344b5498..5dc8e78f5eef 100644 --- a/OrchestrationAirflow/src/V1/UpdateEnvironmentRequest.php +++ b/OrchestrationAirflow/src/V1/UpdateEnvironmentRequest.php @@ -21,14 +21,14 @@ class UpdateEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 2; */ - private $name = ''; + protected $name = ''; /** * A patch environment. Fields specified by the `updateMask` will be copied * from the patch environment into the environment under update. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.Environment environment = 1; */ - private $environment = null; + protected $environment = null; /** * Required. A comma-separated list of paths, relative to `Environment`, of * fields to update. @@ -147,7 +147,7 @@ class UpdateEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; */ - private $update_mask = null; + protected $update_mask = null; /** * @param string $name The relative resource name of the environment to update, in the form: diff --git a/OrchestrationAirflow/src/V1/UpdateUserWorkloadsConfigMapRequest.php b/OrchestrationAirflow/src/V1/UpdateUserWorkloadsConfigMapRequest.php index c7f03fb8e194..7da8153668e4 100644 --- a/OrchestrationAirflow/src/V1/UpdateUserWorkloadsConfigMapRequest.php +++ b/OrchestrationAirflow/src/V1/UpdateUserWorkloadsConfigMapRequest.php @@ -20,7 +20,7 @@ class UpdateUserWorkloadsConfigMapRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.UserWorkloadsConfigMap user_workloads_config_map = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $user_workloads_config_map = null; + protected $user_workloads_config_map = null; /** * @param \Google\Cloud\Orchestration\Airflow\Service\V1\UserWorkloadsConfigMap $userWorkloadsConfigMap Optional. User workloads ConfigMap to override. diff --git a/OrchestrationAirflow/src/V1/UpdateUserWorkloadsSecretRequest.php b/OrchestrationAirflow/src/V1/UpdateUserWorkloadsSecretRequest.php index b7b1a2e84b0e..66845f93f36b 100644 --- a/OrchestrationAirflow/src/V1/UpdateUserWorkloadsSecretRequest.php +++ b/OrchestrationAirflow/src/V1/UpdateUserWorkloadsSecretRequest.php @@ -20,7 +20,7 @@ class UpdateUserWorkloadsSecretRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.UserWorkloadsSecret user_workloads_secret = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $user_workloads_secret = null; + protected $user_workloads_secret = null; /** * @param \Google\Cloud\Orchestration\Airflow\Service\V1\UserWorkloadsSecret $userWorkloadsSecret Optional. User workloads Secret to override. diff --git a/OrchestrationAirflow/src/V1/UserWorkloadsConfigMap.php b/OrchestrationAirflow/src/V1/UserWorkloadsConfigMap.php index 9ce5e48e8776..4ac23f69958d 100644 --- a/OrchestrationAirflow/src/V1/UserWorkloadsConfigMap.php +++ b/OrchestrationAirflow/src/V1/UserWorkloadsConfigMap.php @@ -22,7 +22,7 @@ class UserWorkloadsConfigMap extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; */ - private $name = ''; + protected $name = ''; /** * Optional. The "data" field of Kubernetes ConfigMap, organized in key-value * pairs. For details see: diff --git a/OrchestrationAirflow/src/V1/UserWorkloadsSecret.php b/OrchestrationAirflow/src/V1/UserWorkloadsSecret.php index 6e653ea55776..a7c04b703a33 100644 --- a/OrchestrationAirflow/src/V1/UserWorkloadsSecret.php +++ b/OrchestrationAirflow/src/V1/UserWorkloadsSecret.php @@ -22,7 +22,7 @@ class UserWorkloadsSecret extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; */ - private $name = ''; + protected $name = ''; /** * Optional. The "data" field of Kubernetes Secret, organized in key-value * pairs, which can contain sensitive values such as a password, a token, or a diff --git a/OrchestrationAirflow/src/V1/WebServerConfig.php b/OrchestrationAirflow/src/V1/WebServerConfig.php index 99fa2ba89426..8b4cdd4debb2 100644 --- a/OrchestrationAirflow/src/V1/WebServerConfig.php +++ b/OrchestrationAirflow/src/V1/WebServerConfig.php @@ -27,7 +27,7 @@ class WebServerConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string machine_type = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $machine_type = ''; + protected $machine_type = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/WebServerNetworkAccessControl/AllowedIpRange.php b/OrchestrationAirflow/src/V1/WebServerNetworkAccessControl/AllowedIpRange.php index cea9b88f4cef..d350c536129b 100644 --- a/OrchestrationAirflow/src/V1/WebServerNetworkAccessControl/AllowedIpRange.php +++ b/OrchestrationAirflow/src/V1/WebServerNetworkAccessControl/AllowedIpRange.php @@ -26,14 +26,14 @@ class AllowedIpRange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string value = 1; */ - private $value = ''; + protected $value = ''; /** * Optional. User-provided description. It must contain at most 300 * characters. * * Generated from protobuf field string description = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $description = ''; + protected $description = ''; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/WorkloadsConfig.php b/OrchestrationAirflow/src/V1/WorkloadsConfig.php index 12c924ee3865..e12719b0b73b 100644 --- a/OrchestrationAirflow/src/V1/WorkloadsConfig.php +++ b/OrchestrationAirflow/src/V1/WorkloadsConfig.php @@ -22,25 +22,25 @@ class WorkloadsConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.WorkloadsConfig.SchedulerResource scheduler = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $scheduler = null; + protected $scheduler = null; /** * Optional. Resources used by Airflow web server. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.WorkloadsConfig.WebServerResource web_server = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $web_server = null; + protected $web_server = null; /** * Optional. Resources used by Airflow workers. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.WorkloadsConfig.WorkerResource worker = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $worker = null; + protected $worker = null; /** * Optional. Resources used by Airflow triggerers. * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.WorkloadsConfig.TriggererResource triggerer = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $triggerer = null; + protected $triggerer = null; /** * Optional. Resources used by Airflow DAG processors. * This field is supported for Cloud Composer environments in versions @@ -48,7 +48,7 @@ class WorkloadsConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.orchestration.airflow.service.v1.WorkloadsConfig.DagProcessorResource dag_processor = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $dag_processor = null; + protected $dag_processor = null; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/WorkloadsConfig/DagProcessorResource.php b/OrchestrationAirflow/src/V1/WorkloadsConfig/DagProcessorResource.php index 431d90b19517..59c69886f8c1 100644 --- a/OrchestrationAirflow/src/V1/WorkloadsConfig/DagProcessorResource.php +++ b/OrchestrationAirflow/src/V1/WorkloadsConfig/DagProcessorResource.php @@ -21,28 +21,28 @@ class DagProcessorResource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float cpu = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cpu = 0.0; + protected $cpu = 0.0; /** * Optional. Memory (GB) request and limit for a single Airflow DAG * processor replica. * * Generated from protobuf field float memory_gb = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $memory_gb = 0.0; + protected $memory_gb = 0.0; /** * Optional. Storage (GB) request and limit for a single Airflow DAG * processor replica. * * Generated from protobuf field float storage_gb = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $storage_gb = 0.0; + protected $storage_gb = 0.0; /** * Optional. The number of DAG processors. If not provided or set to 0, a * single DAG processor instance will be created. * * Generated from protobuf field int32 count = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $count = 0; + protected $count = 0; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/WorkloadsConfig/SchedulerResource.php b/OrchestrationAirflow/src/V1/WorkloadsConfig/SchedulerResource.php index fc4a3bd1f7d3..bdb79e2760eb 100644 --- a/OrchestrationAirflow/src/V1/WorkloadsConfig/SchedulerResource.php +++ b/OrchestrationAirflow/src/V1/WorkloadsConfig/SchedulerResource.php @@ -20,27 +20,27 @@ class SchedulerResource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float cpu = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cpu = 0.0; + protected $cpu = 0.0; /** * Optional. Memory (GB) request and limit for a single Airflow scheduler * replica. * * Generated from protobuf field float memory_gb = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $memory_gb = 0.0; + protected $memory_gb = 0.0; /** * Optional. Storage (GB) request and limit for a single Airflow scheduler * replica. * * Generated from protobuf field float storage_gb = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $storage_gb = 0.0; + protected $storage_gb = 0.0; /** * Optional. The number of schedulers. * * Generated from protobuf field int32 count = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $count = 0; + protected $count = 0; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/WorkloadsConfig/TriggererResource.php b/OrchestrationAirflow/src/V1/WorkloadsConfig/TriggererResource.php index e11eec952eb3..3e22ad154a83 100644 --- a/OrchestrationAirflow/src/V1/WorkloadsConfig/TriggererResource.php +++ b/OrchestrationAirflow/src/V1/WorkloadsConfig/TriggererResource.php @@ -20,20 +20,20 @@ class TriggererResource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 count = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $count = 0; + protected $count = 0; /** * Optional. CPU request and limit for a single Airflow triggerer replica. * * Generated from protobuf field float cpu = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cpu = 0.0; + protected $cpu = 0.0; /** * Optional. Memory (GB) request and limit for a single Airflow triggerer * replica. * * Generated from protobuf field float memory_gb = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $memory_gb = 0.0; + protected $memory_gb = 0.0; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/WorkloadsConfig/WebServerResource.php b/OrchestrationAirflow/src/V1/WorkloadsConfig/WebServerResource.php index 1a6e09028ef1..ca8d2ec732c8 100644 --- a/OrchestrationAirflow/src/V1/WorkloadsConfig/WebServerResource.php +++ b/OrchestrationAirflow/src/V1/WorkloadsConfig/WebServerResource.php @@ -20,19 +20,19 @@ class WebServerResource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float cpu = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cpu = 0.0; + protected $cpu = 0.0; /** * Optional. Memory (GB) request and limit for Airflow web server. * * Generated from protobuf field float memory_gb = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $memory_gb = 0.0; + protected $memory_gb = 0.0; /** * Optional. Storage (GB) request and limit for Airflow web server. * * Generated from protobuf field float storage_gb = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $storage_gb = 0.0; + protected $storage_gb = 0.0; /** * Constructor. diff --git a/OrchestrationAirflow/src/V1/WorkloadsConfig/WorkerResource.php b/OrchestrationAirflow/src/V1/WorkloadsConfig/WorkerResource.php index 73877cbbfd79..58d909a6cb4f 100644 --- a/OrchestrationAirflow/src/V1/WorkloadsConfig/WorkerResource.php +++ b/OrchestrationAirflow/src/V1/WorkloadsConfig/WorkerResource.php @@ -20,33 +20,33 @@ class WorkerResource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float cpu = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $cpu = 0.0; + protected $cpu = 0.0; /** * Optional. Memory (GB) request and limit for a single Airflow worker * replica. * * Generated from protobuf field float memory_gb = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $memory_gb = 0.0; + protected $memory_gb = 0.0; /** * Optional. Storage (GB) request and limit for a single Airflow worker * replica. * * Generated from protobuf field float storage_gb = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $storage_gb = 0.0; + protected $storage_gb = 0.0; /** * Optional. Minimum number of workers for autoscaling. * * Generated from protobuf field int32 min_count = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $min_count = 0; + protected $min_count = 0; /** * Optional. Maximum number of workers for autoscaling. * * Generated from protobuf field int32 max_count = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $max_count = 0; + protected $max_count = 0; /** * Constructor. diff --git a/OrchestrationAirflow/tests/Unit/V1/Client/EnvironmentsClientTest.php b/OrchestrationAirflow/tests/Unit/V1/Client/EnvironmentsClientTest.php index 09335c59c952..7314afa0b610 100644 --- a/OrchestrationAirflow/tests/Unit/V1/Client/EnvironmentsClientTest.php +++ b/OrchestrationAirflow/tests/Unit/V1/Client/EnvironmentsClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return EnvironmentsClient */ @@ -146,7 +148,10 @@ public function createEnvironmentTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/CreateEnvironment', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/CreateEnvironment', + $actualApiFuncCall + ); $expectedOperationsRequestObject = new GetOperationRequest(); $expectedOperationsRequestObject->setName('operations/createEnvironmentTest'); $response->pollUntilComplete([ @@ -190,12 +195,15 @@ public function createEnvironmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new CreateEnvironmentRequest(); $response = $gapicClient->createEnvironment($request); @@ -245,7 +253,10 @@ public function createUserWorkloadsConfigMapTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsConfigMap', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsConfigMap', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getUserWorkloadsConfigMap(); @@ -264,12 +275,15 @@ public function createUserWorkloadsConfigMapExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); @@ -315,7 +329,10 @@ public function createUserWorkloadsSecretTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsSecret', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsSecret', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getUserWorkloadsSecret(); @@ -334,12 +351,15 @@ public function createUserWorkloadsSecretExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); @@ -399,7 +419,10 @@ public function databaseFailoverTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/DatabaseFailover', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/DatabaseFailover', + $actualApiFuncCall + ); $expectedOperationsRequestObject = new GetOperationRequest(); $expectedOperationsRequestObject->setName('operations/databaseFailoverTest'); $response->pollUntilComplete([ @@ -443,12 +466,15 @@ public function databaseFailoverExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new DatabaseFailoverRequest(); $response = $gapicClient->databaseFailover($request); @@ -512,7 +538,10 @@ public function deleteEnvironmentTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/DeleteEnvironment', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/DeleteEnvironment', + $actualApiFuncCall + ); $expectedOperationsRequestObject = new GetOperationRequest(); $expectedOperationsRequestObject->setName('operations/deleteEnvironmentTest'); $response->pollUntilComplete([ @@ -556,12 +585,15 @@ public function deleteEnvironmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new DeleteEnvironmentRequest(); $response = $gapicClient->deleteEnvironment($request); @@ -598,15 +630,22 @@ public function deleteUserWorkloadsConfigMapTest() $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - $request = (new DeleteUserWorkloadsConfigMapRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->userWorkloadsConfigMapName( + '[PROJECT]', + '[LOCATION]', + '[ENVIRONMENT]', + '[USER_WORKLOADS_CONFIG_MAP]' + ); + $request = (new DeleteUserWorkloadsConfigMapRequest())->setName($formattedName); $gapicClient->deleteUserWorkloadsConfigMap($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsConfigMap', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsConfigMap', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -623,17 +662,24 @@ public function deleteUserWorkloadsConfigMapExceptionTest() $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); + $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->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - $request = (new DeleteUserWorkloadsConfigMapRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->userWorkloadsConfigMapName( + '[PROJECT]', + '[LOCATION]', + '[ENVIRONMENT]', + '[USER_WORKLOADS_CONFIG_MAP]' + ); + $request = (new DeleteUserWorkloadsConfigMapRequest())->setName($formattedName); try { $gapicClient->deleteUserWorkloadsConfigMap($request); // If the $gapicClient method call did not throw, fail the test @@ -659,15 +705,22 @@ public function deleteUserWorkloadsSecretTest() $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - $request = (new DeleteUserWorkloadsSecretRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->userWorkloadsSecretName( + '[PROJECT]', + '[LOCATION]', + '[ENVIRONMENT]', + '[USER_WORKLOADS_SECRET]' + ); + $request = (new DeleteUserWorkloadsSecretRequest())->setName($formattedName); $gapicClient->deleteUserWorkloadsSecret($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsSecret', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsSecret', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -684,17 +737,24 @@ public function deleteUserWorkloadsSecretExceptionTest() $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); + $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->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - $request = (new DeleteUserWorkloadsSecretRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->userWorkloadsSecretName( + '[PROJECT]', + '[LOCATION]', + '[ENVIRONMENT]', + '[USER_WORKLOADS_SECRET]' + ); + $request = (new DeleteUserWorkloadsSecretRequest())->setName($formattedName); try { $gapicClient->deleteUserWorkloadsSecret($request); // If the $gapicClient method call did not throw, fail the test @@ -734,7 +794,10 @@ public function executeAirflowCommandTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ExecuteAirflowCommand', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/ExecuteAirflowCommand', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -749,12 +812,15 @@ public function executeAirflowCommandExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ExecuteAirflowCommandRequest(); try { @@ -789,15 +855,17 @@ public function fetchDatabasePropertiesTest() $transport->addResponse($expectedResponse); // Mock request $formattedEnvironment = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $request = (new FetchDatabasePropertiesRequest()) - ->setEnvironment($formattedEnvironment); + $request = (new FetchDatabasePropertiesRequest())->setEnvironment($formattedEnvironment); $response = $gapicClient->fetchDatabaseProperties($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.orchestration.airflow.service.v1.Environments/FetchDatabaseProperties', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/FetchDatabaseProperties', + $actualFuncCall + ); $actualValue = $actualRequestObject->getEnvironment(); $this->assertProtobufEquals($formattedEnvironment, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -814,17 +882,19 @@ public function fetchDatabasePropertiesExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedEnvironment = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $request = (new FetchDatabasePropertiesRequest()) - ->setEnvironment($formattedEnvironment); + $request = (new FetchDatabasePropertiesRequest())->setEnvironment($formattedEnvironment); try { $gapicClient->fetchDatabaseProperties($request); // If the $gapicClient method call did not throw, fail the test @@ -862,7 +932,10 @@ public function getEnvironmentTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/GetEnvironment', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/GetEnvironment', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -877,12 +950,15 @@ public function getEnvironmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetEnvironmentRequest(); try { @@ -912,16 +988,23 @@ public function getUserWorkloadsConfigMapTest() $expectedResponse->setName($name2); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - $request = (new GetUserWorkloadsConfigMapRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->userWorkloadsConfigMapName( + '[PROJECT]', + '[LOCATION]', + '[ENVIRONMENT]', + '[USER_WORKLOADS_CONFIG_MAP]' + ); + $request = (new GetUserWorkloadsConfigMapRequest())->setName($formattedName); $response = $gapicClient->getUserWorkloadsConfigMap($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.orchestration.airflow.service.v1.Environments/GetUserWorkloadsConfigMap', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/GetUserWorkloadsConfigMap', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -938,17 +1021,24 @@ public function getUserWorkloadsConfigMapExceptionTest() $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); + $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->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - $request = (new GetUserWorkloadsConfigMapRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->userWorkloadsConfigMapName( + '[PROJECT]', + '[LOCATION]', + '[ENVIRONMENT]', + '[USER_WORKLOADS_CONFIG_MAP]' + ); + $request = (new GetUserWorkloadsConfigMapRequest())->setName($formattedName); try { $gapicClient->getUserWorkloadsConfigMap($request); // If the $gapicClient method call did not throw, fail the test @@ -976,16 +1066,23 @@ public function getUserWorkloadsSecretTest() $expectedResponse->setName($name2); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - $request = (new GetUserWorkloadsSecretRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->userWorkloadsSecretName( + '[PROJECT]', + '[LOCATION]', + '[ENVIRONMENT]', + '[USER_WORKLOADS_SECRET]' + ); + $request = (new GetUserWorkloadsSecretRequest())->setName($formattedName); $response = $gapicClient->getUserWorkloadsSecret($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.orchestration.airflow.service.v1.Environments/GetUserWorkloadsSecret', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/GetUserWorkloadsSecret', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1002,17 +1099,24 @@ public function getUserWorkloadsSecretExceptionTest() $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); + $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->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - $request = (new GetUserWorkloadsSecretRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->userWorkloadsSecretName( + '[PROJECT]', + '[LOCATION]', + '[ENVIRONMENT]', + '[USER_WORKLOADS_SECRET]' + ); + $request = (new GetUserWorkloadsSecretRequest())->setName($formattedName); try { $gapicClient->getUserWorkloadsSecret($request); // If the $gapicClient method call did not throw, fail the test @@ -1037,9 +1141,7 @@ public function listEnvironmentsTest() // Mock response $nextPageToken = ''; $environmentsElement = new Environment(); - $environments = [ - $environmentsElement, - ]; + $environments = [$environmentsElement]; $expectedResponse = new ListEnvironmentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setEnvironments($environments); @@ -1054,7 +1156,10 @@ public function listEnvironmentsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ListEnvironments', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/ListEnvironments', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -1069,12 +1174,15 @@ public function listEnvironmentsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListEnvironmentsRequest(); try { @@ -1101,17 +1209,14 @@ public function listUserWorkloadsConfigMapsTest() // Mock response $nextPageToken = ''; $userWorkloadsConfigMapsElement = new UserWorkloadsConfigMap(); - $userWorkloadsConfigMaps = [ - $userWorkloadsConfigMapsElement, - ]; + $userWorkloadsConfigMaps = [$userWorkloadsConfigMapsElement]; $expectedResponse = new ListUserWorkloadsConfigMapsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setUserWorkloadsConfigMaps($userWorkloadsConfigMaps); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $request = (new ListUserWorkloadsConfigMapsRequest()) - ->setParent($formattedParent); + $request = (new ListUserWorkloadsConfigMapsRequest())->setParent($formattedParent); $response = $gapicClient->listUserWorkloadsConfigMaps($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1121,7 +1226,10 @@ public function listUserWorkloadsConfigMapsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsConfigMaps', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsConfigMaps', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1138,17 +1246,19 @@ public function listUserWorkloadsConfigMapsExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $request = (new ListUserWorkloadsConfigMapsRequest()) - ->setParent($formattedParent); + $request = (new ListUserWorkloadsConfigMapsRequest())->setParent($formattedParent); try { $gapicClient->listUserWorkloadsConfigMaps($request); // If the $gapicClient method call did not throw, fail the test @@ -1173,17 +1283,14 @@ public function listUserWorkloadsSecretsTest() // Mock response $nextPageToken = ''; $userWorkloadsSecretsElement = new UserWorkloadsSecret(); - $userWorkloadsSecrets = [ - $userWorkloadsSecretsElement, - ]; + $userWorkloadsSecrets = [$userWorkloadsSecretsElement]; $expectedResponse = new ListUserWorkloadsSecretsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setUserWorkloadsSecrets($userWorkloadsSecrets); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $request = (new ListUserWorkloadsSecretsRequest()) - ->setParent($formattedParent); + $request = (new ListUserWorkloadsSecretsRequest())->setParent($formattedParent); $response = $gapicClient->listUserWorkloadsSecrets($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1193,7 +1300,10 @@ public function listUserWorkloadsSecretsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsSecrets', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsSecrets', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1210,17 +1320,19 @@ public function listUserWorkloadsSecretsExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $request = (new ListUserWorkloadsSecretsRequest()) - ->setParent($formattedParent); + $request = (new ListUserWorkloadsSecretsRequest())->setParent($formattedParent); try { $gapicClient->listUserWorkloadsSecrets($request); // If the $gapicClient method call did not throw, fail the test @@ -1245,17 +1357,14 @@ public function listWorkloadsTest() // Mock response $nextPageToken = ''; $workloadsElement = new ComposerWorkload(); - $workloads = [ - $workloadsElement, - ]; + $workloads = [$workloadsElement]; $expectedResponse = new ListWorkloadsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setWorkloads($workloads); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $request = (new ListWorkloadsRequest()) - ->setParent($formattedParent); + $request = (new ListWorkloadsRequest())->setParent($formattedParent); $response = $gapicClient->listWorkloads($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1282,17 +1391,19 @@ public function listWorkloadsExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $request = (new ListWorkloadsRequest()) - ->setParent($formattedParent); + $request = (new ListWorkloadsRequest())->setParent($formattedParent); try { $gapicClient->listWorkloads($request); // If the $gapicClient method call did not throw, fail the test @@ -1345,7 +1456,10 @@ public function loadSnapshotTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/LoadSnapshot', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/LoadSnapshot', + $actualApiFuncCall + ); $expectedOperationsRequestObject = new GetOperationRequest(); $expectedOperationsRequestObject->setName('operations/loadSnapshotTest'); $response->pollUntilComplete([ @@ -1389,12 +1503,15 @@ public function loadSnapshotExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new LoadSnapshotRequest(); $response = $gapicClient->loadSnapshot($request); @@ -1439,7 +1556,10 @@ public function pollAirflowCommandTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/PollAirflowCommand', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/PollAirflowCommand', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -1454,12 +1574,15 @@ public function pollAirflowCommandExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new PollAirflowCommandRequest(); try { @@ -1516,7 +1639,10 @@ public function saveSnapshotTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/SaveSnapshot', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/SaveSnapshot', + $actualApiFuncCall + ); $expectedOperationsRequestObject = new GetOperationRequest(); $expectedOperationsRequestObject->setName('operations/saveSnapshotTest'); $response->pollUntilComplete([ @@ -1560,12 +1686,15 @@ public function saveSnapshotExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new SaveSnapshotRequest(); $response = $gapicClient->saveSnapshot($request); @@ -1610,7 +1739,10 @@ public function stopAirflowCommandTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/StopAirflowCommand', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/StopAirflowCommand', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -1625,12 +1757,15 @@ public function stopAirflowCommandExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new StopAirflowCommandRequest(); try { @@ -1691,7 +1826,10 @@ public function updateEnvironmentTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/UpdateEnvironment', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/UpdateEnvironment', + $actualApiFuncCall + ); $expectedOperationsRequestObject = new GetOperationRequest(); $expectedOperationsRequestObject->setName('operations/updateEnvironmentTest'); $response->pollUntilComplete([ @@ -1735,12 +1873,15 @@ public function updateEnvironmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new UpdateEnvironmentRequest(); $response = $gapicClient->updateEnvironment($request); @@ -1785,7 +1926,10 @@ public function updateUserWorkloadsConfigMapTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsConfigMap', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsConfigMap', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -1800,12 +1944,15 @@ public function updateUserWorkloadsConfigMapExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdateUserWorkloadsConfigMapRequest(); try { @@ -1841,7 +1988,10 @@ public function updateUserWorkloadsSecretTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsSecret', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsSecret', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -1856,12 +2006,15 @@ public function updateUserWorkloadsSecretExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new UpdateUserWorkloadsSecretRequest(); try { @@ -1922,7 +2075,10 @@ public function createEnvironmentAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/CreateEnvironment', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.Environments/CreateEnvironment', + $actualApiFuncCall + ); $expectedOperationsRequestObject = new GetOperationRequest(); $expectedOperationsRequestObject->setName('operations/createEnvironmentTest'); $response->pollUntilComplete([ diff --git a/OrchestrationAirflow/tests/Unit/V1/Client/ImageVersionsClientTest.php b/OrchestrationAirflow/tests/Unit/V1/Client/ImageVersionsClientTest.php index 5206ca9a2aee..004f85045789 100644 --- a/OrchestrationAirflow/tests/Unit/V1/Client/ImageVersionsClientTest.php +++ b/OrchestrationAirflow/tests/Unit/V1/Client/ImageVersionsClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ImageVersionsClient */ @@ -72,9 +74,7 @@ public function listImageVersionsTest() // Mock response $nextPageToken = ''; $imageVersionsElement = new ImageVersion(); - $imageVersions = [ - $imageVersionsElement, - ]; + $imageVersions = [$imageVersionsElement]; $expectedResponse = new ListImageVersionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setImageVersions($imageVersions); @@ -89,7 +89,10 @@ public function listImageVersionsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.ImageVersions/ListImageVersions', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.ImageVersions/ListImageVersions', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } @@ -104,12 +107,15 @@ public function listImageVersionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListImageVersionsRequest(); try { @@ -136,9 +142,7 @@ public function listImageVersionsAsyncTest() // Mock response $nextPageToken = ''; $imageVersionsElement = new ImageVersion(); - $imageVersions = [ - $imageVersionsElement, - ]; + $imageVersions = [$imageVersionsElement]; $expectedResponse = new ListImageVersionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setImageVersions($imageVersions); @@ -153,7 +157,10 @@ public function listImageVersionsAsyncTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.ImageVersions/ListImageVersions', $actualFuncCall); + $this->assertSame( + '/google.cloud.orchestration.airflow.service.v1.ImageVersions/ListImageVersions', + $actualFuncCall + ); $this->assertTrue($transport->isExhausted()); } } diff --git a/OrchestrationAirflow/tests/Unit/V1/EnvironmentsClientTest.php b/OrchestrationAirflow/tests/Unit/V1/EnvironmentsClientTest.php deleted file mode 100644 index 476098e1b102..000000000000 --- a/OrchestrationAirflow/tests/Unit/V1/EnvironmentsClientTest.php +++ /dev/null @@ -1,1786 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return EnvironmentsClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new EnvironmentsClient($options); - } - - /** @test */ - public function createEnvironmentTest() - { - $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/createEnvironmentTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $uuid = 'uuid3601339'; - $satisfiesPzs = false; - $expectedResponse = new Environment(); - $expectedResponse->setName($name); - $expectedResponse->setUuid($uuid); - $expectedResponse->setSatisfiesPzs($satisfiesPzs); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createEnvironmentTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->createEnvironment(); - $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.orchestration.airflow.service.v1.Environments/CreateEnvironment', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createEnvironmentTest'); - $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 createEnvironmentExceptionTest() - { - $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/createEnvironmentTest'); - $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); - $response = $gapicClient->createEnvironment(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createEnvironmentTest'); - 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 createUserWorkloadsConfigMapTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $expectedResponse = new UserWorkloadsConfigMap(); - $expectedResponse->setName($name); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $userWorkloadsConfigMap = new UserWorkloadsConfigMap(); - $response = $gapicClient->createUserWorkloadsConfigMap($formattedParent, $userWorkloadsConfigMap); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsConfigMap', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getUserWorkloadsConfigMap(); - $this->assertProtobufEquals($userWorkloadsConfigMap, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createUserWorkloadsConfigMapExceptionTest() - { - $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $userWorkloadsConfigMap = new UserWorkloadsConfigMap(); - try { - $gapicClient->createUserWorkloadsConfigMap($formattedParent, $userWorkloadsConfigMap); - // 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 createUserWorkloadsSecretTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $expectedResponse = new UserWorkloadsSecret(); - $expectedResponse->setName($name); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $userWorkloadsSecret = new UserWorkloadsSecret(); - $response = $gapicClient->createUserWorkloadsSecret($formattedParent, $userWorkloadsSecret); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsSecret', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getUserWorkloadsSecret(); - $this->assertProtobufEquals($userWorkloadsSecret, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createUserWorkloadsSecretExceptionTest() - { - $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $userWorkloadsSecret = new UserWorkloadsSecret(); - try { - $gapicClient->createUserWorkloadsSecret($formattedParent, $userWorkloadsSecret); - // 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 databaseFailoverTest() - { - $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/databaseFailoverTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new DatabaseFailoverResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/databaseFailoverTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->databaseFailover(); - $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.orchestration.airflow.service.v1.Environments/DatabaseFailover', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/databaseFailoverTest'); - $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 databaseFailoverExceptionTest() - { - $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/databaseFailoverTest'); - $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); - $response = $gapicClient->databaseFailover(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/databaseFailoverTest'); - 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 deleteEnvironmentTest() - { - $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/deleteEnvironmentTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteEnvironmentTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->deleteEnvironment(); - $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.orchestration.airflow.service.v1.Environments/DeleteEnvironment', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteEnvironmentTest'); - $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 deleteEnvironmentExceptionTest() - { - $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/deleteEnvironmentTest'); - $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); - $response = $gapicClient->deleteEnvironment(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteEnvironmentTest'); - 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 deleteUserWorkloadsConfigMapTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - $gapicClient->deleteUserWorkloadsConfigMap($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsConfigMap', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteUserWorkloadsConfigMapExceptionTest() - { - $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->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - try { - $gapicClient->deleteUserWorkloadsConfigMap($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 deleteUserWorkloadsSecretTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - $gapicClient->deleteUserWorkloadsSecret($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsSecret', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteUserWorkloadsSecretExceptionTest() - { - $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->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - try { - $gapicClient->deleteUserWorkloadsSecret($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 executeAirflowCommandTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $executionId = 'executionId-1217171550'; - $pod = 'pod111173'; - $podNamespace = 'podNamespace-896290847'; - $error = 'error96784904'; - $expectedResponse = new ExecuteAirflowCommandResponse(); - $expectedResponse->setExecutionId($executionId); - $expectedResponse->setPod($pod); - $expectedResponse->setPodNamespace($podNamespace); - $expectedResponse->setError($error); - $transport->addResponse($expectedResponse); - $response = $gapicClient->executeAirflowCommand(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ExecuteAirflowCommand', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function executeAirflowCommandExceptionTest() - { - $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); - try { - $gapicClient->executeAirflowCommand(); - // 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 fetchDatabasePropertiesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $primaryGceZone = 'primaryGceZone-1946545985'; - $secondaryGceZone = 'secondaryGceZone826699149'; - $isFailoverReplicaAvailable = true; - $expectedResponse = new FetchDatabasePropertiesResponse(); - $expectedResponse->setPrimaryGceZone($primaryGceZone); - $expectedResponse->setSecondaryGceZone($secondaryGceZone); - $expectedResponse->setIsFailoverReplicaAvailable($isFailoverReplicaAvailable); - $transport->addResponse($expectedResponse); - // Mock request - $formattedEnvironment = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $response = $gapicClient->fetchDatabaseProperties($formattedEnvironment); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/FetchDatabaseProperties', $actualFuncCall); - $actualValue = $actualRequestObject->getEnvironment(); - $this->assertProtobufEquals($formattedEnvironment, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function fetchDatabasePropertiesExceptionTest() - { - $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 - $formattedEnvironment = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - try { - $gapicClient->fetchDatabaseProperties($formattedEnvironment); - // 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 getEnvironmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $uuid = 'uuid3601339'; - $satisfiesPzs = false; - $expectedResponse = new Environment(); - $expectedResponse->setName($name2); - $expectedResponse->setUuid($uuid); - $expectedResponse->setSatisfiesPzs($satisfiesPzs); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getEnvironment(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/GetEnvironment', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getEnvironmentExceptionTest() - { - $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); - try { - $gapicClient->getEnvironment(); - // 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 getUserWorkloadsConfigMapTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $expectedResponse = new UserWorkloadsConfigMap(); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - $response = $gapicClient->getUserWorkloadsConfigMap($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.orchestration.airflow.service.v1.Environments/GetUserWorkloadsConfigMap', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getUserWorkloadsConfigMapExceptionTest() - { - $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->userWorkloadsConfigMapName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_CONFIG_MAP]'); - try { - $gapicClient->getUserWorkloadsConfigMap($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 getUserWorkloadsSecretTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $expectedResponse = new UserWorkloadsSecret(); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - $response = $gapicClient->getUserWorkloadsSecret($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.orchestration.airflow.service.v1.Environments/GetUserWorkloadsSecret', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getUserWorkloadsSecretExceptionTest() - { - $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->userWorkloadsSecretName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]', '[USER_WORKLOADS_SECRET]'); - try { - $gapicClient->getUserWorkloadsSecret($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 listEnvironmentsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $environmentsElement = new Environment(); - $environments = [ - $environmentsElement, - ]; - $expectedResponse = new ListEnvironmentsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setEnvironments($environments); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listEnvironments(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getEnvironments()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ListEnvironments', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listEnvironmentsExceptionTest() - { - $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); - try { - $gapicClient->listEnvironments(); - // 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 listUserWorkloadsConfigMapsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $userWorkloadsConfigMapsElement = new UserWorkloadsConfigMap(); - $userWorkloadsConfigMaps = [ - $userWorkloadsConfigMapsElement, - ]; - $expectedResponse = new ListUserWorkloadsConfigMapsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setUserWorkloadsConfigMaps($userWorkloadsConfigMaps); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $response = $gapicClient->listUserWorkloadsConfigMaps($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getUserWorkloadsConfigMaps()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsConfigMaps', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listUserWorkloadsConfigMapsExceptionTest() - { - $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - try { - $gapicClient->listUserWorkloadsConfigMaps($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 listUserWorkloadsSecretsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $userWorkloadsSecretsElement = new UserWorkloadsSecret(); - $userWorkloadsSecrets = [ - $userWorkloadsSecretsElement, - ]; - $expectedResponse = new ListUserWorkloadsSecretsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setUserWorkloadsSecrets($userWorkloadsSecrets); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $response = $gapicClient->listUserWorkloadsSecrets($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getUserWorkloadsSecrets()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsSecrets', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listUserWorkloadsSecretsExceptionTest() - { - $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - try { - $gapicClient->listUserWorkloadsSecrets($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 listWorkloadsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $workloadsElement = new ComposerWorkload(); - $workloads = [ - $workloadsElement, - ]; - $expectedResponse = new ListWorkloadsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setWorkloads($workloads); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - $response = $gapicClient->listWorkloads($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getWorkloads()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/ListWorkloads', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listWorkloadsExceptionTest() - { - $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->environmentName('[PROJECT]', '[LOCATION]', '[ENVIRONMENT]'); - try { - $gapicClient->listWorkloads($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 loadSnapshotTest() - { - $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/loadSnapshotTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new LoadSnapshotResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/loadSnapshotTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->loadSnapshot(); - $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.orchestration.airflow.service.v1.Environments/LoadSnapshot', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/loadSnapshotTest'); - $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 loadSnapshotExceptionTest() - { - $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/loadSnapshotTest'); - $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); - $response = $gapicClient->loadSnapshot(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/loadSnapshotTest'); - 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 pollAirflowCommandTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $outputEnd = false; - $expectedResponse = new PollAirflowCommandResponse(); - $expectedResponse->setOutputEnd($outputEnd); - $transport->addResponse($expectedResponse); - $response = $gapicClient->pollAirflowCommand(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/PollAirflowCommand', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function pollAirflowCommandExceptionTest() - { - $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); - try { - $gapicClient->pollAirflowCommand(); - // 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 saveSnapshotTest() - { - $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/saveSnapshotTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $snapshotPath = 'snapshotPath1197949376'; - $expectedResponse = new SaveSnapshotResponse(); - $expectedResponse->setSnapshotPath($snapshotPath); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/saveSnapshotTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->saveSnapshot(); - $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.orchestration.airflow.service.v1.Environments/SaveSnapshot', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/saveSnapshotTest'); - $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 saveSnapshotExceptionTest() - { - $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/saveSnapshotTest'); - $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); - $response = $gapicClient->saveSnapshot(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/saveSnapshotTest'); - 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 stopAirflowCommandTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $isDone = false; - $expectedResponse = new StopAirflowCommandResponse(); - $expectedResponse->setIsDone($isDone); - $transport->addResponse($expectedResponse); - $response = $gapicClient->stopAirflowCommand(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/StopAirflowCommand', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function stopAirflowCommandExceptionTest() - { - $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); - try { - $gapicClient->stopAirflowCommand(); - // 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 updateEnvironmentTest() - { - $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/updateEnvironmentTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $uuid = 'uuid3601339'; - $satisfiesPzs = false; - $expectedResponse = new Environment(); - $expectedResponse->setName($name2); - $expectedResponse->setUuid($uuid); - $expectedResponse->setSatisfiesPzs($satisfiesPzs); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateEnvironmentTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->updateEnvironment(); - $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.orchestration.airflow.service.v1.Environments/UpdateEnvironment', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateEnvironmentTest'); - $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 updateEnvironmentExceptionTest() - { - $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/updateEnvironmentTest'); - $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); - $response = $gapicClient->updateEnvironment(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateEnvironmentTest'); - 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 updateUserWorkloadsConfigMapTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $expectedResponse = new UserWorkloadsConfigMap(); - $expectedResponse->setName($name); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateUserWorkloadsConfigMap(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsConfigMap', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateUserWorkloadsConfigMapExceptionTest() - { - $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); - try { - $gapicClient->updateUserWorkloadsConfigMap(); - // 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 updateUserWorkloadsSecretTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $expectedResponse = new UserWorkloadsSecret(); - $expectedResponse->setName($name); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateUserWorkloadsSecret(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsSecret', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateUserWorkloadsSecretExceptionTest() - { - $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); - try { - $gapicClient->updateUserWorkloadsSecret(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/OrchestrationAirflow/tests/Unit/V1/ImageVersionsClientTest.php b/OrchestrationAirflow/tests/Unit/V1/ImageVersionsClientTest.php deleted file mode 100644 index 7a94984ed491..000000000000 --- a/OrchestrationAirflow/tests/Unit/V1/ImageVersionsClientTest.php +++ /dev/null @@ -1,124 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ImageVersionsClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ImageVersionsClient($options); - } - - /** @test */ - public function listImageVersionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $imageVersionsElement = new ImageVersion(); - $imageVersions = [ - $imageVersionsElement, - ]; - $expectedResponse = new ListImageVersionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setImageVersions($imageVersions); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listImageVersions(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getImageVersions()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.orchestration.airflow.service.v1.ImageVersions/ListImageVersions', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listImageVersionsExceptionTest() - { - $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); - try { - $gapicClient->listImageVersions(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/OsLogin/.OwlBot.yaml b/OsLogin/.OwlBot.yaml index 169ae91ded39..1a001fa87e7e 100644 --- a/OsLogin/.OwlBot.yaml +++ b/OsLogin/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/oslogin/(.*)/.*-php/(.*) + - source: /google/cloud/oslogin/(v1)/.*-php/(.*) dest: /owl-bot-staging/OsLogin/$1/$2 api-name: OsLogin diff --git a/OsLogin/metadata/Common.php b/OsLogin/metadata/Common.php deleted file mode 100644 index 933be9dfb39c..000000000000 --- a/OsLogin/metadata/Common.php +++ /dev/null @@ -1,41 +0,0 @@ -internalAddGeneratedFile(hex2bin( - "0af4030a21676f6f676c652f636c6f75642f6f736c6f67696e2f636f6d6d" . - "6f6e2e70726f746f121b676f6f676c652e636c6f75642e6f736c6f67696e" . - "2e636f6d6d6f6e22a8010a0c506f7369784163636f756e74120f0a077072" . - "696d61727918012001280812100a08757365726e616d6518022001280912" . - "0b0a03756964180320012803120b0a0367696418042001280312160a0e68" . - "6f6d655f6469726563746f7279180520012809120d0a057368656c6c1806" . - "20012809120d0a056765636f7318072001280912110a0973797374656d5f" . - "696418082001280912120a0a6163636f756e745f6964180920012809224e" . - "0a0c5373685075626c69634b6579120b0a036b6579180120012809121c0a" . - "1465787069726174696f6e5f74696d655f7573656318022001280312130a" . - "0b66696e6765727072696e7418032001280942ae010a1f636f6d2e676f6f" . - "676c652e636c6f75642e6f736c6f67696e2e636f6d6d6f6e420c4f734c6f" . - "67696e50726f746f5a41676f6f676c652e676f6c616e672e6f72672f6765" . - "6e70726f746f2f676f6f676c65617069732f636c6f75642f6f736c6f6769" . - "6e2f636f6d6d6f6e3b636f6d6d6f6eaa021b476f6f676c652e436c6f7564" . - "2e4f734c6f67696e2e436f6d6d6f6eca021b476f6f676c655c436c6f7564" . - "5c4f734c6f67696e5c436f6d6d6f6e620670726f746f33" - )); - - static::$is_initialized = true; - } -} - diff --git a/OsLogin/metadata/V1Beta/Oslogin.php b/OsLogin/metadata/V1Beta/Oslogin.php deleted file mode 100644 index c97930d8b375..000000000000 Binary files a/OsLogin/metadata/V1Beta/Oslogin.php and /dev/null differ diff --git a/OsLogin/owlbot.py b/OsLogin/owlbot.py index 04f874495133..2b9b834ce9d8 100644 --- a/OsLogin/owlbot.py +++ b/OsLogin/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2018 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,55 +32,14 @@ php.owlbot_main(src=src, dest=dest) -# fix copyright year +# remove class_alias code s.replace( - 'src/V1beta/**/*.php', - r'Copyright \d{4}', - r'Copyright 2017') -s.replace( - 'tests/**/V1beta/*Test.php', - r'Copyright \d{4}', - r'Copyright 2018') -s.replace( - 'src/V1/**/*.php', - r'Copyright \d{4}', - r'Copyright 2018') -s.replace( - 'tests/**/V1/*Test.php', - r'Copyright \d{4}', - r'Copyright 2018') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - ["src/**/V*/**/*.php", "src/Common/**/*.php"], - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# prevent proto messages from being marked final -s.replace( - ["src/**/V*/**/*.php", "src/Common/**/*.php"], - r"final class", - r"class") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - ["src/**/V*/**/*.php", "src/Common/**/*.php"], - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) + "src/V*/**/*.php", + r"^// Adding a class alias for backwards compatibility with the previous class name.$" + + "\n" + + r"^class_alias\(.*\);$" + + "\n", + '') # format generated clients subprocess.run([ @@ -90,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/OsLogin/src/Common/PosixAccount.php b/OsLogin/src/Common/PosixAccount.php index 3d2e0dd18041..99d5713285c0 100644 --- a/OsLogin/src/Common/PosixAccount.php +++ b/OsLogin/src/Common/PosixAccount.php @@ -20,68 +20,68 @@ class PosixAccount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool primary = 1; */ - private $primary = false; + protected $primary = false; /** * The username of the POSIX account. * * Generated from protobuf field string username = 2; */ - private $username = ''; + protected $username = ''; /** * The user ID. * * Generated from protobuf field int64 uid = 3; */ - private $uid = 0; + protected $uid = 0; /** * The default group ID. * * Generated from protobuf field int64 gid = 4; */ - private $gid = 0; + protected $gid = 0; /** * The path to the home directory for this account. * * Generated from protobuf field string home_directory = 5; */ - private $home_directory = ''; + protected $home_directory = ''; /** * The path to the logic shell for this account. * * Generated from protobuf field string shell = 6; */ - private $shell = ''; + protected $shell = ''; /** * The GECOS (user information) entry for this account. * * Generated from protobuf field string gecos = 7; */ - private $gecos = ''; + protected $gecos = ''; /** * System identifier for which account the username or uid applies to. * By default, the empty value is used. * * Generated from protobuf field string system_id = 8; */ - private $system_id = ''; + protected $system_id = ''; /** * Output only. A POSIX account identifier. * * Generated from protobuf field string account_id = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $account_id = ''; + protected $account_id = ''; /** * The operating system type where this account applies. * * Generated from protobuf field .google.cloud.oslogin.common.OperatingSystemType operating_system_type = 10; */ - private $operating_system_type = 0; + protected $operating_system_type = 0; /** * Output only. The canonical resource name. * * Generated from protobuf field string name = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/OsLogin/src/Common/SshPublicKey.php b/OsLogin/src/Common/SshPublicKey.php index d9f51cc19dab..185588081e3e 100644 --- a/OsLogin/src/Common/SshPublicKey.php +++ b/OsLogin/src/Common/SshPublicKey.php @@ -22,25 +22,25 @@ class SshPublicKey extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string key = 1; */ - private $key = ''; + protected $key = ''; /** * An expiration time in microseconds since epoch. * * Generated from protobuf field int64 expiration_time_usec = 2; */ - private $expiration_time_usec = 0; + protected $expiration_time_usec = 0; /** * Output only. The SHA-256 fingerprint of the SSH public key. * * Generated from protobuf field string fingerprint = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $fingerprint = ''; + protected $fingerprint = ''; /** * Output only. The canonical resource name. * * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/OsLogin/src/V1/Client/OsLoginServiceClient.php b/OsLogin/src/V1/Client/OsLoginServiceClient.php index 4d3b12c8689c..39a32ff2fdff 100644 --- a/OsLogin/src/V1/Client/OsLoginServiceClient.php +++ b/OsLogin/src/V1/Client/OsLoginServiceClient.php @@ -1,6 +1,6 @@ startApiCall('ImportSshPublicKey', $request, $callOptions)->wait(); } diff --git a/OsLogin/src/V1/CreateSshPublicKeyRequest.php b/OsLogin/src/V1/CreateSshPublicKeyRequest.php index d23bd61ec055..76728c29f5e7 100644 --- a/OsLogin/src/V1/CreateSshPublicKeyRequest.php +++ b/OsLogin/src/V1/CreateSshPublicKeyRequest.php @@ -20,13 +20,13 @@ class CreateSshPublicKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The SSH public key and expiration time. * * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $ssh_public_key = null; + protected $ssh_public_key = null; /** * @param string $parent Required. The unique ID for the user in format `users/{user}`. Please see diff --git a/OsLogin/src/V1/DeletePosixAccountRequest.php b/OsLogin/src/V1/DeletePosixAccountRequest.php index 43d16eceae39..965160ab977f 100644 --- a/OsLogin/src/V1/DeletePosixAccountRequest.php +++ b/OsLogin/src/V1/DeletePosixAccountRequest.php @@ -22,7 +22,7 @@ class DeletePosixAccountRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. A reference to the POSIX account to update. POSIX accounts are diff --git a/OsLogin/src/V1/DeleteSshPublicKeyRequest.php b/OsLogin/src/V1/DeleteSshPublicKeyRequest.php index b635eb21c5ff..11383a19392f 100644 --- a/OsLogin/src/V1/DeleteSshPublicKeyRequest.php +++ b/OsLogin/src/V1/DeleteSshPublicKeyRequest.php @@ -22,7 +22,7 @@ class DeleteSshPublicKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The fingerprint of the public key to update. Public keys are diff --git a/OsLogin/src/V1/Gapic/OsLoginServiceGapicClient.php b/OsLogin/src/V1/Gapic/OsLoginServiceGapicClient.php deleted file mode 100644 index a50206cce7f5..000000000000 --- a/OsLogin/src/V1/Gapic/OsLoginServiceGapicClient.php +++ /dev/null @@ -1,734 +0,0 @@ -userName('[USER]'); - * $sshPublicKey = new SshPublicKey(); - * $response = $osLoginServiceClient->createSshPublicKey($formattedParent, $sshPublicKey); - * } finally { - * $osLoginServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\OsLogin\V1\Client\OsLoginServiceClient}. - */ -class OsLoginServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.oslogin.v1.OsLoginService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'oslogin.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'oslogin.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/compute', - 'https://www.googleapis.com/auth/compute.readonly', - ]; - - private static $posixAccountNameTemplate; - - private static $sshPublicKeyNameTemplate; - - private static $userNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getPosixAccountNameTemplate() - { - if (self::$posixAccountNameTemplate == null) { - self::$posixAccountNameTemplate = new PathTemplate( - 'users/{user}/projects/{project}' - ); - } - - return self::$posixAccountNameTemplate; - } - - private static function getSshPublicKeyNameTemplate() - { - if (self::$sshPublicKeyNameTemplate == null) { - self::$sshPublicKeyNameTemplate = new PathTemplate( - 'users/{user}/sshPublicKeys/{fingerprint}' - ); - } - - return self::$sshPublicKeyNameTemplate; - } - - private static function getUserNameTemplate() - { - if (self::$userNameTemplate == null) { - self::$userNameTemplate = new PathTemplate('users/{user}'); - } - - return self::$userNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'posixAccount' => self::getPosixAccountNameTemplate(), - 'sshPublicKey' => self::getSshPublicKeyNameTemplate(), - 'user' => self::getUserNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($user, $project) - { - return self::getPosixAccountNameTemplate()->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($user, $fingerprint) - { - return self::getSshPublicKeyNameTemplate()->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($user) - { - return self::getUserNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * Create an SSH public key - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedParent = $osLoginServiceClient->userName('[USER]'); - * $sshPublicKey = new SshPublicKey(); - * $response = $osLoginServiceClient->createSshPublicKey($formattedParent, $sshPublicKey); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique ID for the user in format `users/{user}`. - * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. - * @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\OsLogin\Common\SshPublicKey - * - * @throws ApiException if the remote call fails - */ - public function createSshPublicKey( - $parent, - $sshPublicKey, - array $optionalArgs = [] - ) { - $request = new CreateSshPublicKeyRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setSshPublicKey($sshPublicKey); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateSshPublicKey', - SshPublicKey::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a POSIX account. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->posixAccountName('[USER]', '[PROJECT]'); - * $osLoginServiceClient->deletePosixAccount($formattedName); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - * @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 deletePosixAccount($name, array $optionalArgs = []) - { - $request = new DeletePosixAccountRequest(); - $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( - 'DeletePosixAccount', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes an SSH public key. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - * $osLoginServiceClient->deleteSshPublicKey($formattedName); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @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 deleteSshPublicKey($name, array $optionalArgs = []) - { - $request = new DeleteSshPublicKeyRequest(); - $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( - 'DeleteSshPublicKey', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->userName('[USER]'); - * $response = $osLoginServiceClient->getLoginProfile($formattedName); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The unique ID for the user in format `users/{user}`. - * @param array $optionalArgs { - * Optional. - * - * @type string $projectId - * The project ID of the Google Cloud Platform project. - * @type string $systemId - * A system ID for filtering the results of the request. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\OsLogin\V1\LoginProfile - * - * @throws ApiException if the remote call fails - */ - public function getLoginProfile($name, array $optionalArgs = []) - { - $request = new GetLoginProfileRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['projectId'])) { - $request->setProjectId($optionalArgs['projectId']); - } - - if (isset($optionalArgs['systemId'])) { - $request->setSystemId($optionalArgs['systemId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLoginProfile', - LoginProfile::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Retrieves an SSH public key. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - * $response = $osLoginServiceClient->getSshPublicKey($formattedName); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @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\OsLogin\Common\SshPublicKey - * - * @throws ApiException if the remote call fails - */ - public function getSshPublicKey($name, array $optionalArgs = []) - { - $request = new GetSshPublicKeyRequest(); - $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( - 'GetSshPublicKey', - SshPublicKey::class, - $optionalArgs, - $request - )->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. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedParent = $osLoginServiceClient->userName('[USER]'); - * $response = $osLoginServiceClient->importSshPublicKey($formattedParent); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique ID for the user in format `users/{user}`. - * @param array $optionalArgs { - * Optional. - * - * @type SshPublicKey $sshPublicKey - * Optional. The SSH public key and expiration time. - * @type string $projectId - * The project ID of the Google Cloud Platform project. - * @type string[] $regions - * Optional. The regions to which to assert that the key was written. - * If unspecified, defaults to all regions. - * Regions are listed at https://cloud.google.com/about/locations#region. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\OsLogin\V1\ImportSshPublicKeyResponse - * - * @throws ApiException if the remote call fails - */ - public function importSshPublicKey($parent, array $optionalArgs = []) - { - $request = new ImportSshPublicKeyRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['sshPublicKey'])) { - $request->setSshPublicKey($optionalArgs['sshPublicKey']); - } - - if (isset($optionalArgs['projectId'])) { - $request->setProjectId($optionalArgs['projectId']); - } - - if (isset($optionalArgs['regions'])) { - $request->setRegions($optionalArgs['regions']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'ImportSshPublicKey', - ImportSshPublicKeyResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - * $sshPublicKey = new SshPublicKey(); - * $response = $osLoginServiceClient->updateSshPublicKey($formattedName, $sshPublicKey); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Mask to control which fields get updated. Updates all if not present. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\OsLogin\Common\SshPublicKey - * - * @throws ApiException if the remote call fails - */ - public function updateSshPublicKey( - $name, - $sshPublicKey, - array $optionalArgs = [] - ) { - $request = new UpdateSshPublicKeyRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setSshPublicKey($sshPublicKey); - $requestParamHeaders['name'] = $name; - 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( - 'UpdateSshPublicKey', - SshPublicKey::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/OsLogin/src/V1/GetLoginProfileRequest.php b/OsLogin/src/V1/GetLoginProfileRequest.php index 88810e75ebf1..85992364fab9 100644 --- a/OsLogin/src/V1/GetLoginProfileRequest.php +++ b/OsLogin/src/V1/GetLoginProfileRequest.php @@ -20,19 +20,19 @@ class GetLoginProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * The project ID of the Google Cloud Platform project. * * Generated from protobuf field string project_id = 2; */ - private $project_id = ''; + protected $project_id = ''; /** * A system ID for filtering the results of the request. * * Generated from protobuf field string system_id = 3; */ - private $system_id = ''; + protected $system_id = ''; /** * @param string $name Required. The unique ID for the user in format `users/{user}`. Please see diff --git a/OsLogin/src/V1/GetSshPublicKeyRequest.php b/OsLogin/src/V1/GetSshPublicKeyRequest.php index 7e14a4f8c5b0..6e6de1d0ec84 100644 --- a/OsLogin/src/V1/GetSshPublicKeyRequest.php +++ b/OsLogin/src/V1/GetSshPublicKeyRequest.php @@ -22,7 +22,7 @@ class GetSshPublicKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The fingerprint of the public key to retrieve. Public keys are diff --git a/OsLogin/src/V1/ImportSshPublicKeyRequest.php b/OsLogin/src/V1/ImportSshPublicKeyRequest.php index 186dc5632193..122ed6f2f131 100644 --- a/OsLogin/src/V1/ImportSshPublicKeyRequest.php +++ b/OsLogin/src/V1/ImportSshPublicKeyRequest.php @@ -20,19 +20,19 @@ class ImportSshPublicKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. The SSH public key and expiration time. * * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $ssh_public_key = null; + protected $ssh_public_key = null; /** * The project ID of the Google Cloud Platform project. * * Generated from protobuf field string project_id = 3; */ - private $project_id = ''; + protected $project_id = ''; /** * Optional. The regions to which to assert that the key was written. * If unspecified, defaults to all regions. diff --git a/OsLogin/src/V1/ImportSshPublicKeyResponse.php b/OsLogin/src/V1/ImportSshPublicKeyResponse.php index 533e0fc715e9..c9c749a53bee 100644 --- a/OsLogin/src/V1/ImportSshPublicKeyResponse.php +++ b/OsLogin/src/V1/ImportSshPublicKeyResponse.php @@ -20,13 +20,13 @@ class ImportSshPublicKeyResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.oslogin.v1.LoginProfile login_profile = 1; */ - private $login_profile = null; + protected $login_profile = null; /** * Detailed information about import results. * * Generated from protobuf field string details = 2; */ - private $details = ''; + protected $details = ''; /** * Constructor. diff --git a/OsLogin/src/V1/LoginProfile.php b/OsLogin/src/V1/LoginProfile.php index 6e521f78cf58..6abe567377c1 100644 --- a/OsLogin/src/V1/LoginProfile.php +++ b/OsLogin/src/V1/LoginProfile.php @@ -21,7 +21,7 @@ class LoginProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * The list of POSIX accounts associated with the user. * diff --git a/OsLogin/src/V1/OsLoginServiceClient.php b/OsLogin/src/V1/OsLoginServiceClient.php deleted file mode 100644 index cc6a99c527d6..000000000000 --- a/OsLogin/src/V1/OsLoginServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey', - $argument, - ['\Google\Cloud\OsLogin\Common\SshPublicKey', 'decode'], - $metadata, $options); - } - - /** - * Deletes a POSIX account. - * @param \Google\Cloud\OsLogin\V1\DeletePosixAccountRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeletePosixAccount(\Google\Cloud\OsLogin\V1\DeletePosixAccountRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1.OsLoginService/DeletePosixAccount', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Deletes an SSH public key. - * @param \Google\Cloud\OsLogin\V1\DeleteSshPublicKeyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteSshPublicKey(\Google\Cloud\OsLogin\V1\DeleteSshPublicKeyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1.OsLoginService/DeleteSshPublicKey', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * @param \Google\Cloud\OsLogin\V1\GetLoginProfileRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetLoginProfile(\Google\Cloud\OsLogin\V1\GetLoginProfileRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1.OsLoginService/GetLoginProfile', - $argument, - ['\Google\Cloud\OsLogin\V1\LoginProfile', 'decode'], - $metadata, $options); - } - - /** - * Retrieves an SSH public key. - * @param \Google\Cloud\OsLogin\V1\GetSshPublicKeyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetSshPublicKey(\Google\Cloud\OsLogin\V1\GetSshPublicKeyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1.OsLoginService/GetSshPublicKey', - $argument, - ['\Google\Cloud\OsLogin\Common\SshPublicKey', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\OsLogin\V1\ImportSshPublicKeyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ImportSshPublicKey(\Google\Cloud\OsLogin\V1\ImportSshPublicKeyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1.OsLoginService/ImportSshPublicKey', - $argument, - ['\Google\Cloud\OsLogin\V1\ImportSshPublicKeyResponse', 'decode'], - $metadata, $options); - } - - /** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * @param \Google\Cloud\OsLogin\V1\UpdateSshPublicKeyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateSshPublicKey(\Google\Cloud\OsLogin\V1\UpdateSshPublicKeyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1.OsLoginService/UpdateSshPublicKey', - $argument, - ['\Google\Cloud\OsLogin\Common\SshPublicKey', 'decode'], - $metadata, $options); - } - -} diff --git a/OsLogin/src/V1/README.md b/OsLogin/src/V1/README.md deleted file mode 100644 index e28991eefefd..000000000000 --- a/OsLogin/src/V1/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Google Cloud OsLogin V1 generated client for PHP - -### Sample - -```php -require 'vendor/autoload.php'; - -use Google\Cloud\OsLogin\V1\OsLoginServiceClient; - -$osLoginServiceClient = new OsLoginServiceClient(); -$userId = '[MY_USER_ID]'; -$formattedName = $osLoginServiceClient->userName($userId); -$loginProfile = $osLoginServiceClient->getLoginProfile($formattedName); -``` diff --git a/OsLogin/src/V1/UpdateSshPublicKeyRequest.php b/OsLogin/src/V1/UpdateSshPublicKeyRequest.php index 318b6b48b6d6..421c2a2586c5 100644 --- a/OsLogin/src/V1/UpdateSshPublicKeyRequest.php +++ b/OsLogin/src/V1/UpdateSshPublicKeyRequest.php @@ -22,19 +22,19 @@ class UpdateSshPublicKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The SSH public key and expiration time. * * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $ssh_public_key = null; + protected $ssh_public_key = null; /** * Mask to control which fields get updated. Updates all if not present. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; */ - private $update_mask = null; + protected $update_mask = null; /** * @param string $name Required. The fingerprint of the public key to update. Public keys are diff --git a/OsLogin/src/V1/resources/os_login_service_descriptor_config.php b/OsLogin/src/V1/resources/os_login_service_descriptor_config.php index 9ae321a9cf63..f76e9c8d302a 100644 --- a/OsLogin/src/V1/resources/os_login_service_descriptor_config.php +++ b/OsLogin/src/V1/resources/os_login_service_descriptor_config.php @@ -1,6 +1,6 @@ google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest - */ -class CreateSshPublicKeyRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The unique ID for the user in format `users/{user}`. - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $parent = ''; - /** - * Required. The SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $ssh_public_key = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * Required. The unique ID for the user in format `users/{user}`. - * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key - * Required. The SSH public key and expiration time. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Required. The unique ID for the user in format `users/{user}`. - * - * 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 unique ID for the user in format `users/{user}`. - * - * 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 SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null - */ - public function getSshPublicKey() - { - return $this->ssh_public_key; - } - - public function hasSshPublicKey() - { - return isset($this->ssh_public_key); - } - - public function clearSshPublicKey() - { - unset($this->ssh_public_key); - } - - /** - * Required. The SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var - * @return $this - */ - public function setSshPublicKey($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); - $this->ssh_public_key = $var; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/DeletePosixAccountRequest.php b/OsLogin/src/V1beta/DeletePosixAccountRequest.php deleted file mode 100644 index 5684814f4606..000000000000 --- a/OsLogin/src/V1beta/DeletePosixAccountRequest.php +++ /dev/null @@ -1,75 +0,0 @@ -google.cloud.oslogin.v1beta.DeletePosixAccountRequest - */ -class DeletePosixAccountRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - * - * 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. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - * - * 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/OsLogin/src/V1beta/DeleteSshPublicKeyRequest.php b/OsLogin/src/V1beta/DeleteSshPublicKeyRequest.php deleted file mode 100644 index 4ea0038ce5d3..000000000000 --- a/OsLogin/src/V1beta/DeleteSshPublicKeyRequest.php +++ /dev/null @@ -1,75 +0,0 @@ -google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest - */ -class DeleteSshPublicKeyRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * 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 fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * 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/OsLogin/src/V1beta/Gapic/OsLoginServiceGapicClient.php b/OsLogin/src/V1beta/Gapic/OsLoginServiceGapicClient.php deleted file mode 100644 index ae929de07361..000000000000 --- a/OsLogin/src/V1beta/Gapic/OsLoginServiceGapicClient.php +++ /dev/null @@ -1,837 +0,0 @@ -userName('[USER]'); - * $sshPublicKey = new SshPublicKey(); - * $response = $osLoginServiceClient->createSshPublicKey($formattedParent, $sshPublicKey); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * Many parameters require resource names to be formatted in a particular way. To - * assist with these names, this class includes a format method for each type of - * name, and additionally a parseName method to extract the individual identifiers - * contained within formatted names that are returned by the API. - * - * @experimental - * - * @deprecated This class will be removed in the next major version update. - */ -class OsLoginServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.oslogin.v1beta.OsLoginService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'oslogin.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'oslogin.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - 'https://www.googleapis.com/auth/compute', - 'https://www.googleapis.com/auth/compute.readonly', - ]; - - private static $posixAccountNameTemplate; - - private static $sshPublicKeyNameTemplate; - - private static $userNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getPosixAccountNameTemplate() - { - if (self::$posixAccountNameTemplate == null) { - self::$posixAccountNameTemplate = new PathTemplate( - 'users/{user}/projects/{project}' - ); - } - - return self::$posixAccountNameTemplate; - } - - private static function getSshPublicKeyNameTemplate() - { - if (self::$sshPublicKeyNameTemplate == null) { - self::$sshPublicKeyNameTemplate = new PathTemplate( - 'users/{user}/sshPublicKeys/{fingerprint}' - ); - } - - return self::$sshPublicKeyNameTemplate; - } - - private static function getUserNameTemplate() - { - if (self::$userNameTemplate == null) { - self::$userNameTemplate = new PathTemplate('users/{user}'); - } - - return self::$userNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'posixAccount' => self::getPosixAccountNameTemplate(), - 'sshPublicKey' => self::getSshPublicKeyNameTemplate(), - 'user' => self::getUserNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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. - * - * @experimental - */ - public static function posixAccountName($user, $project) - { - return self::getPosixAccountNameTemplate()->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. - * - * @experimental - */ - public static function sshPublicKeyName($user, $fingerprint) - { - return self::getSshPublicKeyNameTemplate()->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. - * - * @experimental - */ - public static function userName($user) - { - return self::getUserNameTemplate()->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. - * - * @experimental - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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 - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Create an SSH public key - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedParent = $osLoginServiceClient->userName('[USER]'); - * $sshPublicKey = new SshPublicKey(); - * $response = $osLoginServiceClient->createSshPublicKey($formattedParent, $sshPublicKey); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique ID for the user in format `users/{user}`. - * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. - * @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\OsLogin\Common\SshPublicKey - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function createSshPublicKey( - $parent, - $sshPublicKey, - array $optionalArgs = [] - ) { - $request = new CreateSshPublicKeyRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setSshPublicKey($sshPublicKey); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateSshPublicKey', - SshPublicKey::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a POSIX account. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->posixAccountName('[USER]', '[PROJECT]'); - * $osLoginServiceClient->deletePosixAccount($formattedName); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. A reference to the POSIX account to update. POSIX accounts are - * identified by the project ID they are associated with. A reference to the - * POSIX account is in format `users/{user}/projects/{project}`. - * @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 - * - * @experimental - */ - public function deletePosixAccount($name, array $optionalArgs = []) - { - $request = new DeletePosixAccountRequest(); - $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( - 'DeletePosixAccount', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes an SSH public key. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - * $osLoginServiceClient->deleteSshPublicKey($formattedName); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @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 - * - * @experimental - */ - public function deleteSshPublicKey($name, array $optionalArgs = []) - { - $request = new DeleteSshPublicKeyRequest(); - $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( - 'DeleteSshPublicKey', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->userName('[USER]'); - * $response = $osLoginServiceClient->getLoginProfile($formattedName); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The unique ID for the user in format `users/{user}`. - * @param array $optionalArgs { - * Optional. - * - * @type string $projectId - * The project ID of the Google Cloud Platform project. - * @type string $systemId - * A system ID for filtering the results of the request. - * @type int $view - * The view configures whether to retrieve security keys information. - * For allowed values, use constants defined on {@see \Google\Cloud\OsLogin\V1beta\LoginProfileView} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\OsLogin\V1beta\LoginProfile - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function getLoginProfile($name, array $optionalArgs = []) - { - $request = new GetLoginProfileRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['projectId'])) { - $request->setProjectId($optionalArgs['projectId']); - } - - if (isset($optionalArgs['systemId'])) { - $request->setSystemId($optionalArgs['systemId']); - } - - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLoginProfile', - LoginProfile::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Retrieves an SSH public key. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - * $response = $osLoginServiceClient->getSshPublicKey($formattedName); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @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\OsLogin\Common\SshPublicKey - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function getSshPublicKey($name, array $optionalArgs = []) - { - $request = new GetSshPublicKeyRequest(); - $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( - 'GetSshPublicKey', - SshPublicKey::class, - $optionalArgs, - $request - )->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. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $sshPublicKey = new SshPublicKey(); - * $response = $osLoginServiceClient->importSshPublicKey($sshPublicKey); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * The unique ID for the user in format `users/{user}`. - * @type string $projectId - * The project ID of the Google Cloud Platform project. - * @type int $view - * The view configures whether to retrieve security keys information. - * For allowed values, use constants defined on {@see \Google\Cloud\OsLogin\V1beta\LoginProfileView} - * @type string[] $regions - * Optional. The regions to which to assert that the key was written. - * If unspecified, defaults to all regions. - * Regions are listed at https://cloud.google.com/about/locations#region. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\OsLogin\V1beta\ImportSshPublicKeyResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function importSshPublicKey($sshPublicKey, array $optionalArgs = []) - { - $request = new ImportSshPublicKeyRequest(); - $requestParamHeaders = []; - $request->setSshPublicKey($sshPublicKey); - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['parent']; - } - - if (isset($optionalArgs['projectId'])) { - $request->setProjectId($optionalArgs['projectId']); - } - - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - if (isset($optionalArgs['regions'])) { - $request->setRegions($optionalArgs['regions']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'ImportSshPublicKey', - ImportSshPublicKeyResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Signs an SSH public key for a user to authenticate to an instance. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $response = $osLoginServiceClient->signSshPublicKey(); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $sshPublicKey - * The SSH public key to sign. - * @type string $parent - * The parent project and region for the signing request. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\OsLogin\V1beta\SignSshPublicKeyResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function signSshPublicKey(array $optionalArgs = []) - { - $request = new SignSshPublicKeyRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['sshPublicKey'])) { - $request->setSshPublicKey($optionalArgs['sshPublicKey']); - } - - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['parent']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'SignSshPublicKey', - SignSshPublicKeyResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * - * Sample code: - * ``` - * $osLoginServiceClient = new OsLoginServiceClient(); - * try { - * $formattedName = $osLoginServiceClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - * $sshPublicKey = new SshPublicKey(); - * $response = $osLoginServiceClient->updateSshPublicKey($formattedName, $sshPublicKey); - * } finally { - * $osLoginServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param SshPublicKey $sshPublicKey Required. The SSH public key and expiration time. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Mask to control which fields get updated. Updates all if not present. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\OsLogin\Common\SshPublicKey - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function updateSshPublicKey( - $name, - $sshPublicKey, - array $optionalArgs = [] - ) { - $request = new UpdateSshPublicKeyRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setSshPublicKey($sshPublicKey); - $requestParamHeaders['name'] = $name; - 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( - 'UpdateSshPublicKey', - SshPublicKey::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/OsLogin/src/V1beta/GetLoginProfileRequest.php b/OsLogin/src/V1beta/GetLoginProfileRequest.php deleted file mode 100644 index 6bd3da68c97a..000000000000 --- a/OsLogin/src/V1beta/GetLoginProfileRequest.php +++ /dev/null @@ -1,169 +0,0 @@ -google.cloud.oslogin.v1beta.GetLoginProfileRequest - */ -class GetLoginProfileRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The unique ID for the user in format `users/{user}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - /** - * The project ID of the Google Cloud Platform project. - * - * Generated from protobuf field string project_id = 2; - */ - private $project_id = ''; - /** - * A system ID for filtering the results of the request. - * - * Generated from protobuf field string system_id = 3; - */ - private $system_id = ''; - /** - * The view configures whether to retrieve security keys information. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; - */ - private $view = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The unique ID for the user in format `users/{user}`. - * @type string $project_id - * The project ID of the Google Cloud Platform project. - * @type string $system_id - * A system ID for filtering the results of the request. - * @type int $view - * The view configures whether to retrieve security keys information. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Required. The unique ID for the user in format `users/{user}`. - * - * 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 unique ID for the user in format `users/{user}`. - * - * 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; - } - - /** - * The project ID of the Google Cloud Platform project. - * - * Generated from protobuf field string project_id = 2; - * @return string - */ - public function getProjectId() - { - return $this->project_id; - } - - /** - * The project ID of the Google Cloud Platform project. - * - * Generated from protobuf field string project_id = 2; - * @param string $var - * @return $this - */ - public function setProjectId($var) - { - GPBUtil::checkString($var, True); - $this->project_id = $var; - - return $this; - } - - /** - * A system ID for filtering the results of the request. - * - * Generated from protobuf field string system_id = 3; - * @return string - */ - public function getSystemId() - { - return $this->system_id; - } - - /** - * A system ID for filtering the results of the request. - * - * Generated from protobuf field string system_id = 3; - * @param string $var - * @return $this - */ - public function setSystemId($var) - { - GPBUtil::checkString($var, True); - $this->system_id = $var; - - return $this; - } - - /** - * The view configures whether to retrieve security keys information. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; - * @return int - */ - public function getView() - { - return $this->view; - } - - /** - * The view configures whether to retrieve security keys information. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; - * @param int $var - * @return $this - */ - public function setView($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\OsLogin\V1beta\LoginProfileView::class); - $this->view = $var; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/GetSshPublicKeyRequest.php b/OsLogin/src/V1beta/GetSshPublicKeyRequest.php deleted file mode 100644 index 65aee21854dd..000000000000 --- a/OsLogin/src/V1beta/GetSshPublicKeyRequest.php +++ /dev/null @@ -1,75 +0,0 @@ -google.cloud.oslogin.v1beta.GetSshPublicKeyRequest - */ -class GetSshPublicKeyRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Required. The fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * 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 fingerprint of the public key to retrieve. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * 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/OsLogin/src/V1beta/ImportSshPublicKeyRequest.php b/OsLogin/src/V1beta/ImportSshPublicKeyRequest.php deleted file mode 100644 index 63287b153178..000000000000 --- a/OsLogin/src/V1beta/ImportSshPublicKeyRequest.php +++ /dev/null @@ -1,221 +0,0 @@ -google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest - */ -class ImportSshPublicKeyRequest extends \Google\Protobuf\Internal\Message -{ - /** - * The unique ID for the user in format `users/{user}`. - * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { - */ - private $parent = ''; - /** - * Required. The SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $ssh_public_key = null; - /** - * The project ID of the Google Cloud Platform project. - * - * Generated from protobuf field string project_id = 3; - */ - private $project_id = ''; - /** - * The view configures whether to retrieve security keys information. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; - */ - private $view = 0; - /** - * Optional. The regions to which to assert that the key was written. - * If unspecified, defaults to all regions. - * Regions are listed at https://cloud.google.com/about/locations#region. - * - * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; - */ - private $regions; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * The unique ID for the user in format `users/{user}`. - * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key - * Required. The SSH public key and expiration time. - * @type string $project_id - * The project ID of the Google Cloud Platform project. - * @type int $view - * The view configures whether to retrieve security keys information. - * @type array|\Google\Protobuf\Internal\RepeatedField $regions - * Optional. The regions to which to assert that the key was written. - * If unspecified, defaults to all regions. - * Regions are listed at https://cloud.google.com/about/locations#region. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * The unique ID for the user in format `users/{user}`. - * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { - * @return string - */ - public function getParent() - { - return $this->parent; - } - - /** - * The unique ID for the user in format `users/{user}`. - * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setParent($var) - { - GPBUtil::checkString($var, True); - $this->parent = $var; - - return $this; - } - - /** - * Required. The SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null - */ - public function getSshPublicKey() - { - return $this->ssh_public_key; - } - - public function hasSshPublicKey() - { - return isset($this->ssh_public_key); - } - - public function clearSshPublicKey() - { - unset($this->ssh_public_key); - } - - /** - * Required. The SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var - * @return $this - */ - public function setSshPublicKey($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); - $this->ssh_public_key = $var; - - return $this; - } - - /** - * The project ID of the Google Cloud Platform project. - * - * Generated from protobuf field string project_id = 3; - * @return string - */ - public function getProjectId() - { - return $this->project_id; - } - - /** - * The project ID of the Google Cloud Platform project. - * - * Generated from protobuf field string project_id = 3; - * @param string $var - * @return $this - */ - public function setProjectId($var) - { - GPBUtil::checkString($var, True); - $this->project_id = $var; - - return $this; - } - - /** - * The view configures whether to retrieve security keys information. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; - * @return int - */ - public function getView() - { - return $this->view; - } - - /** - * The view configures whether to retrieve security keys information. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfileView view = 4; - * @param int $var - * @return $this - */ - public function setView($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\OsLogin\V1beta\LoginProfileView::class); - $this->view = $var; - - return $this; - } - - /** - * Optional. The regions to which to assert that the key was written. - * If unspecified, defaults to all regions. - * Regions are listed at https://cloud.google.com/about/locations#region. - * - * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getRegions() - { - return $this->regions; - } - - /** - * Optional. The regions to which to assert that the key was written. - * If unspecified, defaults to all regions. - * Regions are listed at https://cloud.google.com/about/locations#region. - * - * Generated from protobuf field repeated string regions = 5 [(.google.api.field_behavior) = OPTIONAL]; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setRegions($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->regions = $arr; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/ImportSshPublicKeyResponse.php b/OsLogin/src/V1beta/ImportSshPublicKeyResponse.php deleted file mode 100644 index 69f4e47016fd..000000000000 --- a/OsLogin/src/V1beta/ImportSshPublicKeyResponse.php +++ /dev/null @@ -1,111 +0,0 @@ -google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse - */ -class ImportSshPublicKeyResponse extends \Google\Protobuf\Internal\Message -{ - /** - * The login profile information for the user. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfile login_profile = 1; - */ - private $login_profile = null; - /** - * Detailed information about import results. - * - * Generated from protobuf field string details = 2; - */ - private $details = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\OsLogin\V1beta\LoginProfile $login_profile - * The login profile information for the user. - * @type string $details - * Detailed information about import results. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * The login profile information for the user. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfile login_profile = 1; - * @return \Google\Cloud\OsLogin\V1beta\LoginProfile|null - */ - public function getLoginProfile() - { - return $this->login_profile; - } - - public function hasLoginProfile() - { - return isset($this->login_profile); - } - - public function clearLoginProfile() - { - unset($this->login_profile); - } - - /** - * The login profile information for the user. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.LoginProfile login_profile = 1; - * @param \Google\Cloud\OsLogin\V1beta\LoginProfile $var - * @return $this - */ - public function setLoginProfile($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1beta\LoginProfile::class); - $this->login_profile = $var; - - return $this; - } - - /** - * Detailed information about import results. - * - * Generated from protobuf field string details = 2; - * @return string - */ - public function getDetails() - { - return $this->details; - } - - /** - * Detailed information about import results. - * - * Generated from protobuf field string details = 2; - * @param string $var - * @return $this - */ - public function setDetails($var) - { - GPBUtil::checkString($var, True); - $this->details = $var; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/LoginProfile.php b/OsLogin/src/V1beta/LoginProfile.php deleted file mode 100644 index 9d04ee97b37f..000000000000 --- a/OsLogin/src/V1beta/LoginProfile.php +++ /dev/null @@ -1,170 +0,0 @@ -google.cloud.oslogin.v1beta.LoginProfile - */ -class LoginProfile extends \Google\Protobuf\Internal\Message -{ - /** - * Required. A unique user ID. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; - */ - private $name = ''; - /** - * The list of POSIX accounts associated with the user. - * - * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; - */ - private $posix_accounts; - /** - * A map from SSH public key fingerprint to the associated key object. - * - * Generated from protobuf field map ssh_public_keys = 3; - */ - private $ssh_public_keys; - /** - * The registered security key credentials for a user. - * - * Generated from protobuf field repeated .google.cloud.oslogin.v1beta.SecurityKey security_keys = 5; - */ - private $security_keys; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. A unique user ID. - * @type array<\Google\Cloud\OsLogin\Common\PosixAccount>|\Google\Protobuf\Internal\RepeatedField $posix_accounts - * The list of POSIX accounts associated with the user. - * @type array|\Google\Protobuf\Internal\MapField $ssh_public_keys - * A map from SSH public key fingerprint to the associated key object. - * @type array<\Google\Cloud\OsLogin\V1beta\SecurityKey>|\Google\Protobuf\Internal\RepeatedField $security_keys - * The registered security key credentials for a user. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Required. A unique user ID. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Required. A unique user ID. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * The list of POSIX accounts associated with the user. - * - * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getPosixAccounts() - { - return $this->posix_accounts; - } - - /** - * The list of POSIX accounts associated with the user. - * - * Generated from protobuf field repeated .google.cloud.oslogin.common.PosixAccount posix_accounts = 2; - * @param array<\Google\Cloud\OsLogin\Common\PosixAccount>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setPosixAccounts($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\Common\PosixAccount::class); - $this->posix_accounts = $arr; - - return $this; - } - - /** - * A map from SSH public key fingerprint to the associated key object. - * - * Generated from protobuf field map ssh_public_keys = 3; - * @return \Google\Protobuf\Internal\MapField - */ - public function getSshPublicKeys() - { - return $this->ssh_public_keys; - } - - /** - * A map from SSH public key fingerprint to the associated key object. - * - * Generated from protobuf field map ssh_public_keys = 3; - * @param array|\Google\Protobuf\Internal\MapField $var - * @return $this - */ - public function setSshPublicKeys($var) - { - $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\Common\SshPublicKey::class); - $this->ssh_public_keys = $arr; - - return $this; - } - - /** - * The registered security key credentials for a user. - * - * Generated from protobuf field repeated .google.cloud.oslogin.v1beta.SecurityKey security_keys = 5; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getSecurityKeys() - { - return $this->security_keys; - } - - /** - * The registered security key credentials for a user. - * - * Generated from protobuf field repeated .google.cloud.oslogin.v1beta.SecurityKey security_keys = 5; - * @param array<\Google\Cloud\OsLogin\V1beta\SecurityKey>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setSecurityKeys($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\OsLogin\V1beta\SecurityKey::class); - $this->security_keys = $arr; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/LoginProfileView.php b/OsLogin/src/V1beta/LoginProfileView.php deleted file mode 100644 index 1de251f44127..000000000000 --- a/OsLogin/src/V1beta/LoginProfileView.php +++ /dev/null @@ -1,61 +0,0 @@ -google.cloud.oslogin.v1beta.LoginProfileView - */ -class LoginProfileView -{ - /** - * The default login profile view. The API defaults to the BASIC view. - * - * Generated from protobuf enum LOGIN_PROFILE_VIEW_UNSPECIFIED = 0; - */ - const LOGIN_PROFILE_VIEW_UNSPECIFIED = 0; - /** - * Includes POSIX and SSH key information. - * - * Generated from protobuf enum BASIC = 1; - */ - const BASIC = 1; - /** - * Include security key information for the user. - * - * Generated from protobuf enum SECURITY_KEY = 2; - */ - const SECURITY_KEY = 2; - - private static $valueToName = [ - self::LOGIN_PROFILE_VIEW_UNSPECIFIED => 'LOGIN_PROFILE_VIEW_UNSPECIFIED', - self::BASIC => 'BASIC', - self::SECURITY_KEY => 'SECURITY_KEY', - ]; - - 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/OsLogin/src/V1beta/OsLoginServiceClient.php b/OsLogin/src/V1beta/OsLoginServiceClient.php deleted file mode 100644 index 4834a782febd..000000000000 --- a/OsLogin/src/V1beta/OsLoginServiceClient.php +++ /dev/null @@ -1,36 +0,0 @@ -_simpleRequest('/google.cloud.oslogin.v1beta.OsLoginService/CreateSshPublicKey', - $argument, - ['\Google\Cloud\OsLogin\Common\SshPublicKey', 'decode'], - $metadata, $options); - } - - /** - * Deletes a POSIX account. - * @param \Google\Cloud\OsLogin\V1beta\DeletePosixAccountRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeletePosixAccount(\Google\Cloud\OsLogin\V1beta\DeletePosixAccountRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1beta.OsLoginService/DeletePosixAccount', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Deletes an SSH public key. - * @param \Google\Cloud\OsLogin\V1beta\DeleteSshPublicKeyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteSshPublicKey(\Google\Cloud\OsLogin\V1beta\DeleteSshPublicKeyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1beta.OsLoginService/DeleteSshPublicKey', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * @param \Google\Cloud\OsLogin\V1beta\GetLoginProfileRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetLoginProfile(\Google\Cloud\OsLogin\V1beta\GetLoginProfileRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1beta.OsLoginService/GetLoginProfile', - $argument, - ['\Google\Cloud\OsLogin\V1beta\LoginProfile', 'decode'], - $metadata, $options); - } - - /** - * Retrieves an SSH public key. - * @param \Google\Cloud\OsLogin\V1beta\GetSshPublicKeyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetSshPublicKey(\Google\Cloud\OsLogin\V1beta\GetSshPublicKeyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1beta.OsLoginService/GetSshPublicKey', - $argument, - ['\Google\Cloud\OsLogin\Common\SshPublicKey', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\OsLogin\V1beta\ImportSshPublicKeyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ImportSshPublicKey(\Google\Cloud\OsLogin\V1beta\ImportSshPublicKeyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1beta.OsLoginService/ImportSshPublicKey', - $argument, - ['\Google\Cloud\OsLogin\V1beta\ImportSshPublicKeyResponse', 'decode'], - $metadata, $options); - } - - /** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * @param \Google\Cloud\OsLogin\V1beta\UpdateSshPublicKeyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateSshPublicKey(\Google\Cloud\OsLogin\V1beta\UpdateSshPublicKeyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.oslogin.v1beta.OsLoginService/UpdateSshPublicKey', - $argument, - ['\Google\Cloud\OsLogin\Common\SshPublicKey', 'decode'], - $metadata, $options); - } - -} diff --git a/OsLogin/src/V1beta/README.md b/OsLogin/src/V1beta/README.md deleted file mode 100644 index 430af883fdee..000000000000 --- a/OsLogin/src/V1beta/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Google Cloud OsLogin V1beta generated client for PHP - -### Sample - -```php -require 'vendor/autoload.php'; - -use Google\Cloud\OsLogin\V1beta\OsLoginServiceClient; - -$osLoginServiceClient = new OsLoginServiceClient(); -$userId = '[MY_USER_ID]'; -$formattedName = $osLoginServiceClient->userName($userId); -$loginProfile = $osLoginServiceClient->getLoginProfile($formattedName); -``` diff --git a/OsLogin/src/V1beta/SecurityKey.php b/OsLogin/src/V1beta/SecurityKey.php deleted file mode 100644 index 3c142fe34602..000000000000 --- a/OsLogin/src/V1beta/SecurityKey.php +++ /dev/null @@ -1,224 +0,0 @@ -google.cloud.oslogin.v1beta.SecurityKey - */ -class SecurityKey extends \Google\Protobuf\Internal\Message -{ - /** - * Public key text in SSH format, defined by - * [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. - * - * Generated from protobuf field string public_key = 1; - */ - private $public_key = ''; - /** - * Hardware-backed private key text in SSH format. - * - * 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; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $public_key - * Public key text in SSH format, defined by - * [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. - * @type string $private_key - * Hardware-backed private key text in SSH format. - * @type \Google\Cloud\OsLogin\V1beta\UniversalTwoFactor $universal_two_factor - * 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) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Public key text in SSH format, defined by - * [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. - * - * Generated from protobuf field string public_key = 1; - * @return string - */ - public function getPublicKey() - { - return $this->public_key; - } - - /** - * Public key text in SSH format, defined by - * [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. - * - * Generated from protobuf field string public_key = 1; - * @param string $var - * @return $this - */ - public function setPublicKey($var) - { - GPBUtil::checkString($var, True); - $this->public_key = $var; - - return $this; - } - - /** - * Hardware-backed private key text in SSH format. - * - * Generated from protobuf field string private_key = 2; - * @return string - */ - public function getPrivateKey() - { - return $this->private_key; - } - - /** - * Hardware-backed private key text in SSH format. - * - * Generated from protobuf field string private_key = 2; - * @param string $var - * @return $this - */ - public function setPrivateKey($var) - { - GPBUtil::checkString($var, True); - $this->private_key = $var; - - return $this; - } - - /** - * The U2F protocol type. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.UniversalTwoFactor universal_two_factor = 3; - * @return \Google\Cloud\OsLogin\V1beta\UniversalTwoFactor|null - */ - public function getUniversalTwoFactor() - { - return $this->readOneof(3); - } - - public function hasUniversalTwoFactor() - { - return $this->hasOneof(3); - } - - /** - * The U2F protocol type. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.UniversalTwoFactor universal_two_factor = 3; - * @param \Google\Cloud\OsLogin\V1beta\UniversalTwoFactor $var - * @return $this - */ - public function setUniversalTwoFactor($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1beta\UniversalTwoFactor::class); - $this->writeOneof(3, $var); - - return $this; - } - - /** - * The Web Authentication protocol type. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.WebAuthn web_authn = 4; - * @return \Google\Cloud\OsLogin\V1beta\WebAuthn|null - */ - public function getWebAuthn() - { - return $this->readOneof(4); - } - - public function hasWebAuthn() - { - return $this->hasOneof(4); - } - - /** - * The Web Authentication protocol type. - * - * Generated from protobuf field .google.cloud.oslogin.v1beta.WebAuthn web_authn = 4; - * @param \Google\Cloud\OsLogin\V1beta\WebAuthn $var - * @return $this - */ - public function setWebAuthn($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1beta\WebAuthn::class); - $this->writeOneof(4, $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 - */ - public function getProtocolType() - { - return $this->whichOneof("protocol_type"); - } - -} - diff --git a/OsLogin/src/V1beta/SignSshPublicKeyRequest.php b/OsLogin/src/V1beta/SignSshPublicKeyRequest.php deleted file mode 100644 index 06c9cd386272..000000000000 --- a/OsLogin/src/V1beta/SignSshPublicKeyRequest.php +++ /dev/null @@ -1,111 +0,0 @@ -google.cloud.oslogin.v1beta.SignSshPublicKeyRequest - */ -class SignSshPublicKeyRequest extends \Google\Protobuf\Internal\Message -{ - /** - * The SSH public key to sign. - * - * Generated from protobuf field string ssh_public_key = 1; - */ - private $ssh_public_key = ''; - /** - * The parent project and zone for the signing request. This is needed to - * properly ensure per-organization ISS processing and potentially to provide - * for the possibility of zone-specific certificates used in the signing - * process. - * - * Generated from protobuf field string parent = 2; - */ - private $parent = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $ssh_public_key - * The SSH public key to sign. - * @type string $parent - * The parent project and zone for the signing request. This is needed to - * properly ensure per-organization ISS processing and potentially to provide - * for the possibility of zone-specific certificates used in the signing - * process. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * The SSH public key to sign. - * - * Generated from protobuf field string ssh_public_key = 1; - * @return string - */ - public function getSshPublicKey() - { - return $this->ssh_public_key; - } - - /** - * The SSH public key to sign. - * - * Generated from protobuf field string ssh_public_key = 1; - * @param string $var - * @return $this - */ - public function setSshPublicKey($var) - { - GPBUtil::checkString($var, True); - $this->ssh_public_key = $var; - - return $this; - } - - /** - * The parent project and zone for the signing request. This is needed to - * properly ensure per-organization ISS processing and potentially to provide - * for the possibility of zone-specific certificates used in the signing - * process. - * - * Generated from protobuf field string parent = 2; - * @return string - */ - public function getParent() - { - return $this->parent; - } - - /** - * The parent project and zone for the signing request. This is needed to - * properly ensure per-organization ISS processing and potentially to provide - * for the possibility of zone-specific certificates used in the signing - * process. - * - * Generated from protobuf field string parent = 2; - * @param string $var - * @return $this - */ - public function setParent($var) - { - GPBUtil::checkString($var, True); - $this->parent = $var; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/SignSshPublicKeyResponse.php b/OsLogin/src/V1beta/SignSshPublicKeyResponse.php deleted file mode 100644 index 6979858841e7..000000000000 --- a/OsLogin/src/V1beta/SignSshPublicKeyResponse.php +++ /dev/null @@ -1,65 +0,0 @@ -google.cloud.oslogin.v1beta.SignSshPublicKeyResponse - */ -class SignSshPublicKeyResponse extends \Google\Protobuf\Internal\Message -{ - /** - * The signed SSH public key to use in the SSH handshake. - * - * Generated from protobuf field string signed_ssh_public_key = 1; - */ - private $signed_ssh_public_key = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $signed_ssh_public_key - * The signed SSH public key to use in the SSH handshake. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * The signed SSH public key to use in the SSH handshake. - * - * Generated from protobuf field string signed_ssh_public_key = 1; - * @return string - */ - public function getSignedSshPublicKey() - { - return $this->signed_ssh_public_key; - } - - /** - * The signed SSH public key to use in the SSH handshake. - * - * Generated from protobuf field string signed_ssh_public_key = 1; - * @param string $var - * @return $this - */ - public function setSignedSshPublicKey($var) - { - GPBUtil::checkString($var, True); - $this->signed_ssh_public_key = $var; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/UniversalTwoFactor.php b/OsLogin/src/V1beta/UniversalTwoFactor.php deleted file mode 100644 index 41de562f90b0..000000000000 --- a/OsLogin/src/V1beta/UniversalTwoFactor.php +++ /dev/null @@ -1,67 +0,0 @@ -google.cloud.oslogin.v1beta.UniversalTwoFactor - */ -class UniversalTwoFactor extends \Google\Protobuf\Internal\Message -{ - /** - * Application ID for the U2F protocol. - * - * Generated from protobuf field string app_id = 1; - */ - private $app_id = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $app_id - * Application ID for the U2F protocol. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Application ID for the U2F protocol. - * - * Generated from protobuf field string app_id = 1; - * @return string - */ - public function getAppId() - { - return $this->app_id; - } - - /** - * Application ID for the U2F protocol. - * - * Generated from protobuf field string app_id = 1; - * @param string $var - * @return $this - */ - public function setAppId($var) - { - GPBUtil::checkString($var, True); - $this->app_id = $var; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/UpdateSshPublicKeyRequest.php b/OsLogin/src/V1beta/UpdateSshPublicKeyRequest.php deleted file mode 100644 index 93f4b135e033..000000000000 --- a/OsLogin/src/V1beta/UpdateSshPublicKeyRequest.php +++ /dev/null @@ -1,163 +0,0 @@ -google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest - */ -class UpdateSshPublicKeyRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - private $name = ''; - /** - * Required. The SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - private $ssh_public_key = null; - /** - * Mask to control which fields get updated. Updates all if not present. - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; - */ - private $update_mask = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * @type \Google\Cloud\OsLogin\Common\SshPublicKey $ssh_public_key - * Required. The SSH public key and expiration time. - * @type \Google\Protobuf\FieldMask $update_mask - * Mask to control which fields get updated. Updates all if not present. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Required. The fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * 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 fingerprint of the public key to update. Public keys are - * identified by their SHA-256 fingerprint. The fingerprint of the public key - * is in format `users/{user}/sshPublicKeys/{fingerprint}`. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * Required. The SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\OsLogin\Common\SshPublicKey|null - */ - public function getSshPublicKey() - { - return $this->ssh_public_key; - } - - public function hasSshPublicKey() - { - return isset($this->ssh_public_key); - } - - public function clearSshPublicKey() - { - unset($this->ssh_public_key); - } - - /** - * Required. The SSH public key and expiration time. - * - * Generated from protobuf field .google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(.google.api.field_behavior) = REQUIRED]; - * @param \Google\Cloud\OsLogin\Common\SshPublicKey $var - * @return $this - */ - public function setSshPublicKey($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\Common\SshPublicKey::class); - $this->ssh_public_key = $var; - - return $this; - } - - /** - * Mask to control which fields get updated. Updates all if not present. - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; - * @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); - } - - /** - * Mask to control which fields get updated. Updates all if not present. - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; - * @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/OsLogin/src/V1beta/WebAuthn.php b/OsLogin/src/V1beta/WebAuthn.php deleted file mode 100644 index 32b9b9f942eb..000000000000 --- a/OsLogin/src/V1beta/WebAuthn.php +++ /dev/null @@ -1,67 +0,0 @@ -google.cloud.oslogin.v1beta.WebAuthn - */ -class WebAuthn extends \Google\Protobuf\Internal\Message -{ - /** - * Relying party ID for Web Authentication. - * - * Generated from protobuf field string rp_id = 1; - */ - private $rp_id = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $rp_id - * Relying party ID for Web Authentication. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Oslogin\V1Beta\Oslogin::initOnce(); - parent::__construct($data); - } - - /** - * Relying party ID for Web Authentication. - * - * Generated from protobuf field string rp_id = 1; - * @return string - */ - public function getRpId() - { - return $this->rp_id; - } - - /** - * Relying party ID for Web Authentication. - * - * Generated from protobuf field string rp_id = 1; - * @param string $var - * @return $this - */ - public function setRpId($var) - { - GPBUtil::checkString($var, True); - $this->rp_id = $var; - - return $this; - } - -} - diff --git a/OsLogin/src/V1beta/gapic_metadata.json b/OsLogin/src/V1beta/gapic_metadata.json deleted file mode 100644 index d8b9952004f3..000000000000 --- a/OsLogin/src/V1beta/gapic_metadata.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", - "language": "php", - "protoPackage": "google.cloud.oslogin.v1beta", - "libraryPackage": "Google\\Cloud\\OsLogin\\V1beta", - "services": { - "OsLoginService": { - "clients": { - "grpc": { - "libraryClient": "OsLoginServiceGapicClient", - "rpcs": { - "CreateSshPublicKey": { - "methods": [ - "createSshPublicKey" - ] - }, - "DeletePosixAccount": { - "methods": [ - "deletePosixAccount" - ] - }, - "DeleteSshPublicKey": { - "methods": [ - "deleteSshPublicKey" - ] - }, - "GetLoginProfile": { - "methods": [ - "getLoginProfile" - ] - }, - "GetSshPublicKey": { - "methods": [ - "getSshPublicKey" - ] - }, - "ImportSshPublicKey": { - "methods": [ - "importSshPublicKey" - ] - }, - "SignSshPublicKey": { - "methods": [ - "signSshPublicKey" - ] - }, - "UpdateSshPublicKey": { - "methods": [ - "updateSshPublicKey" - ] - } - } - } - } - } - } -} \ No newline at end of file diff --git a/OsLogin/src/V1beta/resources/os_login_service_client_config.json b/OsLogin/src/V1beta/resources/os_login_service_client_config.json deleted file mode 100644 index cf4821b36489..000000000000 --- a/OsLogin/src/V1beta/resources/os_login_service_client_config.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "interfaces": { - "google.cloud.oslogin.v1beta.OsLoginService": { - "retry_codes": { - "no_retry_codes": [], - "retry_policy_1_codes": [ - "UNAVAILABLE", - "DEADLINE_EXCEEDED" - ] - }, - "retry_params": { - "no_retry_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 0, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 0, - "total_timeout_millis": 0 - }, - "retry_policy_1_params": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 10000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 10000, - "total_timeout_millis": 10000 - } - }, - "methods": { - "CreateSshPublicKey": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "DeletePosixAccount": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "DeleteSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "GetLoginProfile": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "GetSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "ImportSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "SignSshPublicKey": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "UpdateSshPublicKey": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - } - } - } - } -} diff --git a/OsLogin/src/V1beta/resources/os_login_service_descriptor_config.php b/OsLogin/src/V1beta/resources/os_login_service_descriptor_config.php deleted file mode 100644 index e2f37e277e85..000000000000 --- a/OsLogin/src/V1beta/resources/os_login_service_descriptor_config.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - 'google.cloud.oslogin.v1beta.OsLoginService' => [], - ], -]; 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 deleted file mode 100644 index e207013235f5..000000000000 --- a/OsLogin/src/V1beta/resources/os_login_service_rest_client_config.php +++ /dev/null @@ -1,128 +0,0 @@ - [ - 'google.cloud.oslogin.v1beta.OsLoginService' => [ - 'CreateSshPublicKey' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta/{parent=users/*}/sshPublicKeys', - 'body' => 'ssh_public_key', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'DeletePosixAccount' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta/{name=users/*/projects/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'DeleteSshPublicKey' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'GetLoginProfile' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta/{name=users/*}/loginProfile', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'GetSshPublicKey' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ImportSshPublicKey' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta/{parent=users/*}:importSshPublicKey', - 'body' => 'ssh_public_key', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'SignSshPublicKey' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta/{parent=users/*/projects/*/zones/*}:signSshPublicKey', - 'body' => '*', - 'additionalBindings' => [ - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta/{parent=users/*/projects/*/locations/*}:signSshPublicKey', - 'body' => '*', - ], - ], - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'UpdateSshPublicKey' => [ - 'method' => 'patch', - 'uriTemplate' => '/v1beta/{name=users/*/sshPublicKeys/*}', - 'body' => 'ssh_public_key', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - ], - ], - 'numericEnums' => true, -]; diff --git a/OsLogin/tests/System/V1/OsLoginServiceClientTest.php b/OsLogin/tests/System/V1/OsLoginServiceClientTest.php deleted file mode 100644 index e12f751cb04f..000000000000 --- a/OsLogin/tests/System/V1/OsLoginServiceClientTest.php +++ /dev/null @@ -1,77 +0,0 @@ - $keyFilePath, - 'transport' => 'rest' - ]); - - self::$grpcClient = new OsLoginServiceClient([ - 'credentials' => $keyFilePath, - 'transport' => 'grpc' - ]); - - self::$clientEmail = $keyFileData['client_email']; - - self::$hasSetUp = true; - } - - /** - * @dataProvider clientProvider - */ - public function testListOperations(OsLoginServiceClient $client) - { - $response = $client->getLoginProfile( - $client->userName(self::$clientEmail) - ); - - $this->assertInstanceOf(LoginProfile::class, $response); - } -} diff --git a/OsLogin/tests/System/V1beta/OsLoginServiceClientTest.php b/OsLogin/tests/System/V1beta/OsLoginServiceClientTest.php deleted file mode 100644 index 0026e528fea0..000000000000 --- a/OsLogin/tests/System/V1beta/OsLoginServiceClientTest.php +++ /dev/null @@ -1,77 +0,0 @@ - $keyFilePath, - 'transport' => 'rest' - ]); - - self::$grpcClient = new OsLoginServiceClient([ - 'credentials' => $keyFilePath, - 'transport' => 'grpc' - ]); - - self::$clientEmail = $keyFileData['client_email']; - - self::$hasSetUp = true; - } - - /** - * @dataProvider clientProvider - */ - public function testListOperations(OsLoginServiceClient $client) - { - $response = $client->getLoginProfile( - $client->userName(self::$clientEmail) - ); - - $this->assertInstanceOf(LoginProfile::class, $response); - } -} diff --git a/OsLogin/tests/System/bootstrap.php b/OsLogin/tests/System/bootstrap.php deleted file mode 100644 index 30d98dd46349..000000000000 --- a/OsLogin/tests/System/bootstrap.php +++ /dev/null @@ -1,10 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return OsLoginServiceClient */ @@ -91,9 +93,7 @@ public function createSshPublicKeyTest() // Mock request $formattedParent = $gapicClient->userName('[USER]'); $sshPublicKey = new SshPublicKey(); - $request = (new CreateSshPublicKeyRequest()) - ->setParent($formattedParent) - ->setSshPublicKey($sshPublicKey); + $request = (new CreateSshPublicKeyRequest())->setParent($formattedParent)->setSshPublicKey($sshPublicKey); $response = $gapicClient->createSshPublicKey($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -119,19 +119,20 @@ public function createSshPublicKeyExceptionTest() $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); + $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->userName('[USER]'); $sshPublicKey = new SshPublicKey(); - $request = (new CreateSshPublicKeyRequest()) - ->setParent($formattedParent) - ->setSshPublicKey($sshPublicKey); + $request = (new CreateSshPublicKeyRequest())->setParent($formattedParent)->setSshPublicKey($sshPublicKey); try { $gapicClient->createSshPublicKey($request); // If the $gapicClient method call did not throw, fail the test @@ -158,8 +159,7 @@ public function deletePosixAccountTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->posixAccountName('[USER]', '[PROJECT]'); - $request = (new DeletePosixAccountRequest()) - ->setName($formattedName); + $request = (new DeletePosixAccountRequest())->setName($formattedName); $gapicClient->deletePosixAccount($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -182,17 +182,19 @@ public function deletePosixAccountExceptionTest() $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); + $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->posixAccountName('[USER]', '[PROJECT]'); - $request = (new DeletePosixAccountRequest()) - ->setName($formattedName); + $request = (new DeletePosixAccountRequest())->setName($formattedName); try { $gapicClient->deletePosixAccount($request); // If the $gapicClient method call did not throw, fail the test @@ -219,8 +221,7 @@ public function deleteSshPublicKeyTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $request = (new DeleteSshPublicKeyRequest()) - ->setName($formattedName); + $request = (new DeleteSshPublicKeyRequest())->setName($formattedName); $gapicClient->deleteSshPublicKey($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -243,17 +244,19 @@ public function deleteSshPublicKeyExceptionTest() $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); + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $request = (new DeleteSshPublicKeyRequest()) - ->setName($formattedName); + $request = (new DeleteSshPublicKeyRequest())->setName($formattedName); try { $gapicClient->deleteSshPublicKey($request); // If the $gapicClient method call did not throw, fail the test @@ -282,8 +285,7 @@ public function getLoginProfileTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->userName('[USER]'); - $request = (new GetLoginProfileRequest()) - ->setName($formattedName); + $request = (new GetLoginProfileRequest())->setName($formattedName); $response = $gapicClient->getLoginProfile($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -307,17 +309,19 @@ public function getLoginProfileExceptionTest() $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); + $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->userName('[USER]'); - $request = (new GetLoginProfileRequest()) - ->setName($formattedName); + $request = (new GetLoginProfileRequest())->setName($formattedName); try { $gapicClient->getLoginProfile($request); // If the $gapicClient method call did not throw, fail the test @@ -352,8 +356,7 @@ public function getSshPublicKeyTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $request = (new GetSshPublicKeyRequest()) - ->setName($formattedName); + $request = (new GetSshPublicKeyRequest())->setName($formattedName); $response = $gapicClient->getSshPublicKey($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -377,17 +380,19 @@ public function getSshPublicKeyExceptionTest() $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); + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $request = (new GetSshPublicKeyRequest()) - ->setName($formattedName); + $request = (new GetSshPublicKeyRequest())->setName($formattedName); try { $gapicClient->getSshPublicKey($request); // If the $gapicClient method call did not throw, fail the test @@ -416,8 +421,7 @@ public function importSshPublicKeyTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->userName('[USER]'); - $request = (new ImportSshPublicKeyRequest()) - ->setParent($formattedParent); + $request = (new ImportSshPublicKeyRequest())->setParent($formattedParent); $response = $gapicClient->importSshPublicKey($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -441,17 +445,19 @@ public function importSshPublicKeyExceptionTest() $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); + $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->userName('[USER]'); - $request = (new ImportSshPublicKeyRequest()) - ->setParent($formattedParent); + $request = (new ImportSshPublicKeyRequest())->setParent($formattedParent); try { $gapicClient->importSshPublicKey($request); // If the $gapicClient method call did not throw, fail the test @@ -487,9 +493,7 @@ public function updateSshPublicKeyTest() // Mock request $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); $sshPublicKey = new SshPublicKey(); - $request = (new UpdateSshPublicKeyRequest()) - ->setName($formattedName) - ->setSshPublicKey($sshPublicKey); + $request = (new UpdateSshPublicKeyRequest())->setName($formattedName)->setSshPublicKey($sshPublicKey); $response = $gapicClient->updateSshPublicKey($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -515,19 +519,20 @@ public function updateSshPublicKeyExceptionTest() $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); + $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); $sshPublicKey = new SshPublicKey(); - $request = (new UpdateSshPublicKeyRequest()) - ->setName($formattedName) - ->setSshPublicKey($sshPublicKey); + $request = (new UpdateSshPublicKeyRequest())->setName($formattedName)->setSshPublicKey($sshPublicKey); try { $gapicClient->updateSshPublicKey($request); // If the $gapicClient method call did not throw, fail the test @@ -563,9 +568,7 @@ public function createSshPublicKeyAsyncTest() // Mock request $formattedParent = $gapicClient->userName('[USER]'); $sshPublicKey = new SshPublicKey(); - $request = (new CreateSshPublicKeyRequest()) - ->setParent($formattedParent) - ->setSshPublicKey($sshPublicKey); + $request = (new CreateSshPublicKeyRequest())->setParent($formattedParent)->setSshPublicKey($sshPublicKey); $response = $gapicClient->createSshPublicKeyAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); diff --git a/OsLogin/tests/Unit/V1/OsLoginServiceClientTest.php b/OsLogin/tests/Unit/V1/OsLoginServiceClientTest.php deleted file mode 100644 index 8bc98362385f..000000000000 --- a/OsLogin/tests/Unit/V1/OsLoginServiceClientTest.php +++ /dev/null @@ -1,504 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return OsLoginServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new OsLoginServiceClient($options); - } - - /** @test */ - public function createSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $key = 'key106079'; - $expirationTimeUsec = 2058878882; - $fingerprint = 'fingerprint-1375934236'; - $name = 'name3373707'; - $expectedResponse = new SshPublicKey(); - $expectedResponse->setKey($key); - $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); - $expectedResponse->setFingerprint($fingerprint); - $expectedResponse->setName($name); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->userName('[USER]'); - $sshPublicKey = new SshPublicKey(); - $response = $gapicClient->createSshPublicKey($formattedParent, $sshPublicKey); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getSshPublicKey(); - $this->assertProtobufEquals($sshPublicKey, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createSshPublicKeyExceptionTest() - { - $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->userName('[USER]'); - $sshPublicKey = new SshPublicKey(); - try { - $gapicClient->createSshPublicKey($formattedParent, $sshPublicKey); - // 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 deletePosixAccountTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->posixAccountName('[USER]', '[PROJECT]'); - $gapicClient->deletePosixAccount($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/DeletePosixAccount', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deletePosixAccountExceptionTest() - { - $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->posixAccountName('[USER]', '[PROJECT]'); - try { - $gapicClient->deletePosixAccount($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 deleteSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $gapicClient->deleteSshPublicKey($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/DeleteSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteSshPublicKeyExceptionTest() - { - $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - try { - $gapicClient->deleteSshPublicKey($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 getLoginProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $expectedResponse = new LoginProfile(); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->userName('[USER]'); - $response = $gapicClient->getLoginProfile($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.oslogin.v1.OsLoginService/GetLoginProfile', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLoginProfileExceptionTest() - { - $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->userName('[USER]'); - try { - $gapicClient->getLoginProfile($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 getSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $key = 'key106079'; - $expirationTimeUsec = 2058878882; - $fingerprint = 'fingerprint-1375934236'; - $name2 = 'name2-1052831874'; - $expectedResponse = new SshPublicKey(); - $expectedResponse->setKey($key); - $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); - $expectedResponse->setFingerprint($fingerprint); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $response = $gapicClient->getSshPublicKey($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.oslogin.v1.OsLoginService/GetSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getSshPublicKeyExceptionTest() - { - $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - try { - $gapicClient->getSshPublicKey($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 importSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $details = 'details1557721666'; - $expectedResponse = new ImportSshPublicKeyResponse(); - $expectedResponse->setDetails($details); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->userName('[USER]'); - $response = $gapicClient->importSshPublicKey($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/ImportSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function importSshPublicKeyExceptionTest() - { - $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->userName('[USER]'); - try { - $gapicClient->importSshPublicKey($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 updateSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $key = 'key106079'; - $expirationTimeUsec = 2058878882; - $fingerprint = 'fingerprint-1375934236'; - $name2 = 'name2-1052831874'; - $expectedResponse = new SshPublicKey(); - $expectedResponse->setKey($key); - $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); - $expectedResponse->setFingerprint($fingerprint); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $sshPublicKey = new SshPublicKey(); - $response = $gapicClient->updateSshPublicKey($formattedName, $sshPublicKey); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1.OsLoginService/UpdateSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getSshPublicKey(); - $this->assertProtobufEquals($sshPublicKey, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateSshPublicKeyExceptionTest() - { - $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $sshPublicKey = new SshPublicKey(); - try { - $gapicClient->updateSshPublicKey($formattedName, $sshPublicKey); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/OsLogin/tests/Unit/V1beta/OsLoginServiceClientTest.php b/OsLogin/tests/Unit/V1beta/OsLoginServiceClientTest.php deleted file mode 100644 index 706232d4e349..000000000000 --- a/OsLogin/tests/Unit/V1beta/OsLoginServiceClientTest.php +++ /dev/null @@ -1,559 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return OsLoginServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new OsLoginServiceClient($options); - } - - /** @test */ - public function createSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $key = 'key106079'; - $expirationTimeUsec = 2058878882; - $fingerprint = 'fingerprint-1375934236'; - $name = 'name3373707'; - $expectedResponse = new SshPublicKey(); - $expectedResponse->setKey($key); - $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); - $expectedResponse->setFingerprint($fingerprint); - $expectedResponse->setName($name); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->userName('[USER]'); - $sshPublicKey = new SshPublicKey(); - $response = $gapicClient->createSshPublicKey($formattedParent, $sshPublicKey); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/CreateSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getSshPublicKey(); - $this->assertProtobufEquals($sshPublicKey, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createSshPublicKeyExceptionTest() - { - $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->userName('[USER]'); - $sshPublicKey = new SshPublicKey(); - try { - $gapicClient->createSshPublicKey($formattedParent, $sshPublicKey); - // 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 deletePosixAccountTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->posixAccountName('[USER]', '[PROJECT]'); - $gapicClient->deletePosixAccount($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/DeletePosixAccount', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deletePosixAccountExceptionTest() - { - $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->posixAccountName('[USER]', '[PROJECT]'); - try { - $gapicClient->deletePosixAccount($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 deleteSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $gapicClient->deleteSshPublicKey($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/DeleteSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteSshPublicKeyExceptionTest() - { - $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - try { - $gapicClient->deleteSshPublicKey($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 getLoginProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $expectedResponse = new LoginProfile(); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->userName('[USER]'); - $response = $gapicClient->getLoginProfile($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.oslogin.v1beta.OsLoginService/GetLoginProfile', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLoginProfileExceptionTest() - { - $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->userName('[USER]'); - try { - $gapicClient->getLoginProfile($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 getSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $key = 'key106079'; - $expirationTimeUsec = 2058878882; - $fingerprint = 'fingerprint-1375934236'; - $name2 = 'name2-1052831874'; - $expectedResponse = new SshPublicKey(); - $expectedResponse->setKey($key); - $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); - $expectedResponse->setFingerprint($fingerprint); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $response = $gapicClient->getSshPublicKey($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.oslogin.v1beta.OsLoginService/GetSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getSshPublicKeyExceptionTest() - { - $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - try { - $gapicClient->getSshPublicKey($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 importSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $details = 'details1557721666'; - $expectedResponse = new ImportSshPublicKeyResponse(); - $expectedResponse->setDetails($details); - $transport->addResponse($expectedResponse); - // Mock request - $sshPublicKey = new SshPublicKey(); - $response = $gapicClient->importSshPublicKey($sshPublicKey); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/ImportSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getSshPublicKey(); - $this->assertProtobufEquals($sshPublicKey, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function importSshPublicKeyExceptionTest() - { - $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 - $sshPublicKey = new SshPublicKey(); - try { - $gapicClient->importSshPublicKey($sshPublicKey); - // 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 signSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $signedSshPublicKey = 'signedSshPublicKey-1764783709'; - $expectedResponse = new SignSshPublicKeyResponse(); - $expectedResponse->setSignedSshPublicKey($signedSshPublicKey); - $transport->addResponse($expectedResponse); - $response = $gapicClient->signSshPublicKey(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/SignSshPublicKey', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function signSshPublicKeyExceptionTest() - { - $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); - try { - $gapicClient->signSshPublicKey(); - // 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 updateSshPublicKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $key = 'key106079'; - $expirationTimeUsec = 2058878882; - $fingerprint = 'fingerprint-1375934236'; - $name2 = 'name2-1052831874'; - $expectedResponse = new SshPublicKey(); - $expectedResponse->setKey($key); - $expectedResponse->setExpirationTimeUsec($expirationTimeUsec); - $expectedResponse->setFingerprint($fingerprint); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $sshPublicKey = new SshPublicKey(); - $response = $gapicClient->updateSshPublicKey($formattedName, $sshPublicKey); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.oslogin.v1beta.OsLoginService/UpdateSshPublicKey', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getSshPublicKey(); - $this->assertProtobufEquals($sshPublicKey, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateSshPublicKeyExceptionTest() - { - $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->sshPublicKeyName('[USER]', '[FINGERPRINT]'); - $sshPublicKey = new SshPublicKey(); - try { - $gapicClient->updateSshPublicKey($formattedName, $sshPublicKey); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/PolicyTroubleshooter/owlbot.py b/PolicyTroubleshooter/owlbot.py index 86042536d6cb..55601ab58a40 100644 --- a/PolicyTroubleshooter/owlbot.py +++ b/PolicyTroubleshooter/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,28 +41,16 @@ + "\n", '') -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/PolicyTroubleshooter/src/V1/AccessTuple.php b/PolicyTroubleshooter/src/V1/AccessTuple.php index 3f8ac1aabc53..6a94ba29e536 100644 --- a/PolicyTroubleshooter/src/V1/AccessTuple.php +++ b/PolicyTroubleshooter/src/V1/AccessTuple.php @@ -25,7 +25,7 @@ class AccessTuple extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string principal = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $principal = ''; + protected $principal = ''; /** * Required. The full resource name that identifies the resource. For example, * `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. @@ -34,7 +34,7 @@ class AccessTuple extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string full_resource_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $full_resource_name = ''; + protected $full_resource_name = ''; /** * Required. The IAM permission to check for the specified principal and * resource. @@ -45,7 +45,7 @@ class AccessTuple extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string permission = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $permission = ''; + protected $permission = ''; /** * Constructor. diff --git a/PolicyTroubleshooter/src/V1/BindingExplanation.php b/PolicyTroubleshooter/src/V1/BindingExplanation.php index 0edba341f82a..0ed308060ee7 100644 --- a/PolicyTroubleshooter/src/V1/BindingExplanation.php +++ b/PolicyTroubleshooter/src/V1/BindingExplanation.php @@ -27,7 +27,7 @@ class BindingExplanation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.AccessState access = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $access = 0; + protected $access = 0; /** * The role that this binding grants. For example, * `roles/compute.serviceAgent`. @@ -36,21 +36,21 @@ class BindingExplanation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string role = 2; */ - private $role = ''; + protected $role = ''; /** * Indicates whether the role granted by this binding contains the specified * permission. * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.BindingExplanation.RolePermission role_permission = 3; */ - private $role_permission = 0; + protected $role_permission = 0; /** * The relevance of the permission's existence, or nonexistence, in the role * to the overall determination for the entire policy. * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.HeuristicRelevance role_permission_relevance = 4; */ - private $role_permission_relevance = 0; + protected $role_permission_relevance = 0; /** * Indicates whether each principal in the binding includes the principal * specified in the request, either directly or indirectly. Each key @@ -77,7 +77,7 @@ class BindingExplanation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.HeuristicRelevance relevance = 6; */ - private $relevance = 0; + protected $relevance = 0; /** * A condition expression that prevents this binding from granting access * unless the expression evaluates to `true`. @@ -86,7 +86,7 @@ class BindingExplanation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.type.Expr condition = 7; */ - private $condition = null; + protected $condition = null; /** * Constructor. diff --git a/PolicyTroubleshooter/src/V1/BindingExplanation/AnnotatedMembership.php b/PolicyTroubleshooter/src/V1/BindingExplanation/AnnotatedMembership.php index cf058fdce3b5..99aa840ab0c7 100644 --- a/PolicyTroubleshooter/src/V1/BindingExplanation/AnnotatedMembership.php +++ b/PolicyTroubleshooter/src/V1/BindingExplanation/AnnotatedMembership.php @@ -20,14 +20,14 @@ class AnnotatedMembership extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.BindingExplanation.Membership membership = 1; */ - private $membership = 0; + protected $membership = 0; /** * The relevance of the principal's status to the overall determination for * the binding. * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.HeuristicRelevance relevance = 2; */ - private $relevance = 0; + protected $relevance = 0; /** * Constructor. diff --git a/PolicyTroubleshooter/src/V1/Client/IamCheckerClient.php b/PolicyTroubleshooter/src/V1/Client/IamCheckerClient.php index 5aebad398181..4efb3aee4a27 100644 --- a/PolicyTroubleshooter/src/V1/Client/IamCheckerClient.php +++ b/PolicyTroubleshooter/src/V1/Client/IamCheckerClient.php @@ -1,6 +1,6 @@ startApiCall('TroubleshootIamPolicy', $request, $callOptions)->wait(); } } diff --git a/PolicyTroubleshooter/src/V1/ExplainedPolicy.php b/PolicyTroubleshooter/src/V1/ExplainedPolicy.php index 1a05ee3ec6f5..825e85a27a26 100644 --- a/PolicyTroubleshooter/src/V1/ExplainedPolicy.php +++ b/PolicyTroubleshooter/src/V1/ExplainedPolicy.php @@ -27,7 +27,7 @@ class ExplainedPolicy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.AccessState access = 1; */ - private $access = 0; + protected $access = 0; /** * The full resource name that identifies the resource. For example, * `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`. @@ -38,7 +38,7 @@ class ExplainedPolicy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string full_resource_name = 2; */ - private $full_resource_name = ''; + protected $full_resource_name = ''; /** * The IAM policy attached to the resource. * If the sender of the request does not have access to the policy, this field @@ -46,7 +46,7 @@ class ExplainedPolicy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.iam.v1.Policy policy = 3; */ - private $policy = null; + protected $policy = null; /** * Details about how each binding in the policy affects the principal's * ability, or inability, to use the permission for the resource. @@ -64,7 +64,7 @@ class ExplainedPolicy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.HeuristicRelevance relevance = 5; */ - private $relevance = 0; + protected $relevance = 0; /** * Constructor. diff --git a/PolicyTroubleshooter/src/V1/Gapic/IamCheckerGapicClient.php b/PolicyTroubleshooter/src/V1/Gapic/IamCheckerGapicClient.php deleted file mode 100644 index d6b689899276..000000000000 --- a/PolicyTroubleshooter/src/V1/Gapic/IamCheckerGapicClient.php +++ /dev/null @@ -1,204 +0,0 @@ -troubleshootIamPolicy(); - * } finally { - * $iamCheckerClient->close(); - * } - * ``` - * - * @deprecated Please use the new service client {@see \Google\Cloud\PolicyTroubleshooter\V1\Client\IamCheckerClient}. - */ -class IamCheckerGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.policytroubleshooter.v1.IamChecker'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'policytroubleshooter.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'policytroubleshooter.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static 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); - } - - /** - * Checks whether a principal has a specific permission for a specific - * resource, and explains why the principal does or does not have that - * permission. - * - * Sample code: - * ``` - * $iamCheckerClient = new IamCheckerClient(); - * try { - * $response = $iamCheckerClient->troubleshootIamPolicy(); - * } finally { - * $iamCheckerClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type AccessTuple $accessTuple - * The information to use for checking whether a principal has a permission - * for a resource. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\PolicyTroubleshooter\V1\TroubleshootIamPolicyResponse - * - * @throws ApiException if the remote call fails - */ - public function troubleshootIamPolicy(array $optionalArgs = []) - { - $request = new TroubleshootIamPolicyRequest(); - if (isset($optionalArgs['accessTuple'])) { - $request->setAccessTuple($optionalArgs['accessTuple']); - } - - return $this->startCall('TroubleshootIamPolicy', TroubleshootIamPolicyResponse::class, $optionalArgs, $request)->wait(); - } -} diff --git a/PolicyTroubleshooter/src/V1/IamCheckerClient.php b/PolicyTroubleshooter/src/V1/IamCheckerClient.php deleted file mode 100644 index 2671f85c1829..000000000000 --- a/PolicyTroubleshooter/src/V1/IamCheckerClient.php +++ /dev/null @@ -1,34 +0,0 @@ -.google.cloud.policytroubleshooter.v1.AccessTuple access_tuple = 1; */ - private $access_tuple = null; + protected $access_tuple = null; /** * Constructor. diff --git a/PolicyTroubleshooter/src/V1/TroubleshootIamPolicyResponse.php b/PolicyTroubleshooter/src/V1/TroubleshootIamPolicyResponse.php index f3caada12d3a..a183021d594a 100644 --- a/PolicyTroubleshooter/src/V1/TroubleshootIamPolicyResponse.php +++ b/PolicyTroubleshooter/src/V1/TroubleshootIamPolicyResponse.php @@ -22,7 +22,7 @@ class TroubleshootIamPolicyResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.policytroubleshooter.v1.AccessState access = 1; */ - private $access = 0; + protected $access = 0; /** * List of IAM policies that were evaluated to check the principal's * permissions, with annotations to indicate how each policy contributed to diff --git a/PolicyTroubleshooter/tests/Unit/V1/Client/IamCheckerClientTest.php b/PolicyTroubleshooter/tests/Unit/V1/Client/IamCheckerClientTest.php index 45d32e6935a6..5e15b70cc321 100644 --- a/PolicyTroubleshooter/tests/Unit/V1/Client/IamCheckerClientTest.php +++ b/PolicyTroubleshooter/tests/Unit/V1/Client/IamCheckerClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return IamCheckerClient */ @@ -93,12 +95,15 @@ public function troubleshootIamPolicyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new TroubleshootIamPolicyRequest(); try { diff --git a/PolicyTroubleshooter/tests/Unit/V1/IamCheckerClientTest.php b/PolicyTroubleshooter/tests/Unit/V1/IamCheckerClientTest.php deleted file mode 100644 index 83b728d5dec9..000000000000 --- a/PolicyTroubleshooter/tests/Unit/V1/IamCheckerClientTest.php +++ /dev/null @@ -1,113 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return IamCheckerClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new IamCheckerClient($options); - } - - /** @test */ - public function troubleshootIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TroubleshootIamPolicyResponse(); - $transport->addResponse($expectedResponse); - $response = $gapicClient->troubleshootIamPolicy(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.policytroubleshooter.v1.IamChecker/TroubleshootIamPolicy', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function troubleshootIamPolicyExceptionTest() - { - $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); - try { - $gapicClient->troubleshootIamPolicy(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/Recommender/owlbot.py b/Recommender/owlbot.py index 1c33904e5568..ca33e0daa8ae 100644 --- a/Recommender/owlbot.py +++ b/Recommender/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2020 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,35 +32,25 @@ php.owlbot_main(src=src, dest=dest) - -# Change the wording for the deprecation warning. -s.replace( - 'src/*/*_*.php', - r'will be removed in the next major release', - 'will be removed in a future release') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links +# remove class_alias code s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) + "src/V*/**/*.php", + r"^// Adding a class alias for backwards compatibility with the previous class name.$" + + "\n" + + r"^class_alias\(.*\);$" + + "\n", + '') + +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/Recommender/src/V1/Client/RecommenderClient.php b/Recommender/src/V1/Client/RecommenderClient.php index 4bb25818f6ec..b17f951041fe 100644 --- a/Recommender/src/V1/Client/RecommenderClient.php +++ b/Recommender/src/V1/Client/RecommenderClient.php @@ -1,6 +1,6 @@ render([ 'billing_account' => $billingAccount, 'location' => $location, @@ -157,8 +158,11 @@ public static function billingAccountLocationInsightTypeName(string $billingAcco * * @return string The formatted billing_account_location_insight_type_config resource. */ - public static function billingAccountLocationInsightTypeConfigName(string $billingAccount, string $location, string $insightType): string - { + public static function billingAccountLocationInsightTypeConfigName( + string $billingAccount, + string $location, + string $insightType + ): string { return self::getPathTemplate('billingAccountLocationInsightTypeConfig')->render([ 'billing_account' => $billingAccount, 'location' => $location, @@ -177,8 +181,12 @@ public static function billingAccountLocationInsightTypeConfigName(string $billi * * @return string The formatted billing_account_location_insight_type_insight resource. */ - public static function billingAccountLocationInsightTypeInsightName(string $billingAccount, string $location, string $insightType, string $insight): string - { + public static function billingAccountLocationInsightTypeInsightName( + string $billingAccount, + string $location, + string $insightType, + string $insight + ): string { return self::getPathTemplate('billingAccountLocationInsightTypeInsight')->render([ 'billing_account' => $billingAccount, 'location' => $location, @@ -197,8 +205,11 @@ public static function billingAccountLocationInsightTypeInsightName(string $bill * * @return string The formatted billing_account_location_recommender resource. */ - public static function billingAccountLocationRecommenderName(string $billingAccount, string $location, string $recommender): string - { + public static function billingAccountLocationRecommenderName( + string $billingAccount, + string $location, + string $recommender + ): string { return self::getPathTemplate('billingAccountLocationRecommender')->render([ 'billing_account' => $billingAccount, 'location' => $location, @@ -216,8 +227,11 @@ public static function billingAccountLocationRecommenderName(string $billingAcco * * @return string The formatted billing_account_location_recommender_config resource. */ - public static function billingAccountLocationRecommenderConfigName(string $billingAccount, string $location, string $recommender): string - { + public static function billingAccountLocationRecommenderConfigName( + string $billingAccount, + string $location, + string $recommender + ): string { return self::getPathTemplate('billingAccountLocationRecommenderConfig')->render([ 'billing_account' => $billingAccount, 'location' => $location, @@ -236,8 +250,12 @@ public static function billingAccountLocationRecommenderConfigName(string $billi * * @return string The formatted billing_account_location_recommender_recommendation resource. */ - public static function billingAccountLocationRecommenderRecommendationName(string $billingAccount, string $location, string $recommender, string $recommendation): string - { + public static function billingAccountLocationRecommenderRecommendationName( + string $billingAccount, + string $location, + string $recommender, + string $recommendation + ): string { return self::getPathTemplate('billingAccountLocationRecommenderRecommendation')->render([ 'billing_account' => $billingAccount, 'location' => $location, @@ -276,8 +294,12 @@ public static function folderLocationInsightTypeName(string $folder, string $loc * * @return string The formatted folder_location_insight_type_insight resource. */ - public static function folderLocationInsightTypeInsightName(string $folder, string $location, string $insightType, string $insight): string - { + public static function folderLocationInsightTypeInsightName( + string $folder, + string $location, + string $insightType, + string $insight + ): string { return self::getPathTemplate('folderLocationInsightTypeInsight')->render([ 'folder' => $folder, 'location' => $location, @@ -316,8 +338,12 @@ public static function folderLocationRecommenderName(string $folder, string $loc * * @return string The formatted folder_location_recommender_recommendation resource. */ - public static function folderLocationRecommenderRecommendationName(string $folder, string $location, string $recommender, string $recommendation): string - { + public static function folderLocationRecommenderRecommendationName( + string $folder, + string $location, + string $recommender, + string $recommendation + ): string { return self::getPathTemplate('folderLocationRecommenderRecommendation')->render([ 'folder' => $folder, 'location' => $location, @@ -395,8 +421,11 @@ public static function insightTypeConfigName(string $project, string $location, * * @return string The formatted organization_location_insight_type resource. */ - public static function organizationLocationInsightTypeName(string $organization, string $location, string $insightType): string - { + public static function organizationLocationInsightTypeName( + string $organization, + string $location, + string $insightType + ): string { return self::getPathTemplate('organizationLocationInsightType')->render([ 'organization' => $organization, 'location' => $location, @@ -414,8 +443,11 @@ public static function organizationLocationInsightTypeName(string $organization, * * @return string The formatted organization_location_insight_type_config resource. */ - public static function organizationLocationInsightTypeConfigName(string $organization, string $location, string $insightType): string - { + public static function organizationLocationInsightTypeConfigName( + string $organization, + string $location, + string $insightType + ): string { return self::getPathTemplate('organizationLocationInsightTypeConfig')->render([ 'organization' => $organization, 'location' => $location, @@ -434,8 +466,12 @@ public static function organizationLocationInsightTypeConfigName(string $organiz * * @return string The formatted organization_location_insight_type_insight resource. */ - public static function organizationLocationInsightTypeInsightName(string $organization, string $location, string $insightType, string $insight): string - { + public static function organizationLocationInsightTypeInsightName( + string $organization, + string $location, + string $insightType, + string $insight + ): string { return self::getPathTemplate('organizationLocationInsightTypeInsight')->render([ 'organization' => $organization, 'location' => $location, @@ -454,8 +490,11 @@ public static function organizationLocationInsightTypeInsightName(string $organi * * @return string The formatted organization_location_recommender resource. */ - public static function organizationLocationRecommenderName(string $organization, string $location, string $recommender): string - { + public static function organizationLocationRecommenderName( + string $organization, + string $location, + string $recommender + ): string { return self::getPathTemplate('organizationLocationRecommender')->render([ 'organization' => $organization, 'location' => $location, @@ -473,8 +512,11 @@ public static function organizationLocationRecommenderName(string $organization, * * @return string The formatted organization_location_recommender_config resource. */ - public static function organizationLocationRecommenderConfigName(string $organization, string $location, string $recommender): string - { + public static function organizationLocationRecommenderConfigName( + string $organization, + string $location, + string $recommender + ): string { return self::getPathTemplate('organizationLocationRecommenderConfig')->render([ 'organization' => $organization, 'location' => $location, @@ -493,8 +535,12 @@ public static function organizationLocationRecommenderConfigName(string $organiz * * @return string The formatted organization_location_recommender_recommendation resource. */ - public static function organizationLocationRecommenderRecommendationName(string $organization, string $location, string $recommender, string $recommendation): string - { + public static function organizationLocationRecommenderRecommendationName( + string $organization, + string $location, + string $recommender, + string $recommendation + ): string { return self::getPathTemplate('organizationLocationRecommenderRecommendation')->render([ 'organization' => $organization, 'location' => $location, @@ -513,8 +559,11 @@ public static function organizationLocationRecommenderRecommendationName(string * * @return string The formatted project_location_insight_type resource. */ - public static function projectLocationInsightTypeName(string $project, string $location, string $insightType): string - { + public static function projectLocationInsightTypeName( + string $project, + string $location, + string $insightType + ): string { return self::getPathTemplate('projectLocationInsightType')->render([ 'project' => $project, 'location' => $location, @@ -532,8 +581,11 @@ public static function projectLocationInsightTypeName(string $project, string $l * * @return string The formatted project_location_insight_type_config resource. */ - public static function projectLocationInsightTypeConfigName(string $project, string $location, string $insightType): string - { + public static function projectLocationInsightTypeConfigName( + string $project, + string $location, + string $insightType + ): string { return self::getPathTemplate('projectLocationInsightTypeConfig')->render([ 'project' => $project, 'location' => $location, @@ -552,8 +604,12 @@ public static function projectLocationInsightTypeConfigName(string $project, str * * @return string The formatted project_location_insight_type_insight resource. */ - public static function projectLocationInsightTypeInsightName(string $project, string $location, string $insightType, string $insight): string - { + public static function projectLocationInsightTypeInsightName( + string $project, + string $location, + string $insightType, + string $insight + ): string { return self::getPathTemplate('projectLocationInsightTypeInsight')->render([ 'project' => $project, 'location' => $location, @@ -572,8 +628,11 @@ public static function projectLocationInsightTypeInsightName(string $project, st * * @return string The formatted project_location_recommender resource. */ - public static function projectLocationRecommenderName(string $project, string $location, string $recommender): string - { + public static function projectLocationRecommenderName( + string $project, + string $location, + string $recommender + ): string { return self::getPathTemplate('projectLocationRecommender')->render([ 'project' => $project, 'location' => $location, @@ -591,8 +650,11 @@ public static function projectLocationRecommenderName(string $project, string $l * * @return string The formatted project_location_recommender_config resource. */ - public static function projectLocationRecommenderConfigName(string $project, string $location, string $recommender): string - { + public static function projectLocationRecommenderConfigName( + string $project, + string $location, + string $recommender + ): string { return self::getPathTemplate('projectLocationRecommenderConfig')->render([ 'project' => $project, 'location' => $location, @@ -611,8 +673,12 @@ public static function projectLocationRecommenderConfigName(string $project, str * * @return string The formatted project_location_recommender_recommendation resource. */ - public static function projectLocationRecommenderRecommendationName(string $project, string $location, string $recommender, string $recommendation): string - { + public static function projectLocationRecommenderRecommendationName( + string $project, + string $location, + string $recommender, + string $recommendation + ): string { return self::getPathTemplate('projectLocationRecommenderRecommendation')->render([ 'project' => $project, 'location' => $location, @@ -632,8 +698,12 @@ public static function projectLocationRecommenderRecommendationName(string $proj * * @return string The formatted recommendation resource. */ - public static function recommendationName(string $project, string $location, string $recommender, string $recommendation): string - { + public static function recommendationName( + string $project, + string $location, + string $recommender, + string $recommendation + ): string { return self::getPathTemplate('recommendation')->render([ 'project' => $project, 'location' => $location, @@ -851,8 +921,10 @@ public function getInsight(GetInsightRequest $request, array $callOptions = []): * * @throws ApiException Thrown if the API call fails. */ - public function getInsightTypeConfig(GetInsightTypeConfigRequest $request, array $callOptions = []): InsightTypeConfig - { + public function getInsightTypeConfig( + GetInsightTypeConfigRequest $request, + array $callOptions = [] + ): InsightTypeConfig { return $this->startApiCall('GetInsightTypeConfig', $request, $callOptions)->wait(); } @@ -905,8 +977,10 @@ public function getRecommendation(GetRecommendationRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function getRecommenderConfig(GetRecommenderConfigRequest $request, array $callOptions = []): RecommenderConfig - { + public function getRecommenderConfig( + GetRecommenderConfigRequest $request, + array $callOptions = [] + ): RecommenderConfig { return $this->startApiCall('GetRecommenderConfig', $request, $callOptions)->wait(); } @@ -1026,8 +1100,10 @@ public function markInsightAccepted(MarkInsightAcceptedRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function markRecommendationClaimed(MarkRecommendationClaimedRequest $request, array $callOptions = []): Recommendation - { + public function markRecommendationClaimed( + MarkRecommendationClaimedRequest $request, + array $callOptions = [] + ): Recommendation { return $this->startApiCall('MarkRecommendationClaimed', $request, $callOptions)->wait(); } @@ -1061,8 +1137,10 @@ public function markRecommendationClaimed(MarkRecommendationClaimedRequest $requ * * @throws ApiException Thrown if the API call fails. */ - public function markRecommendationDismissed(MarkRecommendationDismissedRequest $request, array $callOptions = []): Recommendation - { + public function markRecommendationDismissed( + MarkRecommendationDismissedRequest $request, + array $callOptions = [] + ): Recommendation { return $this->startApiCall('MarkRecommendationDismissed', $request, $callOptions)->wait(); } @@ -1097,8 +1175,10 @@ public function markRecommendationDismissed(MarkRecommendationDismissedRequest $ * * @throws ApiException Thrown if the API call fails. */ - public function markRecommendationFailed(MarkRecommendationFailedRequest $request, array $callOptions = []): Recommendation - { + public function markRecommendationFailed( + MarkRecommendationFailedRequest $request, + array $callOptions = [] + ): Recommendation { return $this->startApiCall('MarkRecommendationFailed', $request, $callOptions)->wait(); } @@ -1134,8 +1214,10 @@ public function markRecommendationFailed(MarkRecommendationFailedRequest $reques * * @throws ApiException Thrown if the API call fails. */ - public function markRecommendationSucceeded(MarkRecommendationSucceededRequest $request, array $callOptions = []): Recommendation - { + public function markRecommendationSucceeded( + MarkRecommendationSucceededRequest $request, + array $callOptions = [] + ): Recommendation { return $this->startApiCall('MarkRecommendationSucceeded', $request, $callOptions)->wait(); } @@ -1161,8 +1243,10 @@ public function markRecommendationSucceeded(MarkRecommendationSucceededRequest $ * * @throws ApiException Thrown if the API call fails. */ - public function updateInsightTypeConfig(UpdateInsightTypeConfigRequest $request, array $callOptions = []): InsightTypeConfig - { + public function updateInsightTypeConfig( + UpdateInsightTypeConfigRequest $request, + array $callOptions = [] + ): InsightTypeConfig { return $this->startApiCall('UpdateInsightTypeConfig', $request, $callOptions)->wait(); } @@ -1188,8 +1272,10 @@ public function updateInsightTypeConfig(UpdateInsightTypeConfigRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function updateRecommenderConfig(UpdateRecommenderConfigRequest $request, array $callOptions = []): RecommenderConfig - { + public function updateRecommenderConfig( + UpdateRecommenderConfigRequest $request, + array $callOptions = [] + ): RecommenderConfig { return $this->startApiCall('UpdateRecommenderConfig', $request, $callOptions)->wait(); } } diff --git a/Recommender/src/V1/CostProjection.php b/Recommender/src/V1/CostProjection.php index d198c83b0a8b..e981e6aba9ee 100644 --- a/Recommender/src/V1/CostProjection.php +++ b/Recommender/src/V1/CostProjection.php @@ -24,19 +24,19 @@ class CostProjection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.type.Money cost = 1; */ - private $cost = null; + protected $cost = null; /** * Duration for which this cost applies. * * Generated from protobuf field .google.protobuf.Duration duration = 2; */ - private $duration = null; + protected $duration = null; /** * The approximate cost savings in the billing account's local currency. * * Generated from protobuf field .google.type.Money cost_in_local_currency = 3; */ - private $cost_in_local_currency = null; + protected $cost_in_local_currency = null; /** * Constructor. diff --git a/Recommender/src/V1/Gapic/RecommenderGapicClient.php b/Recommender/src/V1/Gapic/RecommenderGapicClient.php deleted file mode 100644 index e8da3932d68f..000000000000 --- a/Recommender/src/V1/Gapic/RecommenderGapicClient.php +++ /dev/null @@ -1,1968 +0,0 @@ -insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - * $response = $recommenderClient->getInsight($formattedName); - * } finally { - * $recommenderClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Recommender\V1\Client\RecommenderClient}. - */ -class RecommenderGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.recommender.v1.Recommender'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'recommender.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'recommender.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $billingAccountLocationInsightTypeNameTemplate; - - private static $billingAccountLocationInsightTypeConfigNameTemplate; - - private static $billingAccountLocationInsightTypeInsightNameTemplate; - - private static $billingAccountLocationRecommenderNameTemplate; - - private static $billingAccountLocationRecommenderConfigNameTemplate; - - private static $billingAccountLocationRecommenderRecommendationNameTemplate; - - private static $folderLocationInsightTypeNameTemplate; - - private static $folderLocationInsightTypeInsightNameTemplate; - - private static $folderLocationRecommenderNameTemplate; - - private static $folderLocationRecommenderRecommendationNameTemplate; - - private static $insightNameTemplate; - - private static $insightTypeNameTemplate; - - private static $insightTypeConfigNameTemplate; - - private static $organizationLocationInsightTypeNameTemplate; - - private static $organizationLocationInsightTypeConfigNameTemplate; - - private static $organizationLocationInsightTypeInsightNameTemplate; - - private static $organizationLocationRecommenderNameTemplate; - - private static $organizationLocationRecommenderConfigNameTemplate; - - private static $organizationLocationRecommenderRecommendationNameTemplate; - - private static $projectLocationInsightTypeNameTemplate; - - private static $projectLocationInsightTypeConfigNameTemplate; - - private static $projectLocationInsightTypeInsightNameTemplate; - - private static $projectLocationRecommenderNameTemplate; - - private static $projectLocationRecommenderConfigNameTemplate; - - private static $projectLocationRecommenderRecommendationNameTemplate; - - private static $recommendationNameTemplate; - - private static $recommenderNameTemplate; - - private static $recommenderConfigNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getBillingAccountLocationInsightTypeNameTemplate() - { - if (self::$billingAccountLocationInsightTypeNameTemplate == null) { - self::$billingAccountLocationInsightTypeNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}'); - } - - return self::$billingAccountLocationInsightTypeNameTemplate; - } - - private static function getBillingAccountLocationInsightTypeConfigNameTemplate() - { - if (self::$billingAccountLocationInsightTypeConfigNameTemplate == null) { - self::$billingAccountLocationInsightTypeConfigNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/config'); - } - - return self::$billingAccountLocationInsightTypeConfigNameTemplate; - } - - private static function getBillingAccountLocationInsightTypeInsightNameTemplate() - { - if (self::$billingAccountLocationInsightTypeInsightNameTemplate == null) { - self::$billingAccountLocationInsightTypeInsightNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}'); - } - - return self::$billingAccountLocationInsightTypeInsightNameTemplate; - } - - private static function getBillingAccountLocationRecommenderNameTemplate() - { - if (self::$billingAccountLocationRecommenderNameTemplate == null) { - self::$billingAccountLocationRecommenderNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}'); - } - - return self::$billingAccountLocationRecommenderNameTemplate; - } - - private static function getBillingAccountLocationRecommenderConfigNameTemplate() - { - if (self::$billingAccountLocationRecommenderConfigNameTemplate == null) { - self::$billingAccountLocationRecommenderConfigNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/config'); - } - - return self::$billingAccountLocationRecommenderConfigNameTemplate; - } - - private static function getBillingAccountLocationRecommenderRecommendationNameTemplate() - { - if (self::$billingAccountLocationRecommenderRecommendationNameTemplate == null) { - self::$billingAccountLocationRecommenderRecommendationNameTemplate = new PathTemplate('billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}'); - } - - return self::$billingAccountLocationRecommenderRecommendationNameTemplate; - } - - private static function getFolderLocationInsightTypeNameTemplate() - { - if (self::$folderLocationInsightTypeNameTemplate == null) { - self::$folderLocationInsightTypeNameTemplate = new PathTemplate('folders/{folder}/locations/{location}/insightTypes/{insight_type}'); - } - - return self::$folderLocationInsightTypeNameTemplate; - } - - private static function getFolderLocationInsightTypeInsightNameTemplate() - { - if (self::$folderLocationInsightTypeInsightNameTemplate == null) { - self::$folderLocationInsightTypeInsightNameTemplate = new PathTemplate('folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}'); - } - - return self::$folderLocationInsightTypeInsightNameTemplate; - } - - private static function getFolderLocationRecommenderNameTemplate() - { - if (self::$folderLocationRecommenderNameTemplate == null) { - self::$folderLocationRecommenderNameTemplate = new PathTemplate('folders/{folder}/locations/{location}/recommenders/{recommender}'); - } - - return self::$folderLocationRecommenderNameTemplate; - } - - private static function getFolderLocationRecommenderRecommendationNameTemplate() - { - if (self::$folderLocationRecommenderRecommendationNameTemplate == null) { - self::$folderLocationRecommenderRecommendationNameTemplate = new PathTemplate('folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}'); - } - - return self::$folderLocationRecommenderRecommendationNameTemplate; - } - - private static function getInsightNameTemplate() - { - if (self::$insightNameTemplate == null) { - self::$insightNameTemplate = new PathTemplate('projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}'); - } - - return self::$insightNameTemplate; - } - - private static function getInsightTypeNameTemplate() - { - if (self::$insightTypeNameTemplate == null) { - self::$insightTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/insightTypes/{insight_type}'); - } - - return self::$insightTypeNameTemplate; - } - - private static function getInsightTypeConfigNameTemplate() - { - if (self::$insightTypeConfigNameTemplate == null) { - self::$insightTypeConfigNameTemplate = new PathTemplate('projects/{project}/locations/{location}/insightTypes/{insight_type}/config'); - } - - return self::$insightTypeConfigNameTemplate; - } - - private static function getOrganizationLocationInsightTypeNameTemplate() - { - if (self::$organizationLocationInsightTypeNameTemplate == null) { - self::$organizationLocationInsightTypeNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/insightTypes/{insight_type}'); - } - - return self::$organizationLocationInsightTypeNameTemplate; - } - - private static function getOrganizationLocationInsightTypeConfigNameTemplate() - { - if (self::$organizationLocationInsightTypeConfigNameTemplate == null) { - self::$organizationLocationInsightTypeConfigNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config'); - } - - return self::$organizationLocationInsightTypeConfigNameTemplate; - } - - private static function getOrganizationLocationInsightTypeInsightNameTemplate() - { - if (self::$organizationLocationInsightTypeInsightNameTemplate == null) { - self::$organizationLocationInsightTypeInsightNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}'); - } - - return self::$organizationLocationInsightTypeInsightNameTemplate; - } - - private static function getOrganizationLocationRecommenderNameTemplate() - { - if (self::$organizationLocationRecommenderNameTemplate == null) { - self::$organizationLocationRecommenderNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/recommenders/{recommender}'); - } - - return self::$organizationLocationRecommenderNameTemplate; - } - - private static function getOrganizationLocationRecommenderConfigNameTemplate() - { - if (self::$organizationLocationRecommenderConfigNameTemplate == null) { - self::$organizationLocationRecommenderConfigNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/recommenders/{recommender}/config'); - } - - return self::$organizationLocationRecommenderConfigNameTemplate; - } - - private static function getOrganizationLocationRecommenderRecommendationNameTemplate() - { - if (self::$organizationLocationRecommenderRecommendationNameTemplate == null) { - self::$organizationLocationRecommenderRecommendationNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}'); - } - - return self::$organizationLocationRecommenderRecommendationNameTemplate; - } - - private static function getProjectLocationInsightTypeNameTemplate() - { - if (self::$projectLocationInsightTypeNameTemplate == null) { - self::$projectLocationInsightTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/insightTypes/{insight_type}'); - } - - return self::$projectLocationInsightTypeNameTemplate; - } - - private static function getProjectLocationInsightTypeConfigNameTemplate() - { - if (self::$projectLocationInsightTypeConfigNameTemplate == null) { - self::$projectLocationInsightTypeConfigNameTemplate = new PathTemplate('projects/{project}/locations/{location}/insightTypes/{insight_type}/config'); - } - - return self::$projectLocationInsightTypeConfigNameTemplate; - } - - private static function getProjectLocationInsightTypeInsightNameTemplate() - { - if (self::$projectLocationInsightTypeInsightNameTemplate == null) { - self::$projectLocationInsightTypeInsightNameTemplate = new PathTemplate('projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}'); - } - - return self::$projectLocationInsightTypeInsightNameTemplate; - } - - private static function getProjectLocationRecommenderNameTemplate() - { - if (self::$projectLocationRecommenderNameTemplate == null) { - self::$projectLocationRecommenderNameTemplate = new PathTemplate('projects/{project}/locations/{location}/recommenders/{recommender}'); - } - - return self::$projectLocationRecommenderNameTemplate; - } - - private static function getProjectLocationRecommenderConfigNameTemplate() - { - if (self::$projectLocationRecommenderConfigNameTemplate == null) { - self::$projectLocationRecommenderConfigNameTemplate = new PathTemplate('projects/{project}/locations/{location}/recommenders/{recommender}/config'); - } - - return self::$projectLocationRecommenderConfigNameTemplate; - } - - private static function getProjectLocationRecommenderRecommendationNameTemplate() - { - if (self::$projectLocationRecommenderRecommendationNameTemplate == null) { - self::$projectLocationRecommenderRecommendationNameTemplate = new PathTemplate('projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}'); - } - - return self::$projectLocationRecommenderRecommendationNameTemplate; - } - - private static function getRecommendationNameTemplate() - { - if (self::$recommendationNameTemplate == null) { - self::$recommendationNameTemplate = new PathTemplate('projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}'); - } - - return self::$recommendationNameTemplate; - } - - private static function getRecommenderNameTemplate() - { - if (self::$recommenderNameTemplate == null) { - self::$recommenderNameTemplate = new PathTemplate('projects/{project}/locations/{location}/recommenders/{recommender}'); - } - - return self::$recommenderNameTemplate; - } - - private static function getRecommenderConfigNameTemplate() - { - if (self::$recommenderConfigNameTemplate == null) { - self::$recommenderConfigNameTemplate = new PathTemplate('projects/{project}/locations/{location}/recommenders/{recommender}/config'); - } - - return self::$recommenderConfigNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'billingAccountLocationInsightType' => self::getBillingAccountLocationInsightTypeNameTemplate(), - 'billingAccountLocationInsightTypeConfig' => self::getBillingAccountLocationInsightTypeConfigNameTemplate(), - 'billingAccountLocationInsightTypeInsight' => self::getBillingAccountLocationInsightTypeInsightNameTemplate(), - 'billingAccountLocationRecommender' => self::getBillingAccountLocationRecommenderNameTemplate(), - 'billingAccountLocationRecommenderConfig' => self::getBillingAccountLocationRecommenderConfigNameTemplate(), - 'billingAccountLocationRecommenderRecommendation' => self::getBillingAccountLocationRecommenderRecommendationNameTemplate(), - 'folderLocationInsightType' => self::getFolderLocationInsightTypeNameTemplate(), - 'folderLocationInsightTypeInsight' => self::getFolderLocationInsightTypeInsightNameTemplate(), - 'folderLocationRecommender' => self::getFolderLocationRecommenderNameTemplate(), - 'folderLocationRecommenderRecommendation' => self::getFolderLocationRecommenderRecommendationNameTemplate(), - 'insight' => self::getInsightNameTemplate(), - 'insightType' => self::getInsightTypeNameTemplate(), - 'insightTypeConfig' => self::getInsightTypeConfigNameTemplate(), - 'organizationLocationInsightType' => self::getOrganizationLocationInsightTypeNameTemplate(), - 'organizationLocationInsightTypeConfig' => self::getOrganizationLocationInsightTypeConfigNameTemplate(), - 'organizationLocationInsightTypeInsight' => self::getOrganizationLocationInsightTypeInsightNameTemplate(), - 'organizationLocationRecommender' => self::getOrganizationLocationRecommenderNameTemplate(), - 'organizationLocationRecommenderConfig' => self::getOrganizationLocationRecommenderConfigNameTemplate(), - 'organizationLocationRecommenderRecommendation' => self::getOrganizationLocationRecommenderRecommendationNameTemplate(), - 'projectLocationInsightType' => self::getProjectLocationInsightTypeNameTemplate(), - 'projectLocationInsightTypeConfig' => self::getProjectLocationInsightTypeConfigNameTemplate(), - 'projectLocationInsightTypeInsight' => self::getProjectLocationInsightTypeInsightNameTemplate(), - 'projectLocationRecommender' => self::getProjectLocationRecommenderNameTemplate(), - 'projectLocationRecommenderConfig' => self::getProjectLocationRecommenderConfigNameTemplate(), - 'projectLocationRecommenderRecommendation' => self::getProjectLocationRecommenderRecommendationNameTemplate(), - 'recommendation' => self::getRecommendationNameTemplate(), - 'recommender' => self::getRecommenderNameTemplate(), - 'recommenderConfig' => self::getRecommenderConfigNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($billingAccount, $location, $insightType) - { - return self::getBillingAccountLocationInsightTypeNameTemplate()->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($billingAccount, $location, $insightType) - { - return self::getBillingAccountLocationInsightTypeConfigNameTemplate()->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($billingAccount, $location, $insightType, $insight) - { - return self::getBillingAccountLocationInsightTypeInsightNameTemplate()->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($billingAccount, $location, $recommender) - { - return self::getBillingAccountLocationRecommenderNameTemplate()->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($billingAccount, $location, $recommender) - { - return self::getBillingAccountLocationRecommenderConfigNameTemplate()->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($billingAccount, $location, $recommender, $recommendation) - { - return self::getBillingAccountLocationRecommenderRecommendationNameTemplate()->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($folder, $location, $insightType) - { - return self::getFolderLocationInsightTypeNameTemplate()->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($folder, $location, $insightType, $insight) - { - return self::getFolderLocationInsightTypeInsightNameTemplate()->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($folder, $location, $recommender) - { - return self::getFolderLocationRecommenderNameTemplate()->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($folder, $location, $recommender, $recommendation) - { - return self::getFolderLocationRecommenderRecommendationNameTemplate()->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($project, $location, $insightType, $insight) - { - return self::getInsightNameTemplate()->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($project, $location, $insightType) - { - return self::getInsightTypeNameTemplate()->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($project, $location, $insightType) - { - return self::getInsightTypeConfigNameTemplate()->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($organization, $location, $insightType) - { - return self::getOrganizationLocationInsightTypeNameTemplate()->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($organization, $location, $insightType) - { - return self::getOrganizationLocationInsightTypeConfigNameTemplate()->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($organization, $location, $insightType, $insight) - { - return self::getOrganizationLocationInsightTypeInsightNameTemplate()->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($organization, $location, $recommender) - { - return self::getOrganizationLocationRecommenderNameTemplate()->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($organization, $location, $recommender) - { - return self::getOrganizationLocationRecommenderConfigNameTemplate()->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($organization, $location, $recommender, $recommendation) - { - return self::getOrganizationLocationRecommenderRecommendationNameTemplate()->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($project, $location, $insightType) - { - return self::getProjectLocationInsightTypeNameTemplate()->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($project, $location, $insightType) - { - return self::getProjectLocationInsightTypeConfigNameTemplate()->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($project, $location, $insightType, $insight) - { - return self::getProjectLocationInsightTypeInsightNameTemplate()->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($project, $location, $recommender) - { - return self::getProjectLocationRecommenderNameTemplate()->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($project, $location, $recommender) - { - return self::getProjectLocationRecommenderConfigNameTemplate()->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($project, $location, $recommender, $recommendation) - { - return self::getProjectLocationRecommenderRecommendationNameTemplate()->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($project, $location, $recommender, $recommendation) - { - return self::getRecommendationNameTemplate()->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($project, $location, $recommender) - { - return self::getRecommenderNameTemplate()->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($project, $location, $recommender) - { - return self::getRecommenderConfigNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * Gets the requested insight. Requires the recommender.*.get IAM permission - * for the specified insight type. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - * $response = $recommenderClient->getInsight($formattedName); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the insight. - * @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\Recommender\V1\Insight - * - * @throws ApiException if the remote call fails - */ - public function getInsight($name, array $optionalArgs = []) - { - $request = new GetInsightRequest(); - $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('GetInsight', Insight::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the requested InsightTypeConfig. There is only one instance of the - * config for each InsightType. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->insightTypeConfigName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - * $response = $recommenderClient->getInsightTypeConfig($formattedName); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the InsightTypeConfig to get. - * - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` - * @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\Recommender\V1\InsightTypeConfig - * - * @throws ApiException if the remote call fails - */ - public function getInsightTypeConfig($name, array $optionalArgs = []) - { - $request = new GetInsightTypeConfigRequest(); - $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('GetInsightTypeConfig', InsightTypeConfig::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the requested recommendation. Requires the recommender.*.get - * IAM permission for the specified recommender. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - * $response = $recommenderClient->getRecommendation($formattedName); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the recommendation. - * @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\Recommender\V1\Recommendation - * - * @throws ApiException if the remote call fails - */ - public function getRecommendation($name, array $optionalArgs = []) - { - $request = new GetRecommendationRequest(); - $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('GetRecommendation', Recommendation::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the requested Recommender Config. There is only one instance of the - * config for each Recommender. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->recommenderConfigName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - * $response = $recommenderClient->getRecommenderConfig($formattedName); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the Recommendation Config to get. - * - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` - * @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\Recommender\V1\RecommenderConfig - * - * @throws ApiException if the remote call fails - */ - public function getRecommenderConfig($name, array $optionalArgs = []) - { - $request = new GetRecommenderConfigRequest(); - $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('GetRecommenderConfig', RecommenderConfig::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists insights for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified insight type. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedParent = $recommenderClient->insightTypeName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - * // Iterate over pages of elements - * $pagedResponse = $recommenderClient->listInsights($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $recommenderClient->listInsights($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $parent Required. The container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * INSIGHT_TYPE_ID refers to supported insight types: - * https://cloud.google.com/recommender/docs/insights/insight-types. - * @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 string $filter - * Optional. Filter expression to restrict the insights returned. Supported - * filter fields: - * - * * `stateInfo.state` - * - * * `insightSubtype` - * - * * `severity` - * - * * `targetResources` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `insightSubtype = PERMISSIONS_USAGE` - * - * * `severity = CRITICAL OR severity = HIGH` - * - * * `targetResources : - * //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` - * - * * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` - * - * The max allowed filter length is 500 characters. - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listInsights($parent, array $optionalArgs = []) - { - $request = new ListInsightsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListInsights', $optionalArgs, ListInsightsResponse::class, $request); - } - - /** - * Lists recommendations for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified recommender. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedParent = $recommenderClient->recommenderName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - * // Iterate over pages of elements - * $pagedResponse = $recommenderClient->listRecommendations($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $recommenderClient->listRecommendations($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $parent Required. The container resource on which to execute the request. - * Acceptable formats: - * - * * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` - * - * LOCATION here refers to GCP Locations: - * https://cloud.google.com/about/locations/ - * RECOMMENDER_ID refers to supported recommenders: - * https://cloud.google.com/recommender/docs/recommenders. - * @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 string $filter - * Filter expression to restrict the recommendations returned. Supported - * filter fields: - * - * * `state_info.state` - * - * * `recommenderSubtype` - * - * * `priority` - * - * * `targetResources` - * - * Examples: - * - * * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` - * - * * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` - * - * * `priority = P1 OR priority = P2` - * - * * `targetResources : - * //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` - * - * * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` - * - * The max allowed filter length is 500 characters. - * - * (These expressions are based on the filter language described at - * https://google.aip.dev/160) - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listRecommendations($parent, array $optionalArgs = []) - { - $request = new ListRecommendationsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListRecommendations', $optionalArgs, ListRecommendationsResponse::class, $request); - } - - /** - * 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. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - * $etag = 'etag'; - * $response = $recommenderClient->markInsightAccepted($formattedName, $etag); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the insight. - * @param string $etag Required. Fingerprint of the Insight. Provides optimistic locking. - * @param array $optionalArgs { - * Optional. - * - * @type array $stateMetadata - * Optional. State properties user wish to include with this state. Full - * replace of the current state_metadata. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Recommender\V1\Insight - * - * @throws ApiException if the remote call fails - */ - public function markInsightAccepted($name, $etag, array $optionalArgs = []) - { - $request = new MarkInsightAcceptedRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setEtag($etag); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['stateMetadata'])) { - $request->setStateMetadata($optionalArgs['stateMetadata']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('MarkInsightAccepted', Insight::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - * $etag = 'etag'; - * $response = $recommenderClient->markRecommendationClaimed($formattedName, $etag); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the recommendation. - * @param string $etag Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param array $optionalArgs { - * Optional. - * - * @type array $stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Recommender\V1\Recommendation - * - * @throws ApiException if the remote call fails - */ - public function markRecommendationClaimed($name, $etag, array $optionalArgs = []) - { - $request = new MarkRecommendationClaimedRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setEtag($etag); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['stateMetadata'])) { - $request->setStateMetadata($optionalArgs['stateMetadata']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('MarkRecommendationClaimed', Recommendation::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - * $response = $recommenderClient->markRecommendationDismissed($formattedName); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the recommendation. - * @param array $optionalArgs { - * Optional. - * - * @type string $etag - * Fingerprint of the Recommendation. Provides optimistic locking. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Recommender\V1\Recommendation - * - * @throws ApiException if the remote call fails - */ - public function markRecommendationDismissed($name, array $optionalArgs = []) - { - $request = new MarkRecommendationDismissedRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['etag'])) { - $request->setEtag($optionalArgs['etag']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('MarkRecommendationDismissed', Recommendation::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - * $etag = 'etag'; - * $response = $recommenderClient->markRecommendationFailed($formattedName, $etag); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the recommendation. - * @param string $etag Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param array $optionalArgs { - * Optional. - * - * @type array $stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Recommender\V1\Recommendation - * - * @throws ApiException if the remote call fails - */ - public function markRecommendationFailed($name, $etag, array $optionalArgs = []) - { - $request = new MarkRecommendationFailedRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setEtag($etag); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['stateMetadata'])) { - $request->setStateMetadata($optionalArgs['stateMetadata']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('MarkRecommendationFailed', Recommendation::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $formattedName = $recommenderClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - * $etag = 'etag'; - * $response = $recommenderClient->markRecommendationSucceeded($formattedName, $etag); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the recommendation. - * @param string $etag Required. Fingerprint of the Recommendation. Provides optimistic locking. - * @param array $optionalArgs { - * Optional. - * - * @type array $stateMetadata - * State properties to include with this state. Overwrites any existing - * `state_metadata`. - * Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`. - * Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Recommender\V1\Recommendation - * - * @throws ApiException if the remote call fails - */ - public function markRecommendationSucceeded($name, $etag, array $optionalArgs = []) - { - $request = new MarkRecommendationSucceededRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setEtag($etag); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['stateMetadata'])) { - $request->setStateMetadata($optionalArgs['stateMetadata']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('MarkRecommendationSucceeded', Recommendation::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates an InsightTypeConfig change. This will create a new revision of the - * config. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $insightTypeConfig = new InsightTypeConfig(); - * $response = $recommenderClient->updateInsightTypeConfig($insightTypeConfig); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param InsightTypeConfig $insightTypeConfig Required. The InsightTypeConfig to update. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to be updated. - * @type bool $validateOnly - * If true, validate the request and preview the change, but do not actually - * update it. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Recommender\V1\InsightTypeConfig - * - * @throws ApiException if the remote call fails - */ - public function updateInsightTypeConfig($insightTypeConfig, array $optionalArgs = []) - { - $request = new UpdateInsightTypeConfigRequest(); - $requestParamHeaders = []; - $request->setInsightTypeConfig($insightTypeConfig); - $requestParamHeaders['insight_type_config.name'] = $insightTypeConfig->getName(); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateInsightTypeConfig', InsightTypeConfig::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates a Recommender Config. This will create a new revision of the - * config. - * - * Sample code: - * ``` - * $recommenderClient = new RecommenderClient(); - * try { - * $recommenderConfig = new RecommenderConfig(); - * $response = $recommenderClient->updateRecommenderConfig($recommenderConfig); - * } finally { - * $recommenderClient->close(); - * } - * ``` - * - * @param RecommenderConfig $recommenderConfig Required. The RecommenderConfig to update. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to be updated. - * @type bool $validateOnly - * If true, validate the request and preview the change, but do not actually - * update it. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\Recommender\V1\RecommenderConfig - * - * @throws ApiException if the remote call fails - */ - public function updateRecommenderConfig($recommenderConfig, array $optionalArgs = []) - { - $request = new UpdateRecommenderConfigRequest(); - $requestParamHeaders = []; - $request->setRecommenderConfig($recommenderConfig); - $requestParamHeaders['recommender_config.name'] = $recommenderConfig->getName(); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateRecommenderConfig', RecommenderConfig::class, $optionalArgs, $request)->wait(); - } -} diff --git a/Recommender/src/V1/GetInsightRequest.php b/Recommender/src/V1/GetInsightRequest.php index e9eff290091b..4eefd045c8d4 100644 --- a/Recommender/src/V1/GetInsightRequest.php +++ b/Recommender/src/V1/GetInsightRequest.php @@ -20,7 +20,7 @@ class GetInsightRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the insight. Please see diff --git a/Recommender/src/V1/GetInsightTypeConfigRequest.php b/Recommender/src/V1/GetInsightTypeConfigRequest.php index 73a2988c5b9b..cf71aa698a60 100644 --- a/Recommender/src/V1/GetInsightTypeConfigRequest.php +++ b/Recommender/src/V1/GetInsightTypeConfigRequest.php @@ -25,7 +25,7 @@ class GetInsightTypeConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the InsightTypeConfig to get. diff --git a/Recommender/src/V1/GetRecommendationRequest.php b/Recommender/src/V1/GetRecommendationRequest.php index 500268c0b7d1..b15ce7896af4 100644 --- a/Recommender/src/V1/GetRecommendationRequest.php +++ b/Recommender/src/V1/GetRecommendationRequest.php @@ -20,7 +20,7 @@ class GetRecommendationRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the recommendation. Please see diff --git a/Recommender/src/V1/GetRecommenderConfigRequest.php b/Recommender/src/V1/GetRecommenderConfigRequest.php index f010935f27ac..ff82145c37d0 100644 --- a/Recommender/src/V1/GetRecommenderConfigRequest.php +++ b/Recommender/src/V1/GetRecommenderConfigRequest.php @@ -25,7 +25,7 @@ class GetRecommenderConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the Recommendation Config to get. diff --git a/Recommender/src/V1/Impact.php b/Recommender/src/V1/Impact.php index f543dfcc01d0..1ae4e1147913 100644 --- a/Recommender/src/V1/Impact.php +++ b/Recommender/src/V1/Impact.php @@ -20,7 +20,7 @@ class Impact extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.recommender.v1.Impact.Category category = 1; */ - private $category = 0; + protected $category = 0; protected $projection; /** diff --git a/Recommender/src/V1/Impact/Category.php b/Recommender/src/V1/Impact/Category.php index 3edc36ada2dc..116258885c26 100644 --- a/Recommender/src/V1/Impact/Category.php +++ b/Recommender/src/V1/Impact/Category.php @@ -87,6 +87,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Category::class, \Google\Cloud\Recommender\V1\Impact_Category::class); diff --git a/Recommender/src/V1/Impact_Category.php b/Recommender/src/V1/Impact_Category.php deleted file mode 100644 index 1530898bedcf..000000000000 --- a/Recommender/src/V1/Impact_Category.php +++ /dev/null @@ -1,16 +0,0 @@ -string name = 1; */ - private $name = ''; + protected $name = ''; /** * Free-form human readable summary in English. The maximum length is 500 * characters. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * Fully qualified resource names that this insight is targeting. * @@ -40,20 +40,20 @@ class Insight extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string insight_subtype = 10; */ - private $insight_subtype = ''; + protected $insight_subtype = ''; /** * A struct of custom fields to explain the insight. * Example: "grantedPermissionsCount": "1000" * * Generated from protobuf field .google.protobuf.Struct content = 3; */ - private $content = null; + protected $content = null; /** * Timestamp of the latest data used to generate the insight. * * Generated from protobuf field .google.protobuf.Timestamp last_refresh_time = 4; */ - private $last_refresh_time = null; + protected $last_refresh_time = null; /** * Observation period that led to the insight. The source data used to * generate the insight ends at last_refresh_time and begins at @@ -61,32 +61,32 @@ class Insight extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration observation_period = 5; */ - private $observation_period = null; + protected $observation_period = null; /** * Information state and metadata. * * Generated from protobuf field .google.cloud.recommender.v1.InsightStateInfo state_info = 6; */ - private $state_info = null; + protected $state_info = null; /** * Category being targeted by the insight. * * Generated from protobuf field .google.cloud.recommender.v1.Insight.Category category = 7; */ - private $category = 0; + protected $category = 0; /** * Insight's severity. * * Generated from protobuf field .google.cloud.recommender.v1.Insight.Severity severity = 15; */ - private $severity = 0; + protected $severity = 0; /** * Fingerprint of the Insight. Provides optimistic locking when updating * states. * * Generated from protobuf field string etag = 11; */ - private $etag = ''; + protected $etag = ''; /** * Recommendations derived from this insight. * diff --git a/Recommender/src/V1/Insight/Category.php b/Recommender/src/V1/Insight/Category.php index 2bd1978a8018..4ff692bf6769 100644 --- a/Recommender/src/V1/Insight/Category.php +++ b/Recommender/src/V1/Insight/Category.php @@ -87,6 +87,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Category::class, \Google\Cloud\Recommender\V1\Insight_Category::class); diff --git a/Recommender/src/V1/Insight/RecommendationReference.php b/Recommender/src/V1/Insight/RecommendationReference.php index 25eebd8d6f85..fe793c352c2e 100644 --- a/Recommender/src/V1/Insight/RecommendationReference.php +++ b/Recommender/src/V1/Insight/RecommendationReference.php @@ -21,7 +21,7 @@ class RecommendationReference extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string recommendation = 1; */ - private $recommendation = ''; + protected $recommendation = ''; /** * Constructor. @@ -69,6 +69,4 @@ public function setRecommendation($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(RecommendationReference::class, \Google\Cloud\Recommender\V1\Insight_RecommendationReference::class); diff --git a/Recommender/src/V1/Insight/Severity.php b/Recommender/src/V1/Insight/Severity.php index 4370e3d0118e..d327c114019e 100644 --- a/Recommender/src/V1/Insight/Severity.php +++ b/Recommender/src/V1/Insight/Severity.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Severity::class, \Google\Cloud\Recommender\V1\Insight_Severity::class); diff --git a/Recommender/src/V1/InsightStateInfo.php b/Recommender/src/V1/InsightStateInfo.php index a01b020a0400..e34f0b84d941 100644 --- a/Recommender/src/V1/InsightStateInfo.php +++ b/Recommender/src/V1/InsightStateInfo.php @@ -20,7 +20,7 @@ class InsightStateInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.recommender.v1.InsightStateInfo.State state = 1; */ - private $state = 0; + protected $state = 0; /** * A map of metadata for the state, provided by user or automations systems. * diff --git a/Recommender/src/V1/InsightStateInfo/State.php b/Recommender/src/V1/InsightStateInfo/State.php index 648ce14b4594..dc90968ea3dd 100644 --- a/Recommender/src/V1/InsightStateInfo/State.php +++ b/Recommender/src/V1/InsightStateInfo/State.php @@ -72,6 +72,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\Recommender\V1\InsightStateInfo_State::class); diff --git a/Recommender/src/V1/InsightStateInfo_State.php b/Recommender/src/V1/InsightStateInfo_State.php deleted file mode 100644 index f55b3e0032c5..000000000000 --- a/Recommender/src/V1/InsightStateInfo_State.php +++ /dev/null @@ -1,16 +0,0 @@ -string name = 1; */ - private $name = ''; + protected $name = ''; /** * InsightTypeGenerationConfig which configures the generation of * insights for this insight type. * * Generated from protobuf field .google.cloud.recommender.v1.InsightTypeGenerationConfig insight_type_generation_config = 2; */ - private $insight_type_generation_config = null; + protected $insight_type_generation_config = null; /** * Fingerprint of the InsightTypeConfig. Provides optimistic locking when * updating. * * Generated from protobuf field string etag = 3; */ - private $etag = ''; + protected $etag = ''; /** * Last time when the config was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 4; */ - private $update_time = null; + protected $update_time = null; /** * Output only. Immutable. The revision ID of the config. * A new revision is committed whenever the config is changed in any way. @@ -50,7 +50,7 @@ class InsightTypeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string revision_id = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $revision_id = ''; + protected $revision_id = ''; /** * Allows clients to store small amounts of arbitrary data. Annotations must * follow the Kubernetes syntax. @@ -70,7 +70,7 @@ class InsightTypeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 7; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. diff --git a/Recommender/src/V1/InsightTypeGenerationConfig.php b/Recommender/src/V1/InsightTypeGenerationConfig.php index 822b77e7b928..93d2117a35ce 100644 --- a/Recommender/src/V1/InsightTypeGenerationConfig.php +++ b/Recommender/src/V1/InsightTypeGenerationConfig.php @@ -23,7 +23,7 @@ class InsightTypeGenerationConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct params = 1; */ - private $params = null; + protected $params = null; /** * Constructor. diff --git a/Recommender/src/V1/Insight_Category.php b/Recommender/src/V1/Insight_Category.php deleted file mode 100644 index 3790b662cdd1..000000000000 --- a/Recommender/src/V1/Insight_Category.php +++ /dev/null @@ -1,16 +0,0 @@ -string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. The maximum number of results to return from this request. * Non-positive values are ignored. If not specified, the server will @@ -38,7 +38,7 @@ class ListInsightsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. If present, retrieves the next batch of results from the * preceding call to this method. `page_token` must be the value of @@ -47,7 +47,7 @@ class ListInsightsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. Filter expression to restrict the insights returned. Supported * filter fields: @@ -68,7 +68,7 @@ class ListInsightsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The container resource on which to execute the request. diff --git a/Recommender/src/V1/ListInsightsResponse.php b/Recommender/src/V1/ListInsightsResponse.php index 47407a7cacb5..559624b870fb 100644 --- a/Recommender/src/V1/ListInsightsResponse.php +++ b/Recommender/src/V1/ListInsightsResponse.php @@ -27,7 +27,7 @@ class ListInsightsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Recommender/src/V1/ListRecommendationsRequest.php b/Recommender/src/V1/ListRecommendationsRequest.php index 6dc39eb9f748..4d1306e50f46 100644 --- a/Recommender/src/V1/ListRecommendationsRequest.php +++ b/Recommender/src/V1/ListRecommendationsRequest.php @@ -30,7 +30,7 @@ class ListRecommendationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. The maximum number of results to return from this request. * Non-positive values are ignored. If not specified, the server will @@ -38,7 +38,7 @@ class ListRecommendationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. If present, retrieves the next batch of results from the * preceding call to this method. `page_token` must be the value of @@ -47,7 +47,7 @@ class ListRecommendationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Filter expression to restrict the recommendations returned. Supported * filter fields: @@ -68,7 +68,7 @@ class ListRecommendationsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 5; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The container resource on which to execute the request. diff --git a/Recommender/src/V1/ListRecommendationsResponse.php b/Recommender/src/V1/ListRecommendationsResponse.php index 1340d563bc5f..e1f49c49e2b3 100644 --- a/Recommender/src/V1/ListRecommendationsResponse.php +++ b/Recommender/src/V1/ListRecommendationsResponse.php @@ -27,7 +27,7 @@ class ListRecommendationsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Recommender/src/V1/MarkInsightAcceptedRequest.php b/Recommender/src/V1/MarkInsightAcceptedRequest.php index 8233c7657748..44812d4b120b 100644 --- a/Recommender/src/V1/MarkInsightAcceptedRequest.php +++ b/Recommender/src/V1/MarkInsightAcceptedRequest.php @@ -20,7 +20,7 @@ class MarkInsightAcceptedRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. State properties user wish to include with this state. Full * replace of the current state_metadata. @@ -33,7 +33,7 @@ class MarkInsightAcceptedRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $etag = ''; + protected $etag = ''; /** * @param string $name Required. Name of the insight. Please see diff --git a/Recommender/src/V1/MarkRecommendationClaimedRequest.php b/Recommender/src/V1/MarkRecommendationClaimedRequest.php index 89212b22d108..a95547ef0f17 100644 --- a/Recommender/src/V1/MarkRecommendationClaimedRequest.php +++ b/Recommender/src/V1/MarkRecommendationClaimedRequest.php @@ -20,7 +20,7 @@ class MarkRecommendationClaimedRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * State properties to include with this state. Overwrites any existing * `state_metadata`. @@ -35,7 +35,7 @@ class MarkRecommendationClaimedRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $etag = ''; + protected $etag = ''; /** * @param string $name Required. Name of the recommendation. Please see diff --git a/Recommender/src/V1/MarkRecommendationDismissedRequest.php b/Recommender/src/V1/MarkRecommendationDismissedRequest.php index f502aa807e6f..41cc6032babd 100644 --- a/Recommender/src/V1/MarkRecommendationDismissedRequest.php +++ b/Recommender/src/V1/MarkRecommendationDismissedRequest.php @@ -20,13 +20,13 @@ class MarkRecommendationDismissedRequest extends \Google\Protobuf\Internal\Messa * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Fingerprint of the Recommendation. Provides optimistic locking. * * Generated from protobuf field string etag = 2; */ - private $etag = ''; + protected $etag = ''; /** * Constructor. diff --git a/Recommender/src/V1/MarkRecommendationFailedRequest.php b/Recommender/src/V1/MarkRecommendationFailedRequest.php index 90ff20a74dde..9130a402746f 100644 --- a/Recommender/src/V1/MarkRecommendationFailedRequest.php +++ b/Recommender/src/V1/MarkRecommendationFailedRequest.php @@ -20,7 +20,7 @@ class MarkRecommendationFailedRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * State properties to include with this state. Overwrites any existing * `state_metadata`. @@ -35,7 +35,7 @@ class MarkRecommendationFailedRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $etag = ''; + protected $etag = ''; /** * @param string $name Required. Name of the recommendation. Please see diff --git a/Recommender/src/V1/MarkRecommendationSucceededRequest.php b/Recommender/src/V1/MarkRecommendationSucceededRequest.php index 1f36c5ae6a85..5d95a39fbe78 100644 --- a/Recommender/src/V1/MarkRecommendationSucceededRequest.php +++ b/Recommender/src/V1/MarkRecommendationSucceededRequest.php @@ -20,7 +20,7 @@ class MarkRecommendationSucceededRequest extends \Google\Protobuf\Internal\Messa * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * State properties to include with this state. Overwrites any existing * `state_metadata`. @@ -35,7 +35,7 @@ class MarkRecommendationSucceededRequest extends \Google\Protobuf\Internal\Messa * * Generated from protobuf field string etag = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $etag = ''; + protected $etag = ''; /** * @param string $name Required. Name of the recommendation. Please see diff --git a/Recommender/src/V1/Operation.php b/Recommender/src/V1/Operation.php index f68fcfecdb2e..096085bea6f7 100644 --- a/Recommender/src/V1/Operation.php +++ b/Recommender/src/V1/Operation.php @@ -29,7 +29,7 @@ class Operation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string action = 1; */ - private $action = ''; + protected $action = ''; /** * Type of GCP resource being modified/tested. This field is always populated. * Example: cloudresourcemanager.googleapis.com/Project, @@ -37,21 +37,21 @@ class Operation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string resource_type = 2; */ - private $resource_type = ''; + protected $resource_type = ''; /** * Contains the fully qualified resource name. This field is always populated. * ex: //cloudresourcemanager.googleapis.com/projects/foo. * * Generated from protobuf field string resource = 3; */ - private $resource = ''; + protected $resource = ''; /** * Path to the target field being operated on. If the operation is at the * resource level, then path should be "/". This field is always populated. * * Generated from protobuf field string path = 4; */ - private $path = ''; + protected $path = ''; /** * Can be set with action 'copy' to copy resource configuration across * different resources of the same type. Example: A resource clone can be @@ -61,14 +61,14 @@ class Operation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_resource = 5; */ - private $source_resource = ''; + protected $source_resource = ''; /** * Can be set with action 'copy' or 'move' to indicate the source field within * resource or source_resource, ignored if provided for other operation types. * * Generated from protobuf field string source_path = 6; */ - private $source_path = ''; + protected $source_path = ''; /** * Set of filters to apply if `path` refers to array elements or nested array * elements in order to narrow down to a single unique element that is being diff --git a/Recommender/src/V1/README.md b/Recommender/src/V1/README.md deleted file mode 100644 index 3a66cc55f0fa..000000000000 --- a/Recommender/src/V1/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Recommender V1 generated client for PHP - -### Sample - -```php -require 'vendor/autoload.php'; - -use Google\Cloud\Recommender\V1\RecommenderClient; - -$client = new RecommenderClient(); - -$recommendations = $client->listRecommendations( - RecommenderClient::recommenderName( - '[MY_PROJECT_ID]', - 'us-central1', - 'google.compute.instance.MachineTypeRecommender' - ) -); - -foreach ($recommendations as $recommendation) { - printf( - 'Found recommendation: %s' . PHP_EOL, - $recommendation->getName() - ); -} -``` diff --git a/Recommender/src/V1/Recommendation.php b/Recommender/src/V1/Recommendation.php index d52d86079a5e..0883027776d1 100644 --- a/Recommender/src/V1/Recommendation.php +++ b/Recommender/src/V1/Recommendation.php @@ -21,14 +21,14 @@ class Recommendation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Free-form human readable summary in English. The maximum length is 500 * characters. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * Contains an identifier for a subtype of recommendations produced for the * same recommender. Subtype is a function of content and impact, meaning a @@ -41,21 +41,21 @@ class Recommendation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string recommender_subtype = 12; */ - private $recommender_subtype = ''; + protected $recommender_subtype = ''; /** * Last time this recommendation was refreshed by the system that created it * in the first place. * * Generated from protobuf field .google.protobuf.Timestamp last_refresh_time = 4; */ - private $last_refresh_time = null; + protected $last_refresh_time = null; /** * The primary impact that this recommendation can have while trying to * optimize for one category. * * Generated from protobuf field .google.cloud.recommender.v1.Impact primary_impact = 5; */ - private $primary_impact = null; + protected $primary_impact = null; /** * Optional set of additional impact that this recommendation may have when * trying to optimize for the primary category. These may be positive @@ -69,26 +69,26 @@ class Recommendation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.recommender.v1.Recommendation.Priority priority = 17; */ - private $priority = 0; + protected $priority = 0; /** * Content of the recommendation describing recommended changes to resources. * * Generated from protobuf field .google.cloud.recommender.v1.RecommendationContent content = 7; */ - private $content = null; + protected $content = null; /** * Information for state. Contains state and metadata. * * Generated from protobuf field .google.cloud.recommender.v1.RecommendationStateInfo state_info = 10; */ - private $state_info = null; + protected $state_info = null; /** * Fingerprint of the Recommendation. Provides optimistic locking when * updating states. * * Generated from protobuf field string etag = 11; */ - private $etag = ''; + protected $etag = ''; /** * Insights that led to this recommendation. * @@ -103,7 +103,7 @@ class Recommendation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string xor_group_id = 18; */ - private $xor_group_id = ''; + protected $xor_group_id = ''; /** * Constructor. diff --git a/Recommender/src/V1/Recommendation/InsightReference.php b/Recommender/src/V1/Recommendation/InsightReference.php index 8821bd3f8e6f..a5796a420d78 100644 --- a/Recommender/src/V1/Recommendation/InsightReference.php +++ b/Recommender/src/V1/Recommendation/InsightReference.php @@ -21,7 +21,7 @@ class InsightReference extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string insight = 1; */ - private $insight = ''; + protected $insight = ''; /** * Constructor. @@ -69,6 +69,4 @@ public function setInsight($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(InsightReference::class, \Google\Cloud\Recommender\V1\Recommendation_InsightReference::class); diff --git a/Recommender/src/V1/Recommendation/Priority.php b/Recommender/src/V1/Recommendation/Priority.php index 0077380a5659..bccc20ecfb36 100644 --- a/Recommender/src/V1/Recommendation/Priority.php +++ b/Recommender/src/V1/Recommendation/Priority.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Priority::class, \Google\Cloud\Recommender\V1\Recommendation_Priority::class); diff --git a/Recommender/src/V1/RecommendationContent.php b/Recommender/src/V1/RecommendationContent.php index b0c05e016ac4..8f9bc53a3a93 100644 --- a/Recommender/src/V1/RecommendationContent.php +++ b/Recommender/src/V1/RecommendationContent.php @@ -28,7 +28,7 @@ class RecommendationContent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct overview = 3; */ - private $overview = null; + protected $overview = null; /** * Constructor. diff --git a/Recommender/src/V1/RecommendationStateInfo.php b/Recommender/src/V1/RecommendationStateInfo.php index afeb1c945614..af3d2fa1cc79 100644 --- a/Recommender/src/V1/RecommendationStateInfo.php +++ b/Recommender/src/V1/RecommendationStateInfo.php @@ -20,7 +20,7 @@ class RecommendationStateInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.recommender.v1.RecommendationStateInfo.State state = 1; */ - private $state = 0; + protected $state = 0; /** * A map of metadata for the state, provided by user or automations systems. * diff --git a/Recommender/src/V1/RecommendationStateInfo/State.php b/Recommender/src/V1/RecommendationStateInfo/State.php index 4813573e86d2..c54b8a53a393 100644 --- a/Recommender/src/V1/RecommendationStateInfo/State.php +++ b/Recommender/src/V1/RecommendationStateInfo/State.php @@ -90,6 +90,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\Recommender\V1\RecommendationStateInfo_State::class); diff --git a/Recommender/src/V1/RecommendationStateInfo_State.php b/Recommender/src/V1/RecommendationStateInfo_State.php deleted file mode 100644 index cf8233f27f56..000000000000 --- a/Recommender/src/V1/RecommendationStateInfo_State.php +++ /dev/null @@ -1,16 +0,0 @@ -string name = 1; */ - private $name = ''; + protected $name = ''; /** * RecommenderGenerationConfig which configures the Generation of * recommendations for this recommender. * * Generated from protobuf field .google.cloud.recommender.v1.RecommenderGenerationConfig recommender_generation_config = 2; */ - private $recommender_generation_config = null; + protected $recommender_generation_config = null; /** * Fingerprint of the RecommenderConfig. Provides optimistic locking when * updating. * * Generated from protobuf field string etag = 3; */ - private $etag = ''; + protected $etag = ''; /** * Last time when the config was updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 4; */ - private $update_time = null; + protected $update_time = null; /** * Output only. Immutable. The revision ID of the config. * A new revision is committed whenever the config is changed in any way. @@ -50,7 +50,7 @@ class RecommenderConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string revision_id = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $revision_id = ''; + protected $revision_id = ''; /** * Allows clients to store small amounts of arbitrary data. Annotations must * follow the Kubernetes syntax. @@ -70,7 +70,7 @@ class RecommenderConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 7; */ - private $display_name = ''; + protected $display_name = ''; /** * Constructor. diff --git a/Recommender/src/V1/RecommenderGenerationConfig.php b/Recommender/src/V1/RecommenderGenerationConfig.php index 1e3ef7d2718f..7c2e642c0a83 100644 --- a/Recommender/src/V1/RecommenderGenerationConfig.php +++ b/Recommender/src/V1/RecommenderGenerationConfig.php @@ -23,7 +23,7 @@ class RecommenderGenerationConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct params = 1; */ - private $params = null; + protected $params = null; /** * Constructor. diff --git a/Recommender/src/V1/RecommenderGrpcClient.php b/Recommender/src/V1/RecommenderGrpcClient.php deleted file mode 100644 index 61220c4d7a6b..000000000000 --- a/Recommender/src/V1/RecommenderGrpcClient.php +++ /dev/null @@ -1,260 +0,0 @@ -_simpleRequest('/google.cloud.recommender.v1.Recommender/ListInsights', - $argument, - ['\Google\Cloud\Recommender\V1\ListInsightsResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets the requested insight. Requires the recommender.*.get IAM permission - * for the specified insight type. - * @param \Google\Cloud\Recommender\V1\GetInsightRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetInsight(\Google\Cloud\Recommender\V1\GetInsightRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/GetInsight', - $argument, - ['\Google\Cloud\Recommender\V1\Insight', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\Recommender\V1\MarkInsightAcceptedRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function MarkInsightAccepted(\Google\Cloud\Recommender\V1\MarkInsightAcceptedRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/MarkInsightAccepted', - $argument, - ['\Google\Cloud\Recommender\V1\Insight', 'decode'], - $metadata, $options); - } - - /** - * Lists recommendations for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified recommender. - * @param \Google\Cloud\Recommender\V1\ListRecommendationsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListRecommendations(\Google\Cloud\Recommender\V1\ListRecommendationsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/ListRecommendations', - $argument, - ['\Google\Cloud\Recommender\V1\ListRecommendationsResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets the requested recommendation. Requires the recommender.*.get - * IAM permission for the specified recommender. - * @param \Google\Cloud\Recommender\V1\GetRecommendationRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetRecommendation(\Google\Cloud\Recommender\V1\GetRecommendationRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/GetRecommendation', - $argument, - ['\Google\Cloud\Recommender\V1\Recommendation', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\Recommender\V1\MarkRecommendationClaimedRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function MarkRecommendationClaimed(\Google\Cloud\Recommender\V1\MarkRecommendationClaimedRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/MarkRecommendationClaimed', - $argument, - ['\Google\Cloud\Recommender\V1\Recommendation', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\Recommender\V1\MarkRecommendationSucceededRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function MarkRecommendationSucceeded(\Google\Cloud\Recommender\V1\MarkRecommendationSucceededRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/MarkRecommendationSucceeded', - $argument, - ['\Google\Cloud\Recommender\V1\Recommendation', 'decode'], - $metadata, $options); - } - - /** - * 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. - * @param \Google\Cloud\Recommender\V1\MarkRecommendationFailedRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function MarkRecommendationFailed(\Google\Cloud\Recommender\V1\MarkRecommendationFailedRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/MarkRecommendationFailed', - $argument, - ['\Google\Cloud\Recommender\V1\Recommendation', 'decode'], - $metadata, $options); - } - - /** - * Gets the requested Recommender Config. There is only one instance of the - * config for each Recommender. - * @param \Google\Cloud\Recommender\V1\GetRecommenderConfigRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetRecommenderConfig(\Google\Cloud\Recommender\V1\GetRecommenderConfigRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/GetRecommenderConfig', - $argument, - ['\Google\Cloud\Recommender\V1\RecommenderConfig', 'decode'], - $metadata, $options); - } - - /** - * Updates a Recommender Config. This will create a new revision of the - * config. - * @param \Google\Cloud\Recommender\V1\UpdateRecommenderConfigRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateRecommenderConfig(\Google\Cloud\Recommender\V1\UpdateRecommenderConfigRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/UpdateRecommenderConfig', - $argument, - ['\Google\Cloud\Recommender\V1\RecommenderConfig', 'decode'], - $metadata, $options); - } - - /** - * Gets the requested InsightTypeConfig. There is only one instance of the - * config for each InsightType. - * @param \Google\Cloud\Recommender\V1\GetInsightTypeConfigRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetInsightTypeConfig(\Google\Cloud\Recommender\V1\GetInsightTypeConfigRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/GetInsightTypeConfig', - $argument, - ['\Google\Cloud\Recommender\V1\InsightTypeConfig', 'decode'], - $metadata, $options); - } - - /** - * Updates an InsightTypeConfig change. This will create a new revision of the - * config. - * @param \Google\Cloud\Recommender\V1\UpdateInsightTypeConfigRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateInsightTypeConfig(\Google\Cloud\Recommender\V1\UpdateInsightTypeConfigRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.recommender.v1.Recommender/UpdateInsightTypeConfig', - $argument, - ['\Google\Cloud\Recommender\V1\InsightTypeConfig', 'decode'], - $metadata, $options); - } - -} diff --git a/Recommender/src/V1/ReliabilityProjection.php b/Recommender/src/V1/ReliabilityProjection.php index 30704356bbcb..10f00f46f499 100644 --- a/Recommender/src/V1/ReliabilityProjection.php +++ b/Recommender/src/V1/ReliabilityProjection.php @@ -26,7 +26,7 @@ class ReliabilityProjection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct details = 2; */ - private $details = null; + protected $details = null; /** * Constructor. diff --git a/Recommender/src/V1/ReliabilityProjection/RiskType.php b/Recommender/src/V1/ReliabilityProjection/RiskType.php index 3f37986fd3a7..6684f137e5f3 100644 --- a/Recommender/src/V1/ReliabilityProjection/RiskType.php +++ b/Recommender/src/V1/ReliabilityProjection/RiskType.php @@ -67,6 +67,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(RiskType::class, \Google\Cloud\Recommender\V1\ReliabilityProjection_RiskType::class); diff --git a/Recommender/src/V1/SecurityProjection.php b/Recommender/src/V1/SecurityProjection.php index 0e79b9712b74..dffe739191c5 100644 --- a/Recommender/src/V1/SecurityProjection.php +++ b/Recommender/src/V1/SecurityProjection.php @@ -20,7 +20,7 @@ class SecurityProjection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Struct details = 2; */ - private $details = null; + protected $details = null; /** * Constructor. diff --git a/Recommender/src/V1/SustainabilityProjection.php b/Recommender/src/V1/SustainabilityProjection.php index 6bf61957af1c..a1d4678563e6 100644 --- a/Recommender/src/V1/SustainabilityProjection.php +++ b/Recommender/src/V1/SustainabilityProjection.php @@ -22,13 +22,13 @@ class SustainabilityProjection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double kg_c_o2e = 1; */ - private $kg_c_o2e = 0.0; + protected $kg_c_o2e = 0.0; /** * Duration for which this sustainability applies. * * Generated from protobuf field .google.protobuf.Duration duration = 2; */ - private $duration = null; + protected $duration = null; /** * Constructor. diff --git a/Recommender/src/V1/UpdateInsightTypeConfigRequest.php b/Recommender/src/V1/UpdateInsightTypeConfigRequest.php index 026130f46ae8..6c402f186c4c 100644 --- a/Recommender/src/V1/UpdateInsightTypeConfigRequest.php +++ b/Recommender/src/V1/UpdateInsightTypeConfigRequest.php @@ -20,20 +20,20 @@ class UpdateInsightTypeConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.recommender.v1.InsightTypeConfig insight_type_config = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $insight_type_config = null; + protected $insight_type_config = null; /** * The list of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * If true, validate the request and preview the change, but do not actually * update it. * * Generated from protobuf field bool validate_only = 3; */ - private $validate_only = false; + protected $validate_only = false; /** * @param \Google\Cloud\Recommender\V1\InsightTypeConfig $insightTypeConfig Required. The InsightTypeConfig to update. diff --git a/Recommender/src/V1/UpdateRecommenderConfigRequest.php b/Recommender/src/V1/UpdateRecommenderConfigRequest.php index a48649df7769..9977e4f6feff 100644 --- a/Recommender/src/V1/UpdateRecommenderConfigRequest.php +++ b/Recommender/src/V1/UpdateRecommenderConfigRequest.php @@ -20,20 +20,20 @@ class UpdateRecommenderConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.recommender.v1.RecommenderConfig recommender_config = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $recommender_config = null; + protected $recommender_config = null; /** * The list of fields to be updated. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; */ - private $update_mask = null; + protected $update_mask = null; /** * If true, validate the request and preview the change, but do not actually * update it. * * Generated from protobuf field bool validate_only = 3; */ - private $validate_only = false; + protected $validate_only = false; /** * @param \Google\Cloud\Recommender\V1\RecommenderConfig $recommenderConfig Required. The RecommenderConfig to update. diff --git a/Recommender/tests/Unit/V1/Client/RecommenderClientTest.php b/Recommender/tests/Unit/V1/Client/RecommenderClientTest.php index c277a8ff0e36..29e107558f34 100644 --- a/Recommender/tests/Unit/V1/Client/RecommenderClientTest.php +++ b/Recommender/tests/Unit/V1/Client/RecommenderClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return RecommenderClient */ @@ -98,8 +100,7 @@ public function getInsightTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - $request = (new GetInsightRequest()) - ->setName($formattedName); + $request = (new GetInsightRequest())->setName($formattedName); $response = $gapicClient->getInsight($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -123,17 +124,19 @@ public function getInsightExceptionTest() $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); + $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->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - $request = (new GetInsightRequest()) - ->setName($formattedName); + $request = (new GetInsightRequest())->setName($formattedName); try { $gapicClient->getInsight($request); // If the $gapicClient method call did not throw, fail the test @@ -168,8 +171,7 @@ public function getInsightTypeConfigTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->insightTypeConfigName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - $request = (new GetInsightTypeConfigRequest()) - ->setName($formattedName); + $request = (new GetInsightTypeConfigRequest())->setName($formattedName); $response = $gapicClient->getInsightTypeConfig($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -193,17 +195,19 @@ public function getInsightTypeConfigExceptionTest() $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); + $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->insightTypeConfigName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - $request = (new GetInsightTypeConfigRequest()) - ->setName($formattedName); + $request = (new GetInsightTypeConfigRequest())->setName($formattedName); try { $gapicClient->getInsightTypeConfig($request); // If the $gapicClient method call did not throw, fail the test @@ -239,9 +243,13 @@ public function getRecommendationTest() $expectedResponse->setXorGroupId($xorGroupId); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $request = (new GetRecommendationRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); + $request = (new GetRecommendationRequest())->setName($formattedName); $response = $gapicClient->getRecommendation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -265,17 +273,24 @@ public function getRecommendationExceptionTest() $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); + $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $request = (new GetRecommendationRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); + $request = (new GetRecommendationRequest())->setName($formattedName); try { $gapicClient->getRecommendation($request); // If the $gapicClient method call did not throw, fail the test @@ -310,8 +325,7 @@ public function getRecommenderConfigTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->recommenderConfigName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - $request = (new GetRecommenderConfigRequest()) - ->setName($formattedName); + $request = (new GetRecommenderConfigRequest())->setName($formattedName); $response = $gapicClient->getRecommenderConfig($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -335,17 +349,19 @@ public function getRecommenderConfigExceptionTest() $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); + $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->recommenderConfigName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - $request = (new GetRecommenderConfigRequest()) - ->setName($formattedName); + $request = (new GetRecommenderConfigRequest())->setName($formattedName); try { $gapicClient->getRecommenderConfig($request); // If the $gapicClient method call did not throw, fail the test @@ -370,17 +386,14 @@ public function listInsightsTest() // Mock response $nextPageToken = ''; $insightsElement = new Insight(); - $insights = [ - $insightsElement, - ]; + $insights = [$insightsElement]; $expectedResponse = new ListInsightsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setInsights($insights); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->insightTypeName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - $request = (new ListInsightsRequest()) - ->setParent($formattedParent); + $request = (new ListInsightsRequest())->setParent($formattedParent); $response = $gapicClient->listInsights($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -407,17 +420,19 @@ public function listInsightsExceptionTest() $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); + $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->insightTypeName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - $request = (new ListInsightsRequest()) - ->setParent($formattedParent); + $request = (new ListInsightsRequest())->setParent($formattedParent); try { $gapicClient->listInsights($request); // If the $gapicClient method call did not throw, fail the test @@ -442,17 +457,14 @@ public function listRecommendationsTest() // Mock response $nextPageToken = ''; $recommendationsElement = new Recommendation(); - $recommendations = [ - $recommendationsElement, - ]; + $recommendations = [$recommendationsElement]; $expectedResponse = new ListRecommendationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setRecommendations($recommendations); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->recommenderName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - $request = (new ListRecommendationsRequest()) - ->setParent($formattedParent); + $request = (new ListRecommendationsRequest())->setParent($formattedParent); $response = $gapicClient->listRecommendations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -479,17 +491,19 @@ public function listRecommendationsExceptionTest() $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); + $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->recommenderName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - $request = (new ListRecommendationsRequest()) - ->setParent($formattedParent); + $request = (new ListRecommendationsRequest())->setParent($formattedParent); try { $gapicClient->listRecommendations($request); // If the $gapicClient method call did not throw, fail the test @@ -525,9 +539,7 @@ public function markInsightAcceptedTest() // Mock request $formattedName = $gapicClient->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); $etag = 'etag3123477'; - $request = (new MarkInsightAcceptedRequest()) - ->setName($formattedName) - ->setEtag($etag); + $request = (new MarkInsightAcceptedRequest())->setName($formattedName)->setEtag($etag); $response = $gapicClient->markInsightAccepted($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -553,19 +565,20 @@ public function markInsightAcceptedExceptionTest() $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); + $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->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); $etag = 'etag3123477'; - $request = (new MarkInsightAcceptedRequest()) - ->setName($formattedName) - ->setEtag($etag); + $request = (new MarkInsightAcceptedRequest())->setName($formattedName)->setEtag($etag); try { $gapicClient->markInsightAccepted($request); // If the $gapicClient method call did not throw, fail the test @@ -601,11 +614,14 @@ public function markRecommendationClaimedTest() $expectedResponse->setXorGroupId($xorGroupId); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); $etag = 'etag3123477'; - $request = (new MarkRecommendationClaimedRequest()) - ->setName($formattedName) - ->setEtag($etag); + $request = (new MarkRecommendationClaimedRequest())->setName($formattedName)->setEtag($etag); $response = $gapicClient->markRecommendationClaimed($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -631,19 +647,25 @@ public function markRecommendationClaimedExceptionTest() $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); + $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); $etag = 'etag3123477'; - $request = (new MarkRecommendationClaimedRequest()) - ->setName($formattedName) - ->setEtag($etag); + $request = (new MarkRecommendationClaimedRequest())->setName($formattedName)->setEtag($etag); try { $gapicClient->markRecommendationClaimed($request); // If the $gapicClient method call did not throw, fail the test @@ -679,9 +701,13 @@ public function markRecommendationDismissedTest() $expectedResponse->setXorGroupId($xorGroupId); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $request = (new MarkRecommendationDismissedRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); + $request = (new MarkRecommendationDismissedRequest())->setName($formattedName); $response = $gapicClient->markRecommendationDismissed($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -705,17 +731,24 @@ public function markRecommendationDismissedExceptionTest() $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); + $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $request = (new MarkRecommendationDismissedRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); + $request = (new MarkRecommendationDismissedRequest())->setName($formattedName); try { $gapicClient->markRecommendationDismissed($request); // If the $gapicClient method call did not throw, fail the test @@ -751,11 +784,14 @@ public function markRecommendationFailedTest() $expectedResponse->setXorGroupId($xorGroupId); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); $etag = 'etag3123477'; - $request = (new MarkRecommendationFailedRequest()) - ->setName($formattedName) - ->setEtag($etag); + $request = (new MarkRecommendationFailedRequest())->setName($formattedName)->setEtag($etag); $response = $gapicClient->markRecommendationFailed($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -781,19 +817,25 @@ public function markRecommendationFailedExceptionTest() $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); + $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); $etag = 'etag3123477'; - $request = (new MarkRecommendationFailedRequest()) - ->setName($formattedName) - ->setEtag($etag); + $request = (new MarkRecommendationFailedRequest())->setName($formattedName)->setEtag($etag); try { $gapicClient->markRecommendationFailed($request); // If the $gapicClient method call did not throw, fail the test @@ -829,11 +871,14 @@ public function markRecommendationSucceededTest() $expectedResponse->setXorGroupId($xorGroupId); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); $etag = 'etag3123477'; - $request = (new MarkRecommendationSucceededRequest()) - ->setName($formattedName) - ->setEtag($etag); + $request = (new MarkRecommendationSucceededRequest())->setName($formattedName)->setEtag($etag); $response = $gapicClient->markRecommendationSucceeded($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -859,19 +904,25 @@ public function markRecommendationSucceededExceptionTest() $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); + $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); + $formattedName = $gapicClient->recommendationName( + '[PROJECT]', + '[LOCATION]', + '[RECOMMENDER]', + '[RECOMMENDATION]' + ); $etag = 'etag3123477'; - $request = (new MarkRecommendationSucceededRequest()) - ->setName($formattedName) - ->setEtag($etag); + $request = (new MarkRecommendationSucceededRequest())->setName($formattedName)->setEtag($etag); try { $gapicClient->markRecommendationSucceeded($request); // If the $gapicClient method call did not throw, fail the test @@ -906,8 +957,7 @@ public function updateInsightTypeConfigTest() $transport->addResponse($expectedResponse); // Mock request $insightTypeConfig = new InsightTypeConfig(); - $request = (new UpdateInsightTypeConfigRequest()) - ->setInsightTypeConfig($insightTypeConfig); + $request = (new UpdateInsightTypeConfigRequest())->setInsightTypeConfig($insightTypeConfig); $response = $gapicClient->updateInsightTypeConfig($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -931,17 +981,19 @@ public function updateInsightTypeConfigExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $insightTypeConfig = new InsightTypeConfig(); - $request = (new UpdateInsightTypeConfigRequest()) - ->setInsightTypeConfig($insightTypeConfig); + $request = (new UpdateInsightTypeConfigRequest())->setInsightTypeConfig($insightTypeConfig); try { $gapicClient->updateInsightTypeConfig($request); // If the $gapicClient method call did not throw, fail the test @@ -976,8 +1028,7 @@ public function updateRecommenderConfigTest() $transport->addResponse($expectedResponse); // Mock request $recommenderConfig = new RecommenderConfig(); - $request = (new UpdateRecommenderConfigRequest()) - ->setRecommenderConfig($recommenderConfig); + $request = (new UpdateRecommenderConfigRequest())->setRecommenderConfig($recommenderConfig); $response = $gapicClient->updateRecommenderConfig($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1001,17 +1052,19 @@ public function updateRecommenderConfigExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $recommenderConfig = new RecommenderConfig(); - $request = (new UpdateRecommenderConfigRequest()) - ->setRecommenderConfig($recommenderConfig); + $request = (new UpdateRecommenderConfigRequest())->setRecommenderConfig($recommenderConfig); try { $gapicClient->updateRecommenderConfig($request); // If the $gapicClient method call did not throw, fail the test @@ -1046,8 +1099,7 @@ public function getInsightAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - $request = (new GetInsightRequest()) - ->setName($formattedName); + $request = (new GetInsightRequest())->setName($formattedName); $response = $gapicClient->getInsightAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); diff --git a/Recommender/tests/Unit/V1/RecommenderClientTest.php b/Recommender/tests/Unit/V1/RecommenderClientTest.php deleted file mode 100644 index a9e84f071eeb..000000000000 --- a/Recommender/tests/Unit/V1/RecommenderClientTest.php +++ /dev/null @@ -1,954 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return RecommenderClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new RecommenderClient($options); - } - - /** @test */ - public function getInsightTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $insightSubtype = 'insightSubtype-1491142701'; - $etag = 'etag3123477'; - $expectedResponse = new Insight(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setInsightSubtype($insightSubtype); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - $response = $gapicClient->getInsight($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.recommender.v1.Recommender/GetInsight', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getInsightExceptionTest() - { - $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->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - try { - $gapicClient->getInsight($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 getInsightTypeConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $etag = 'etag3123477'; - $revisionId = 'revisionId513861631'; - $displayName = 'displayName1615086568'; - $expectedResponse = new InsightTypeConfig(); - $expectedResponse->setName($name2); - $expectedResponse->setEtag($etag); - $expectedResponse->setRevisionId($revisionId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->insightTypeConfigName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - $response = $gapicClient->getInsightTypeConfig($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.recommender.v1.Recommender/GetInsightTypeConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getInsightTypeConfigExceptionTest() - { - $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->insightTypeConfigName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - try { - $gapicClient->getInsightTypeConfig($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 getRecommendationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $recommenderSubtype = 'recommenderSubtype-1488504412'; - $etag = 'etag3123477'; - $xorGroupId = 'xorGroupId381095487'; - $expectedResponse = new Recommendation(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setRecommenderSubtype($recommenderSubtype); - $expectedResponse->setEtag($etag); - $expectedResponse->setXorGroupId($xorGroupId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $response = $gapicClient->getRecommendation($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.recommender.v1.Recommender/GetRecommendation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getRecommendationExceptionTest() - { - $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - try { - $gapicClient->getRecommendation($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 getRecommenderConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $etag = 'etag3123477'; - $revisionId = 'revisionId513861631'; - $displayName = 'displayName1615086568'; - $expectedResponse = new RecommenderConfig(); - $expectedResponse->setName($name2); - $expectedResponse->setEtag($etag); - $expectedResponse->setRevisionId($revisionId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->recommenderConfigName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - $response = $gapicClient->getRecommenderConfig($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.recommender.v1.Recommender/GetRecommenderConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getRecommenderConfigExceptionTest() - { - $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->recommenderConfigName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - try { - $gapicClient->getRecommenderConfig($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 listInsightsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $insightsElement = new Insight(); - $insights = [ - $insightsElement, - ]; - $expectedResponse = new ListInsightsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setInsights($insights); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->insightTypeName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - $response = $gapicClient->listInsights($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getInsights()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.recommender.v1.Recommender/ListInsights', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listInsightsExceptionTest() - { - $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->insightTypeName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]'); - try { - $gapicClient->listInsights($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 listRecommendationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $recommendationsElement = new Recommendation(); - $recommendations = [ - $recommendationsElement, - ]; - $expectedResponse = new ListRecommendationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setRecommendations($recommendations); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->recommenderName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - $response = $gapicClient->listRecommendations($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getRecommendations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.recommender.v1.Recommender/ListRecommendations', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listRecommendationsExceptionTest() - { - $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->recommenderName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]'); - try { - $gapicClient->listRecommendations($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 markInsightAcceptedTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $insightSubtype = 'insightSubtype-1491142701'; - $etag2 = 'etag2-1293302904'; - $expectedResponse = new Insight(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setInsightSubtype($insightSubtype); - $expectedResponse->setEtag($etag2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - $etag = 'etag3123477'; - $response = $gapicClient->markInsightAccepted($formattedName, $etag); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.recommender.v1.Recommender/MarkInsightAccepted', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getEtag(); - $this->assertProtobufEquals($etag, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function markInsightAcceptedExceptionTest() - { - $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->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]'); - $etag = 'etag3123477'; - try { - $gapicClient->markInsightAccepted($formattedName, $etag); - // 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 markRecommendationClaimedTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $recommenderSubtype = 'recommenderSubtype-1488504412'; - $etag2 = 'etag2-1293302904'; - $xorGroupId = 'xorGroupId381095487'; - $expectedResponse = new Recommendation(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setRecommenderSubtype($recommenderSubtype); - $expectedResponse->setEtag($etag2); - $expectedResponse->setXorGroupId($xorGroupId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $etag = 'etag3123477'; - $response = $gapicClient->markRecommendationClaimed($formattedName, $etag); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.recommender.v1.Recommender/MarkRecommendationClaimed', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getEtag(); - $this->assertProtobufEquals($etag, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function markRecommendationClaimedExceptionTest() - { - $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $etag = 'etag3123477'; - try { - $gapicClient->markRecommendationClaimed($formattedName, $etag); - // 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 markRecommendationDismissedTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $recommenderSubtype = 'recommenderSubtype-1488504412'; - $etag2 = 'etag2-1293302904'; - $xorGroupId = 'xorGroupId381095487'; - $expectedResponse = new Recommendation(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setRecommenderSubtype($recommenderSubtype); - $expectedResponse->setEtag($etag2); - $expectedResponse->setXorGroupId($xorGroupId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $response = $gapicClient->markRecommendationDismissed($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.recommender.v1.Recommender/MarkRecommendationDismissed', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function markRecommendationDismissedExceptionTest() - { - $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - try { - $gapicClient->markRecommendationDismissed($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 markRecommendationFailedTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $recommenderSubtype = 'recommenderSubtype-1488504412'; - $etag2 = 'etag2-1293302904'; - $xorGroupId = 'xorGroupId381095487'; - $expectedResponse = new Recommendation(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setRecommenderSubtype($recommenderSubtype); - $expectedResponse->setEtag($etag2); - $expectedResponse->setXorGroupId($xorGroupId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $etag = 'etag3123477'; - $response = $gapicClient->markRecommendationFailed($formattedName, $etag); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.recommender.v1.Recommender/MarkRecommendationFailed', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getEtag(); - $this->assertProtobufEquals($etag, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function markRecommendationFailedExceptionTest() - { - $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $etag = 'etag3123477'; - try { - $gapicClient->markRecommendationFailed($formattedName, $etag); - // 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 markRecommendationSucceededTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $description = 'description-1724546052'; - $recommenderSubtype = 'recommenderSubtype-1488504412'; - $etag2 = 'etag2-1293302904'; - $xorGroupId = 'xorGroupId381095487'; - $expectedResponse = new Recommendation(); - $expectedResponse->setName($name2); - $expectedResponse->setDescription($description); - $expectedResponse->setRecommenderSubtype($recommenderSubtype); - $expectedResponse->setEtag($etag2); - $expectedResponse->setXorGroupId($xorGroupId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $etag = 'etag3123477'; - $response = $gapicClient->markRecommendationSucceeded($formattedName, $etag); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.recommender.v1.Recommender/MarkRecommendationSucceeded', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getEtag(); - $this->assertProtobufEquals($etag, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function markRecommendationSucceededExceptionTest() - { - $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->recommendationName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]'); - $etag = 'etag3123477'; - try { - $gapicClient->markRecommendationSucceeded($formattedName, $etag); - // 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 updateInsightTypeConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $etag = 'etag3123477'; - $revisionId = 'revisionId513861631'; - $displayName = 'displayName1615086568'; - $expectedResponse = new InsightTypeConfig(); - $expectedResponse->setName($name); - $expectedResponse->setEtag($etag); - $expectedResponse->setRevisionId($revisionId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $insightTypeConfig = new InsightTypeConfig(); - $response = $gapicClient->updateInsightTypeConfig($insightTypeConfig); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.recommender.v1.Recommender/UpdateInsightTypeConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getInsightTypeConfig(); - $this->assertProtobufEquals($insightTypeConfig, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateInsightTypeConfigExceptionTest() - { - $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 - $insightTypeConfig = new InsightTypeConfig(); - try { - $gapicClient->updateInsightTypeConfig($insightTypeConfig); - // 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 updateRecommenderConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $etag = 'etag3123477'; - $revisionId = 'revisionId513861631'; - $displayName = 'displayName1615086568'; - $expectedResponse = new RecommenderConfig(); - $expectedResponse->setName($name); - $expectedResponse->setEtag($etag); - $expectedResponse->setRevisionId($revisionId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $recommenderConfig = new RecommenderConfig(); - $response = $gapicClient->updateRecommenderConfig($recommenderConfig); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.recommender.v1.Recommender/UpdateRecommenderConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getRecommenderConfig(); - $this->assertProtobufEquals($recommenderConfig, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateRecommenderConfigExceptionTest() - { - $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 - $recommenderConfig = new RecommenderConfig(); - try { - $gapicClient->updateRecommenderConfig($recommenderConfig); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/ResourceSettings/owlbot.py b/ResourceSettings/owlbot.py index 8e9943546a6c..71d9af0a1da0 100644 --- a/ResourceSettings/owlbot.py +++ b/ResourceSettings/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,33 +41,6 @@ + "\n", '') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - # format generated clients subprocess.run([ 'npm', @@ -83,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) + '--print-width=120']) diff --git a/ResourceSettings/src/V1/Client/ResourceSettingsServiceClient.php b/ResourceSettings/src/V1/Client/ResourceSettingsServiceClient.php index 6d5483bb3dfe..937f4200a1ad 100644 --- a/ResourceSettings/src/V1/Client/ResourceSettingsServiceClient.php +++ b/ResourceSettings/src/V1/Client/ResourceSettingsServiceClient.php @@ -1,6 +1,6 @@ [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/resource_settings_service_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/resource_settings_service_rest_client_config.php', ], ], ]; diff --git a/ResourceSettings/src/V1/Gapic/ResourceSettingsServiceGapicClient.php b/ResourceSettings/src/V1/Gapic/ResourceSettingsServiceGapicClient.php deleted file mode 100644 index 735b280de306..000000000000 --- a/ResourceSettings/src/V1/Gapic/ResourceSettingsServiceGapicClient.php +++ /dev/null @@ -1,597 +0,0 @@ -settingName('[PROJECT_NUMBER]', '[SETTING_NAME]'); - * $response = $resourceSettingsServiceClient->getSetting($formattedName); - * } finally { - * $resourceSettingsServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\ResourceSettings\V1\Client\ResourceSettingsServiceClient}. - */ -class ResourceSettingsServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.resourcesettings.v1.ResourceSettingsService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'resourcesettings.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'resourcesettings.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $folderSettingNameNameTemplate; - - private static $organizationSettingNameNameTemplate; - - private static $projectNumberSettingNameNameTemplate; - - private static $settingNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getFolderSettingNameNameTemplate() - { - if (self::$folderSettingNameNameTemplate == null) { - self::$folderSettingNameNameTemplate = new PathTemplate( - 'folders/{folder}/settings/{setting_name}' - ); - } - - return self::$folderSettingNameNameTemplate; - } - - private static function getOrganizationSettingNameNameTemplate() - { - if (self::$organizationSettingNameNameTemplate == null) { - self::$organizationSettingNameNameTemplate = new PathTemplate( - 'organizations/{organization}/settings/{setting_name}' - ); - } - - return self::$organizationSettingNameNameTemplate; - } - - private static function getProjectNumberSettingNameNameTemplate() - { - if (self::$projectNumberSettingNameNameTemplate == null) { - self::$projectNumberSettingNameNameTemplate = new PathTemplate( - 'projects/{project_number}/settings/{setting_name}' - ); - } - - return self::$projectNumberSettingNameNameTemplate; - } - - private static function getSettingNameTemplate() - { - if (self::$settingNameTemplate == null) { - self::$settingNameTemplate = new PathTemplate( - 'projects/{project_number}/settings/{setting_name}' - ); - } - - return self::$settingNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'folderSettingName' => self::getFolderSettingNameNameTemplate(), - 'organizationSettingName' => self::getOrganizationSettingNameNameTemplate(), - 'projectNumberSettingName' => self::getProjectNumberSettingNameNameTemplate(), - 'setting' => self::getSettingNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($folder, $settingName) - { - return self::getFolderSettingNameNameTemplate()->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( - $organization, - $settingName - ) { - return self::getOrganizationSettingNameNameTemplate()->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( - $projectNumber, - $settingName - ) { - return self::getProjectNumberSettingNameNameTemplate()->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($projectNumber, $settingName) - { - return self::getSettingNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException( - "Template name $template does not exist" - ); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException( - "Input did not match any known format. Input: $formattedName" - ); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default '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); - } - - /** - * Gets a setting. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * setting does not exist. - * - * Sample code: - * ``` - * $resourceSettingsServiceClient = new ResourceSettingsServiceClient(); - * try { - * $formattedName = $resourceSettingsServiceClient->settingName('[PROJECT_NUMBER]', '[SETTING_NAME]'); - * $response = $resourceSettingsServiceClient->getSetting($formattedName); - * } finally { - * $resourceSettingsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the setting to get. See - * [Setting][google.cloud.resourcesettings.v1.Setting] for naming - * requirements. - * @param array $optionalArgs { - * Optional. - * - * @type int $view - * The SettingView for this request. - * For allowed values, use constants defined on {@see \Google\Cloud\ResourceSettings\V1\SettingView} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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\ResourceSettings\V1\Setting - * - * @throws ApiException if the remote call fails - */ - public function getSetting($name, array $optionalArgs = []) - { - $request = new GetSettingRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetSetting', - Setting::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists all the settings that are available on the Cloud resource `parent`. - * - * Sample code: - * ``` - * $resourceSettingsServiceClient = new ResourceSettingsServiceClient(); - * try { - * $parent = 'parent'; - * // Iterate over pages of elements - * $pagedResponse = $resourceSettingsServiceClient->listSettings($parent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $resourceSettingsServiceClient->listSettings($parent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $resourceSettingsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The Cloud resource that parents the setting. Must be in one of - * the following forms: - * - * * `projects/{project_number}` - * * `projects/{project_id}` - * * `folders/{folder_id}` - * * `organizations/{organization_id}` - * @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 int $view - * The SettingView for this request. - * For allowed values, use constants defined on {@see \Google\Cloud\ResourceSettings\V1\SettingView} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listSettings($parent, array $optionalArgs = []) - { - $request = new ListSettingsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListSettings', - $optionalArgs, - ListSettingsResponse::class, - $request - ); - } - - /** - * 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. - * - * Sample code: - * ``` - * $resourceSettingsServiceClient = new ResourceSettingsServiceClient(); - * try { - * $setting = new Setting(); - * $response = $resourceSettingsServiceClient->updateSetting($setting); - * } finally { - * $resourceSettingsServiceClient->close(); - * } - * ``` - * - * @param Setting $setting Required. The setting to update. See - * [Setting][google.cloud.resourcesettings.v1.Setting] for field requirements. - * @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\ResourceSettings\V1\Setting - * - * @throws ApiException if the remote call fails - */ - public function updateSetting($setting, array $optionalArgs = []) - { - $request = new UpdateSettingRequest(); - $requestParamHeaders = []; - $request->setSetting($setting); - $requestParamHeaders['setting.name'] = $setting->getName(); - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'UpdateSetting', - Setting::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/ResourceSettings/src/V1/GetSettingRequest.php b/ResourceSettings/src/V1/GetSettingRequest.php index 4e9469b716bd..c6eee9fa8d14 100644 --- a/ResourceSettings/src/V1/GetSettingRequest.php +++ b/ResourceSettings/src/V1/GetSettingRequest.php @@ -22,13 +22,13 @@ class GetSettingRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * The SettingView for this request. * * Generated from protobuf field .google.cloud.resourcesettings.v1.SettingView view = 2; */ - private $view = 0; + protected $view = 0; /** * @param string $name Required. The name of the setting to get. See diff --git a/ResourceSettings/src/V1/ListSettingsRequest.php b/ResourceSettings/src/V1/ListSettingsRequest.php index 869cbbe3267f..55dbf4f3fa79 100644 --- a/ResourceSettings/src/V1/ListSettingsRequest.php +++ b/ResourceSettings/src/V1/ListSettingsRequest.php @@ -25,25 +25,25 @@ class ListSettingsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Unused. The size of the page to be returned. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Unused. A page token used to retrieve the next page. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * The SettingView for this request. * * Generated from protobuf field .google.cloud.resourcesettings.v1.SettingView view = 4; */ - private $view = 0; + protected $view = 0; /** * @param string $parent Required. The Cloud resource that parents the setting. Must be in one of diff --git a/ResourceSettings/src/V1/ListSettingsResponse.php b/ResourceSettings/src/V1/ListSettingsResponse.php index e55b8727658c..7b1ed2d089dc 100644 --- a/ResourceSettings/src/V1/ListSettingsResponse.php +++ b/ResourceSettings/src/V1/ListSettingsResponse.php @@ -26,7 +26,7 @@ class ListSettingsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/ResourceSettings/src/V1/ResourceSettingsServiceClient.php b/ResourceSettings/src/V1/ResourceSettingsServiceClient.php deleted file mode 100644 index 39375964b6c6..000000000000 --- a/ResourceSettings/src/V1/ResourceSettingsServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. Metadata about a setting which is not editable by the end * user. * * Generated from protobuf field .google.cloud.resourcesettings.v1.SettingMetadata metadata = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $metadata = null; + protected $metadata = null; /** * The configured value of the setting at the given parent resource (ignoring * the resource hierarchy). The data type of @@ -41,7 +41,7 @@ class Setting extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.resourcesettings.v1.Value local_value = 8; */ - private $local_value = null; + protected $local_value = null; /** * Output only. The computed effective value of the setting at the given * parent resource (based on the resource hierarchy). @@ -60,7 +60,7 @@ class Setting extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.resourcesettings.v1.Value effective_value = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $effective_value = null; + protected $effective_value = null; /** * A fingerprint used for optimistic concurrency. See * [UpdateSetting][google.cloud.resourcesettings.v1.ResourceSettingsService.UpdateSetting] @@ -68,7 +68,7 @@ class Setting extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 10; */ - private $etag = ''; + protected $etag = ''; /** * Constructor. diff --git a/ResourceSettings/src/V1/SettingMetadata.php b/ResourceSettings/src/V1/SettingMetadata.php index cf7f941b300f..0c7450691b76 100644 --- a/ResourceSettings/src/V1/SettingMetadata.php +++ b/ResourceSettings/src/V1/SettingMetadata.php @@ -20,26 +20,26 @@ class SettingMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 1; */ - private $display_name = ''; + protected $display_name = ''; /** * A detailed description of what this setting does. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * A flag indicating that values of this setting cannot be modified (see * documentation of the specific setting for updates and reasons). * * Generated from protobuf field bool read_only = 3; */ - private $read_only = false; + protected $read_only = false; /** * The data type for this setting. * * Generated from protobuf field .google.cloud.resourcesettings.v1.SettingMetadata.DataType data_type = 4; */ - private $data_type = 0; + protected $data_type = 0; /** * The value provided by * [Setting.effective_value][google.cloud.resourcesettings.v1.Setting.effective_value] @@ -48,7 +48,7 @@ class SettingMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.resourcesettings.v1.Value default_value = 5; */ - private $default_value = null; + protected $default_value = null; /** * Constructor. diff --git a/ResourceSettings/src/V1/UpdateSettingRequest.php b/ResourceSettings/src/V1/UpdateSettingRequest.php index e3f37d99cb30..9f21c56b4550 100644 --- a/ResourceSettings/src/V1/UpdateSettingRequest.php +++ b/ResourceSettings/src/V1/UpdateSettingRequest.php @@ -21,7 +21,7 @@ class UpdateSettingRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.resourcesettings.v1.Setting setting = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $setting = null; + protected $setting = null; /** * Constructor. diff --git a/ResourceSettings/src/V1/Value/EnumValue.php b/ResourceSettings/src/V1/Value/EnumValue.php index c42c978311a7..f3ea09b30112 100644 --- a/ResourceSettings/src/V1/Value/EnumValue.php +++ b/ResourceSettings/src/V1/Value/EnumValue.php @@ -22,7 +22,7 @@ class EnumValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string value = 1; */ - private $value = ''; + protected $value = ''; /** * Constructor. diff --git a/ResourceSettings/tests/Unit/V1/Client/ResourceSettingsServiceClientTest.php b/ResourceSettings/tests/Unit/V1/Client/ResourceSettingsServiceClientTest.php index 4efe2d0aee02..9b4dcb1c841e 100644 --- a/ResourceSettings/tests/Unit/V1/Client/ResourceSettingsServiceClientTest.php +++ b/ResourceSettings/tests/Unit/V1/Client/ResourceSettingsServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ResourceSettingsServiceClient */ @@ -80,8 +82,7 @@ public function getSettingTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->settingName('[PROJECT_NUMBER]', '[SETTING_NAME]'); - $request = (new GetSettingRequest()) - ->setName($formattedName); + $request = (new GetSettingRequest())->setName($formattedName); $response = $gapicClient->getSetting($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -105,17 +106,19 @@ public function getSettingExceptionTest() $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); + $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->settingName('[PROJECT_NUMBER]', '[SETTING_NAME]'); - $request = (new GetSettingRequest()) - ->setName($formattedName); + $request = (new GetSettingRequest())->setName($formattedName); try { $gapicClient->getSetting($request); // If the $gapicClient method call did not throw, fail the test @@ -140,17 +143,14 @@ public function listSettingsTest() // Mock response $nextPageToken = ''; $settingsElement = new Setting(); - $settings = [ - $settingsElement, - ]; + $settings = [$settingsElement]; $expectedResponse = new ListSettingsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSettings($settings); $transport->addResponse($expectedResponse); // Mock request $parent = 'parent-995424086'; - $request = (new ListSettingsRequest()) - ->setParent($parent); + $request = (new ListSettingsRequest())->setParent($parent); $response = $gapicClient->listSettings($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -177,17 +177,19 @@ public function listSettingsExceptionTest() $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); + $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 ListSettingsRequest()) - ->setParent($parent); + $request = (new ListSettingsRequest())->setParent($parent); try { $gapicClient->listSettings($request); // If the $gapicClient method call did not throw, fail the test @@ -218,8 +220,7 @@ public function updateSettingTest() $transport->addResponse($expectedResponse); // Mock request $setting = new Setting(); - $request = (new UpdateSettingRequest()) - ->setSetting($setting); + $request = (new UpdateSettingRequest())->setSetting($setting); $response = $gapicClient->updateSetting($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -243,17 +244,19 @@ public function updateSettingExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $setting = new Setting(); - $request = (new UpdateSettingRequest()) - ->setSetting($setting); + $request = (new UpdateSettingRequest())->setSetting($setting); try { $gapicClient->updateSetting($request); // If the $gapicClient method call did not throw, fail the test @@ -284,8 +287,7 @@ public function getSettingAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->settingName('[PROJECT_NUMBER]', '[SETTING_NAME]'); - $request = (new GetSettingRequest()) - ->setName($formattedName); + $request = (new GetSettingRequest())->setName($formattedName); $response = $gapicClient->getSettingAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); diff --git a/ResourceSettings/tests/Unit/V1/ResourceSettingsServiceClientTest.php b/ResourceSettings/tests/Unit/V1/ResourceSettingsServiceClientTest.php deleted file mode 100644 index e54843a664f2..000000000000 --- a/ResourceSettings/tests/Unit/V1/ResourceSettingsServiceClientTest.php +++ /dev/null @@ -1,254 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ResourceSettingsServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ResourceSettingsServiceClient($options); - } - - /** @test */ - public function getSettingTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $etag = 'etag3123477'; - $expectedResponse = new Setting(); - $expectedResponse->setName($name2); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->settingName('[PROJECT_NUMBER]', '[SETTING_NAME]'); - $response = $gapicClient->getSetting($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.resourcesettings.v1.ResourceSettingsService/GetSetting', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getSettingExceptionTest() - { - $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->settingName('[PROJECT_NUMBER]', '[SETTING_NAME]'); - try { - $gapicClient->getSetting($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 listSettingsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $settingsElement = new Setting(); - $settings = [ - $settingsElement, - ]; - $expectedResponse = new ListSettingsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSettings($settings); - $transport->addResponse($expectedResponse); - // Mock request - $parent = 'parent-995424086'; - $response = $gapicClient->listSettings($parent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSettings()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.resourcesettings.v1.ResourceSettingsService/ListSettings', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($parent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listSettingsExceptionTest() - { - $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'; - try { - $gapicClient->listSettings($parent); - // 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 updateSettingTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $etag = 'etag3123477'; - $expectedResponse = new Setting(); - $expectedResponse->setName($name); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $setting = new Setting(); - $response = $gapicClient->updateSetting($setting); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.resourcesettings.v1.ResourceSettingsService/UpdateSetting', $actualFuncCall); - $actualValue = $actualRequestObject->getSetting(); - $this->assertProtobufEquals($setting, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateSettingExceptionTest() - { - $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 - $setting = new Setting(); - try { - $gapicClient->updateSetting($setting); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/Shell/owlbot.py b/Shell/owlbot.py index ba2c9ecf6647..cf796687d7f9 100644 --- a/Shell/owlbot.py +++ b/Shell/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,29 +41,16 @@ + "\n", '') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/Shell/src/V1/AddPublicKeyRequest.php b/Shell/src/V1/AddPublicKeyRequest.php index c0bdbc17e92d..c97bdddbd810 100644 --- a/Shell/src/V1/AddPublicKeyRequest.php +++ b/Shell/src/V1/AddPublicKeyRequest.php @@ -22,7 +22,7 @@ class AddPublicKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string environment = 1; */ - private $environment = ''; + protected $environment = ''; /** * Key that should be added to the environment. Supported formats are * `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256` @@ -33,7 +33,7 @@ class AddPublicKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string key = 2; */ - private $key = ''; + protected $key = ''; /** * Constructor. diff --git a/Shell/src/V1/AddPublicKeyResponse.php b/Shell/src/V1/AddPublicKeyResponse.php index da9f8cfe3c49..0e1037955d54 100644 --- a/Shell/src/V1/AddPublicKeyResponse.php +++ b/Shell/src/V1/AddPublicKeyResponse.php @@ -21,7 +21,7 @@ class AddPublicKeyResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string key = 1; */ - private $key = ''; + protected $key = ''; /** * Constructor. diff --git a/Shell/src/V1/AuthorizeEnvironmentRequest.php b/Shell/src/V1/AuthorizeEnvironmentRequest.php index a2ded66db3fa..8e7a43ed7708 100644 --- a/Shell/src/V1/AuthorizeEnvironmentRequest.php +++ b/Shell/src/V1/AuthorizeEnvironmentRequest.php @@ -23,26 +23,26 @@ class AuthorizeEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The OAuth access token that should be sent to the environment. * * Generated from protobuf field string access_token = 2; */ - private $access_token = ''; + protected $access_token = ''; /** * The OAuth ID token that should be sent to the environment. * * Generated from protobuf field string id_token = 4; */ - private $id_token = ''; + protected $id_token = ''; /** * The time when the credentials expire. If not set, defaults to one hour from * when the server received the request. * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 3; */ - private $expire_time = null; + protected $expire_time = null; /** * Constructor. diff --git a/Shell/src/V1/Client/CloudShellServiceClient.php b/Shell/src/V1/Client/CloudShellServiceClient.php index 7f9ae480091c..a085d15a3fb8 100644 --- a/Shell/src/V1/Client/CloudShellServiceClient.php +++ b/Shell/src/V1/Client/CloudShellServiceClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a environment * resource. @@ -313,8 +332,10 @@ public function addPublicKey(AddPublicKeyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function authorizeEnvironment(AuthorizeEnvironmentRequest $request, array $callOptions = []): OperationResponse - { + public function authorizeEnvironment( + AuthorizeEnvironmentRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('AuthorizeEnvironment', $request, $callOptions)->wait(); } diff --git a/Shell/src/V1/CloudShellErrorDetails.php b/Shell/src/V1/CloudShellErrorDetails.php index b9f563e37f9d..f2917510226e 100644 --- a/Shell/src/V1/CloudShellErrorDetails.php +++ b/Shell/src/V1/CloudShellErrorDetails.php @@ -21,7 +21,7 @@ class CloudShellErrorDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.shell.v1.CloudShellErrorDetails.CloudShellErrorCode code = 1; */ - private $code = 0; + protected $code = 0; /** * Constructor. diff --git a/Shell/src/V1/CloudShellServiceClient.php b/Shell/src/V1/CloudShellServiceClient.php deleted file mode 100644 index 0cd037c3a4ba..000000000000 --- a/Shell/src/V1/CloudShellServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. The environment's identifier, unique among the user's * environments. * * Generated from protobuf field string id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $id = ''; + protected $id = ''; /** * Required. Immutable. Full path to the Docker image used to run this environment, e.g. * "gcr.io/dev-con/cloud-devshell:latest". * * Generated from protobuf field string docker_image = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = IMMUTABLE]; */ - private $docker_image = ''; + protected $docker_image = ''; /** * Output only. Current execution state of this environment. * * Generated from protobuf field .google.cloud.shell.v1.Environment.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. Host to which clients can connect to initiate HTTPS or WSS * connections with the environment. * * Generated from protobuf field string web_host = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $web_host = ''; + protected $web_host = ''; /** * Output only. Username that clients should use when initiating SSH sessions * with the environment. * * Generated from protobuf field string ssh_username = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $ssh_username = ''; + protected $ssh_username = ''; /** * Output only. Host to which clients can connect to initiate SSH sessions * with the environment. * * Generated from protobuf field string ssh_host = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $ssh_host = ''; + protected $ssh_host = ''; /** * Output only. Port to which clients can connect to initiate SSH sessions * with the environment. * * Generated from protobuf field int32 ssh_port = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $ssh_port = 0; + protected $ssh_port = 0; /** * Output only. Public keys associated with the environment. Clients can * connect to this environment via SSH only if they possess a private key diff --git a/Shell/src/V1/Gapic/CloudShellServiceGapicClient.php b/Shell/src/V1/Gapic/CloudShellServiceGapicClient.php deleted file mode 100644 index 70e1b8333482..000000000000 --- a/Shell/src/V1/Gapic/CloudShellServiceGapicClient.php +++ /dev/null @@ -1,700 +0,0 @@ -addPublicKey(); - * $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 = $cloudShellServiceClient->addPublicKey(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudShellServiceClient->resumeOperation($operationName, 'addPublicKey'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudShellServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Shell\V1\Client\CloudShellServiceClient}. - */ -class CloudShellServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.shell.v1.CloudShellService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'cloudshell.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'cloudshell.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $environmentNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getEnvironmentNameTemplate() - { - if (self::$environmentNameTemplate == null) { - self::$environmentNameTemplate = new PathTemplate('users/{user}/environments/{environment}'); - } - - return self::$environmentNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'environment' => self::getEnvironmentNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($user, $environment) - { - return self::getEnvironmentNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * 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. - * - * Sample code: - * ``` - * $cloudShellServiceClient = new CloudShellServiceClient(); - * try { - * $operationResponse = $cloudShellServiceClient->addPublicKey(); - * $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 = $cloudShellServiceClient->addPublicKey(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudShellServiceClient->resumeOperation($operationName, 'addPublicKey'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudShellServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * Environment this key should be added to, e.g. - * `users/me/environments/default`. - * @type string $key - * Key that should be added to the environment. Supported formats are - * `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256` - * (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and - * `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as - * <format> <content>, where <content> part is encoded with - * Base64. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 addPublicKey(array $optionalArgs = []) - { - $request = new AddPublicKeyRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - $requestParamHeaders['environment'] = $optionalArgs['environment']; - } - - if (isset($optionalArgs['key'])) { - $request->setKey($optionalArgs['key']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('AddPublicKey', $optionalArgs, $request, $this->getOperationsClient())->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. - * - * Sample code: - * ``` - * $cloudShellServiceClient = new CloudShellServiceClient(); - * try { - * $operationResponse = $cloudShellServiceClient->authorizeEnvironment(); - * $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 = $cloudShellServiceClient->authorizeEnvironment(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudShellServiceClient->resumeOperation($operationName, 'authorizeEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudShellServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the resource that should receive the credentials, for example - * `users/me/environments/default` or - * `users/someone@example.com/environments/default`. - * @type string $accessToken - * The OAuth access token that should be sent to the environment. - * @type string $idToken - * The OAuth ID token that should be sent to the environment. - * @type Timestamp $expireTime - * The time when the credentials expire. If not set, defaults to one hour from - * when the server received the request. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 authorizeEnvironment(array $optionalArgs = []) - { - $request = new AuthorizeEnvironmentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['accessToken'])) { - $request->setAccessToken($optionalArgs['accessToken']); - } - - if (isset($optionalArgs['idToken'])) { - $request->setIdToken($optionalArgs['idToken']); - } - - if (isset($optionalArgs['expireTime'])) { - $request->setExpireTime($optionalArgs['expireTime']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('AuthorizeEnvironment', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Gets an environment. Returns NOT_FOUND if the environment does not exist. - * - * Sample code: - * ``` - * $cloudShellServiceClient = new CloudShellServiceClient(); - * try { - * $formattedName = $cloudShellServiceClient->environmentName('[USER]', '[ENVIRONMENT]'); - * $response = $cloudShellServiceClient->getEnvironment($formattedName); - * } finally { - * $cloudShellServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the requested resource, for example `users/me/environments/default` - * or `users/someone@example.com/environments/default`. - * @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\Shell\V1\Environment - * - * @throws ApiException if the remote call fails - */ - public function getEnvironment($name, array $optionalArgs = []) - { - $request = new GetEnvironmentRequest(); - $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('GetEnvironment', Environment::class, $optionalArgs, $request)->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. - * - * Sample code: - * ``` - * $cloudShellServiceClient = new CloudShellServiceClient(); - * try { - * $operationResponse = $cloudShellServiceClient->removePublicKey(); - * $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 = $cloudShellServiceClient->removePublicKey(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudShellServiceClient->resumeOperation($operationName, 'removePublicKey'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudShellServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * Environment this key should be removed from, e.g. - * `users/me/environments/default`. - * @type string $key - * Key that should be removed from the environment. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 removePublicKey(array $optionalArgs = []) - { - $request = new RemovePublicKeyRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - $requestParamHeaders['environment'] = $optionalArgs['environment']; - } - - if (isset($optionalArgs['key'])) { - $request->setKey($optionalArgs['key']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('RemovePublicKey', $optionalArgs, $request, $this->getOperationsClient())->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. - * - * Sample code: - * ``` - * $cloudShellServiceClient = new CloudShellServiceClient(); - * try { - * $operationResponse = $cloudShellServiceClient->startEnvironment(); - * $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 = $cloudShellServiceClient->startEnvironment(); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $cloudShellServiceClient->resumeOperation($operationName, 'startEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $cloudShellServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Name of the resource that should be started, for example - * `users/me/environments/default` or - * `users/someone@example.com/environments/default`. - * @type string $accessToken - * The initial access token passed to the environment. If this is present and - * valid, the environment will be pre-authenticated with gcloud so that the - * user can run gcloud commands in Cloud Shell without having to log in. This - * code can be updated later by calling AuthorizeEnvironment. - * @type string[] $publicKeys - * Public keys that should be added to the environment before it is started. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 startEnvironment(array $optionalArgs = []) - { - $request = new StartEnvironmentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['accessToken'])) { - $request->setAccessToken($optionalArgs['accessToken']); - } - - if (isset($optionalArgs['publicKeys'])) { - $request->setPublicKeys($optionalArgs['publicKeys']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('StartEnvironment', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } -} diff --git a/Shell/src/V1/GetEnvironmentRequest.php b/Shell/src/V1/GetEnvironmentRequest.php index 63e7c60a2a64..1a7ccc554936 100644 --- a/Shell/src/V1/GetEnvironmentRequest.php +++ b/Shell/src/V1/GetEnvironmentRequest.php @@ -22,7 +22,7 @@ class GetEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the requested resource, for example `users/me/environments/default` diff --git a/Shell/src/V1/RemovePublicKeyRequest.php b/Shell/src/V1/RemovePublicKeyRequest.php index 173b80e25368..f88f4956a717 100644 --- a/Shell/src/V1/RemovePublicKeyRequest.php +++ b/Shell/src/V1/RemovePublicKeyRequest.php @@ -22,13 +22,13 @@ class RemovePublicKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string environment = 1; */ - private $environment = ''; + protected $environment = ''; /** * Key that should be removed from the environment. * * Generated from protobuf field string key = 2; */ - private $key = ''; + protected $key = ''; /** * Constructor. diff --git a/Shell/src/V1/StartEnvironmentMetadata.php b/Shell/src/V1/StartEnvironmentMetadata.php index 475c450ec0dc..6f86b9864683 100644 --- a/Shell/src/V1/StartEnvironmentMetadata.php +++ b/Shell/src/V1/StartEnvironmentMetadata.php @@ -21,7 +21,7 @@ class StartEnvironmentMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.shell.v1.StartEnvironmentMetadata.State state = 1; */ - private $state = 0; + protected $state = 0; /** * Constructor. diff --git a/Shell/src/V1/StartEnvironmentRequest.php b/Shell/src/V1/StartEnvironmentRequest.php index aeea9b3bb8ec..606ccd73038f 100644 --- a/Shell/src/V1/StartEnvironmentRequest.php +++ b/Shell/src/V1/StartEnvironmentRequest.php @@ -23,7 +23,7 @@ class StartEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The initial access token passed to the environment. If this is present and * valid, the environment will be pre-authenticated with gcloud so that the @@ -32,7 +32,7 @@ class StartEnvironmentRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string access_token = 2; */ - private $access_token = ''; + protected $access_token = ''; /** * Public keys that should be added to the environment before it is started. * diff --git a/Shell/src/V1/StartEnvironmentResponse.php b/Shell/src/V1/StartEnvironmentResponse.php index 665aeeb05623..23804329ea29 100644 --- a/Shell/src/V1/StartEnvironmentResponse.php +++ b/Shell/src/V1/StartEnvironmentResponse.php @@ -22,7 +22,7 @@ class StartEnvironmentResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.shell.v1.Environment environment = 1; */ - private $environment = null; + protected $environment = null; /** * Constructor. diff --git a/Shell/tests/Unit/V1/Client/CloudShellServiceClientTest.php b/Shell/tests/Unit/V1/Client/CloudShellServiceClientTest.php index 6ddd7ec9ded4..5d88a99a0324 100644 --- a/Shell/tests/Unit/V1/Client/CloudShellServiceClientTest.php +++ b/Shell/tests/Unit/V1/Client/CloudShellServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return CloudShellServiceClient */ @@ -157,12 +159,15 @@ public function addPublicKeyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new AddPublicKeyRequest(); $response = $gapicClient->addPublicKey($request); @@ -270,12 +275,15 @@ public function authorizeEnvironmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new AuthorizeEnvironmentRequest(); $response = $gapicClient->authorizeEnvironment($request); @@ -327,8 +335,7 @@ public function getEnvironmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->environmentName('[USER]', '[ENVIRONMENT]'); - $request = (new GetEnvironmentRequest()) - ->setName($formattedName); + $request = (new GetEnvironmentRequest())->setName($formattedName); $response = $gapicClient->getEnvironment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -352,17 +359,19 @@ public function getEnvironmentExceptionTest() $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); + $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->environmentName('[USER]', '[ENVIRONMENT]'); - $request = (new GetEnvironmentRequest()) - ->setName($formattedName); + $request = (new GetEnvironmentRequest())->setName($formattedName); try { $gapicClient->getEnvironment($request); // If the $gapicClient method call did not throw, fail the test @@ -459,12 +468,15 @@ public function removePublicKeyExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new RemovePublicKeyRequest(); $response = $gapicClient->removePublicKey($request); @@ -572,12 +584,15 @@ public function startEnvironmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); $request = new StartEnvironmentRequest(); $response = $gapicClient->startEnvironment($request); diff --git a/Shell/tests/Unit/V1/CloudShellServiceClientTest.php b/Shell/tests/Unit/V1/CloudShellServiceClientTest.php deleted file mode 100644 index 2016cd4669c8..000000000000 --- a/Shell/tests/Unit/V1/CloudShellServiceClientTest.php +++ /dev/null @@ -1,587 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return CloudShellServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new CloudShellServiceClient($options); - } - - /** @test */ - public function addPublicKeyTest() - { - $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/addPublicKeyTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $key2 = 'key2101944914'; - $expectedResponse = new AddPublicKeyResponse(); - $expectedResponse->setKey($key2); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/addPublicKeyTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->addPublicKey(); - $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.shell.v1.CloudShellService/AddPublicKey', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/addPublicKeyTest'); - $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 addPublicKeyExceptionTest() - { - $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/addPublicKeyTest'); - $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); - $response = $gapicClient->addPublicKey(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/addPublicKeyTest'); - 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 authorizeEnvironmentTest() - { - $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/authorizeEnvironmentTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new AuthorizeEnvironmentResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/authorizeEnvironmentTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->authorizeEnvironment(); - $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.shell.v1.CloudShellService/AuthorizeEnvironment', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/authorizeEnvironmentTest'); - $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 authorizeEnvironmentExceptionTest() - { - $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/authorizeEnvironmentTest'); - $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); - $response = $gapicClient->authorizeEnvironment(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/authorizeEnvironmentTest'); - 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 getEnvironmentTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $dockerImage = 'dockerImage872637052'; - $webHost = 'webHost-718809165'; - $sshUsername = 'sshUsername-1964096211'; - $sshHost = 'sshHost611808639'; - $sshPort = 612046936; - $expectedResponse = new Environment(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setDockerImage($dockerImage); - $expectedResponse->setWebHost($webHost); - $expectedResponse->setSshUsername($sshUsername); - $expectedResponse->setSshHost($sshHost); - $expectedResponse->setSshPort($sshPort); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->environmentName('[USER]', '[ENVIRONMENT]'); - $response = $gapicClient->getEnvironment($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.shell.v1.CloudShellService/GetEnvironment', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getEnvironmentExceptionTest() - { - $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->environmentName('[USER]', '[ENVIRONMENT]'); - try { - $gapicClient->getEnvironment($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 removePublicKeyTest() - { - $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/removePublicKeyTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new RemovePublicKeyResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/removePublicKeyTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->removePublicKey(); - $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.shell.v1.CloudShellService/RemovePublicKey', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/removePublicKeyTest'); - $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 removePublicKeyExceptionTest() - { - $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/removePublicKeyTest'); - $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); - $response = $gapicClient->removePublicKey(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/removePublicKeyTest'); - 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 startEnvironmentTest() - { - $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/startEnvironmentTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new StartEnvironmentResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/startEnvironmentTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - $response = $gapicClient->startEnvironment(); - $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.shell.v1.CloudShellService/StartEnvironment', $actualApiFuncCall); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/startEnvironmentTest'); - $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 startEnvironmentExceptionTest() - { - $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/startEnvironmentTest'); - $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); - $response = $gapicClient->startEnvironment(); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/startEnvironmentTest'); - 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()); - } -} diff --git a/VpcAccess/owlbot.py b/VpcAccess/owlbot.py index 31517e5493cf..308b5eede9d9 100644 --- a/VpcAccess/owlbot.py +++ b/VpcAccess/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,14 +30,7 @@ # Added so that we can pass copy_excludes in the owlbot_main() call _tracked_paths.add(src) -php.owlbot_main( - src=src, - dest=dest, - copy_excludes=[ - src / "**/[A-Z]*_*.php", - src / "**/*GrpcClient.php", - ] -) +php.owlbot_main(src=src, dest=dest) # remove class_alias code s.replace( @@ -48,29 +41,16 @@ + "\n", '') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/VpcAccess/src/V1/Client/VpcAccessServiceClient.php b/VpcAccess/src/V1/Client/VpcAccessServiceClient.php index 30c67bd00654..0cb7eca0b92a 100644 --- a/VpcAccess/src/V1/Client/VpcAccessServiceClient.php +++ b/VpcAccess/src/V1/Client/VpcAccessServiceClient.php @@ -1,6 +1,6 @@ descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a connector * resource. diff --git a/VpcAccess/src/V1/Connector.php b/VpcAccess/src/V1/Connector.php index 7cebbc5f4419..25fa64274902 100644 --- a/VpcAccess/src/V1/Connector.php +++ b/VpcAccess/src/V1/Connector.php @@ -20,38 +20,38 @@ class Connector extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Name of a VPC network. * * Generated from protobuf field string network = 2; */ - private $network = ''; + protected $network = ''; /** * The range of internal addresses that follows RFC 4632 notation. * Example: `10.132.0.0/28`. * * Generated from protobuf field string ip_cidr_range = 3; */ - private $ip_cidr_range = ''; + protected $ip_cidr_range = ''; /** * Output only. State of the VPC access connector. * * Generated from protobuf field .google.cloud.vpcaccess.v1.Connector.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Minimum throughput of the connector in Mbps. Default and min is 200. * * Generated from protobuf field int32 min_throughput = 5; */ - private $min_throughput = 0; + protected $min_throughput = 0; /** * Maximum throughput of the connector in Mbps. Default is 300, max is 1000. * * Generated from protobuf field int32 max_throughput = 6; */ - private $max_throughput = 0; + protected $max_throughput = 0; /** * Output only. List of projects using the connector. * @@ -63,25 +63,25 @@ class Connector extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.vpcaccess.v1.Connector.Subnet subnet = 8; */ - private $subnet = null; + protected $subnet = null; /** * Machine type of VM Instance underlying connector. Default is e2-micro * * Generated from protobuf field string machine_type = 10; */ - private $machine_type = ''; + protected $machine_type = ''; /** * Minimum value of instances in autoscaling group underlying the connector. * * Generated from protobuf field int32 min_instances = 11; */ - private $min_instances = 0; + protected $min_instances = 0; /** * Maximum value of instances in autoscaling group underlying the connector. * * Generated from protobuf field int32 max_instances = 12; */ - private $max_instances = 0; + protected $max_instances = 0; /** * Constructor. diff --git a/VpcAccess/src/V1/Connector/Subnet.php b/VpcAccess/src/V1/Connector/Subnet.php index ee1a68272735..ad9766382884 100644 --- a/VpcAccess/src/V1/Connector/Subnet.php +++ b/VpcAccess/src/V1/Connector/Subnet.php @@ -23,7 +23,7 @@ class Subnet extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Project in which the subnet exists. * If not set, this project is assumed to be the project for which @@ -31,7 +31,7 @@ class Subnet extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string project_id = 2; */ - private $project_id = ''; + protected $project_id = ''; /** * Constructor. diff --git a/VpcAccess/src/V1/CreateConnectorRequest.php b/VpcAccess/src/V1/CreateConnectorRequest.php index b49a5bbec05f..8b40233b6b2d 100644 --- a/VpcAccess/src/V1/CreateConnectorRequest.php +++ b/VpcAccess/src/V1/CreateConnectorRequest.php @@ -21,19 +21,19 @@ class CreateConnectorRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID to use for this connector. * * Generated from protobuf field string connector_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $connector_id = ''; + protected $connector_id = ''; /** * Required. Resource to create. * * Generated from protobuf field .google.cloud.vpcaccess.v1.Connector connector = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $connector = null; + protected $connector = null; /** * @param string $parent Required. The project and location in which the configuration should be created, diff --git a/VpcAccess/src/V1/DeleteConnectorRequest.php b/VpcAccess/src/V1/DeleteConnectorRequest.php index fb81852e3e40..dff74532e1f0 100644 --- a/VpcAccess/src/V1/DeleteConnectorRequest.php +++ b/VpcAccess/src/V1/DeleteConnectorRequest.php @@ -20,7 +20,7 @@ class DeleteConnectorRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of a Serverless VPC Access connector to delete. Please see diff --git a/VpcAccess/src/V1/Gapic/VpcAccessServiceGapicClient.php b/VpcAccess/src/V1/Gapic/VpcAccessServiceGapicClient.php deleted file mode 100644 index 9ba2dc285304..000000000000 --- a/VpcAccess/src/V1/Gapic/VpcAccessServiceGapicClient.php +++ /dev/null @@ -1,671 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $connectorId = 'connector_id'; - * $connector = new Connector(); - * $operationResponse = $vpcAccessServiceClient->createConnector($formattedParent, $connectorId, $connector); - * $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 = $vpcAccessServiceClient->createConnector($formattedParent, $connectorId, $connector); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $vpcAccessServiceClient->resumeOperation($operationName, 'createConnector'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $vpcAccessServiceClient->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. - * - * @deprecated Please use the new service client {@see \Google\Cloud\VpcAccess\V1\Client\VpcAccessServiceClient}. - */ -class VpcAccessServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.vpcaccess.v1.VpcAccessService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'vpcaccess.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'vpcaccess.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private static $connectorNameTemplate; - - private static $locationNameTemplate; - - private static $pathTemplateMap; - - 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', - ], - ], - ]; - } - - private static function getConnectorNameTemplate() - { - if (self::$connectorNameTemplate == null) { - self::$connectorNameTemplate = new PathTemplate('projects/{project}/locations/{location}/connectors/{connector}'); - } - - return self::$connectorNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'connector' => self::getConnectorNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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($project, $location, $connector) - { - return self::getConnectorNameTemplate()->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($project, $location) - { - return self::getLocationNameTemplate()->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($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($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 '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); - } - - /** - * Creates a Serverless VPC Access connector, returns an operation. - * - * Sample code: - * ``` - * $vpcAccessServiceClient = new VpcAccessServiceClient(); - * try { - * $formattedParent = $vpcAccessServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $connectorId = 'connector_id'; - * $connector = new Connector(); - * $operationResponse = $vpcAccessServiceClient->createConnector($formattedParent, $connectorId, $connector); - * $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 = $vpcAccessServiceClient->createConnector($formattedParent, $connectorId, $connector); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $vpcAccessServiceClient->resumeOperation($operationName, 'createConnector'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $vpcAccessServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The project and location in which the configuration should be created, - * specified in the format `projects/*/locations/*`. - * @param string $connectorId Required. The ID to use for this connector. - * @param Connector $connector Required. Resource to create. - * @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 createConnector($parent, $connectorId, $connector, array $optionalArgs = []) - { - $request = new CreateConnectorRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setConnectorId($connectorId); - $request->setConnector($connector); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateConnector', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the - * resource does not exist. - * - * Sample code: - * ``` - * $vpcAccessServiceClient = new VpcAccessServiceClient(); - * try { - * $formattedName = $vpcAccessServiceClient->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - * $operationResponse = $vpcAccessServiceClient->deleteConnector($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 = $vpcAccessServiceClient->deleteConnector($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $vpcAccessServiceClient->resumeOperation($operationName, 'deleteConnector'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $vpcAccessServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of a Serverless VPC Access connector to delete. - * @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 deleteConnector($name, array $optionalArgs = []) - { - $request = new DeleteConnectorRequest(); - $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('DeleteConnector', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource - * does not exist. - * - * Sample code: - * ``` - * $vpcAccessServiceClient = new VpcAccessServiceClient(); - * try { - * $formattedName = $vpcAccessServiceClient->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - * $response = $vpcAccessServiceClient->getConnector($formattedName); - * } finally { - * $vpcAccessServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of a Serverless VPC Access connector to get. - * @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\VpcAccess\V1\Connector - * - * @throws ApiException if the remote call fails - */ - public function getConnector($name, array $optionalArgs = []) - { - $request = new GetConnectorRequest(); - $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('GetConnector', Connector::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists Serverless VPC Access connectors. - * - * Sample code: - * ``` - * $vpcAccessServiceClient = new VpcAccessServiceClient(); - * try { - * $formattedParent = $vpcAccessServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $vpcAccessServiceClient->listConnectors($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $vpcAccessServiceClient->listConnectors($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $vpcAccessServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The project and location from which the routes should be listed. - * @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 listConnectors($parent, array $optionalArgs = []) - { - $request = new ListConnectorsRequest(); - $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('ListConnectors', $optionalArgs, ListConnectorsResponse::class, $request); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $vpcAccessServiceClient = new VpcAccessServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $vpcAccessServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $vpcAccessServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $vpcAccessServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * 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 RetrySettings|array $retrySettings - * Retry settings to use for this call. 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 listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - 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('ListLocations', $optionalArgs, ListLocationsResponse::class, $request, 'google.cloud.location.Locations'); - } -} diff --git a/VpcAccess/src/V1/GetConnectorRequest.php b/VpcAccess/src/V1/GetConnectorRequest.php index 1c1587bbf048..e0e5f30df34b 100644 --- a/VpcAccess/src/V1/GetConnectorRequest.php +++ b/VpcAccess/src/V1/GetConnectorRequest.php @@ -20,7 +20,7 @@ class GetConnectorRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of a Serverless VPC Access connector to get. Please see diff --git a/VpcAccess/src/V1/ListConnectorsRequest.php b/VpcAccess/src/V1/ListConnectorsRequest.php index 7f9fc3f4c24f..c5aa13828211 100644 --- a/VpcAccess/src/V1/ListConnectorsRequest.php +++ b/VpcAccess/src/V1/ListConnectorsRequest.php @@ -20,19 +20,19 @@ class ListConnectorsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Maximum number of functions to return per call. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Continuation token. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The project and location from which the routes should be listed. Please see diff --git a/VpcAccess/src/V1/ListConnectorsResponse.php b/VpcAccess/src/V1/ListConnectorsResponse.php index 27c727fceeb2..58ddaece4918 100644 --- a/VpcAccess/src/V1/ListConnectorsResponse.php +++ b/VpcAccess/src/V1/ListConnectorsResponse.php @@ -26,7 +26,7 @@ class ListConnectorsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/VpcAccess/src/V1/OperationMetadata.php b/VpcAccess/src/V1/OperationMetadata.php index 17e9dd1c8852..45680ee1e154 100644 --- a/VpcAccess/src/V1/OperationMetadata.php +++ b/VpcAccess/src/V1/OperationMetadata.php @@ -21,26 +21,26 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string method = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $method = ''; + protected $method = ''; /** * Output only. Time when the operation was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. Time when the operation completed. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. Name of the resource that this operation is acting on e.g. * projects/my-project/locations/us-central1/connectors/v1. * * Generated from protobuf field string target = 5 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $target = ''; + protected $target = ''; /** * Constructor. diff --git a/VpcAccess/src/V1/VpcAccessServiceClient.php b/VpcAccess/src/V1/VpcAccessServiceClient.php deleted file mode 100644 index 2f2c4ba6670c..000000000000 --- a/VpcAccess/src/V1/VpcAccessServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return VpcAccessServiceClient */ @@ -184,12 +186,15 @@ public function createConnectorExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -252,8 +257,7 @@ public function deleteConnectorTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - $request = (new DeleteConnectorRequest()) - ->setName($formattedName); + $request = (new DeleteConnectorRequest())->setName($formattedName); $response = $gapicClient->deleteConnector($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -309,17 +313,19 @@ public function deleteConnectorExceptionTest() $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); + $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->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - $request = (new DeleteConnectorRequest()) - ->setName($formattedName); + $request = (new DeleteConnectorRequest())->setName($formattedName); $response = $gapicClient->deleteConnector($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -371,8 +377,7 @@ public function getConnectorTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - $request = (new GetConnectorRequest()) - ->setName($formattedName); + $request = (new GetConnectorRequest())->setName($formattedName); $response = $gapicClient->getConnector($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -396,17 +401,19 @@ public function getConnectorExceptionTest() $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); + $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->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - $request = (new GetConnectorRequest()) - ->setName($formattedName); + $request = (new GetConnectorRequest())->setName($formattedName); try { $gapicClient->getConnector($request); // If the $gapicClient method call did not throw, fail the test @@ -431,17 +438,14 @@ public function listConnectorsTest() // Mock response $nextPageToken = ''; $connectorsElement = new Connector(); - $connectors = [ - $connectorsElement, - ]; + $connectors = [$connectorsElement]; $expectedResponse = new ListConnectorsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setConnectors($connectors); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListConnectorsRequest()) - ->setParent($formattedParent); + $request = (new ListConnectorsRequest())->setParent($formattedParent); $response = $gapicClient->listConnectors($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -468,17 +472,19 @@ public function listConnectorsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListConnectorsRequest()) - ->setParent($formattedParent); + $request = (new ListConnectorsRequest())->setParent($formattedParent); try { $gapicClient->listConnectors($request); // If the $gapicClient method call did not throw, fail the test @@ -503,9 +509,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -535,12 +539,15 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { diff --git a/VpcAccess/tests/Unit/V1/VpcAccessServiceClientTest.php b/VpcAccess/tests/Unit/V1/VpcAccessServiceClientTest.php deleted file mode 100644 index 8ed687faa634..000000000000 --- a/VpcAccess/tests/Unit/V1/VpcAccessServiceClientTest.php +++ /dev/null @@ -1,531 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return VpcAccessServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new VpcAccessServiceClient($options); - } - - /** @test */ - public function createConnectorTest() - { - $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/createConnectorTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $network = 'network1843485230'; - $ipCidrRange = 'ipCidrRange-2049366326'; - $minThroughput = 2064735799; - $maxThroughput = 1407819749; - $machineType = 'machineType1838323762'; - $minInstances = 1491624145; - $maxInstances = 330682013; - $expectedResponse = new Connector(); - $expectedResponse->setName($name); - $expectedResponse->setNetwork($network); - $expectedResponse->setIpCidrRange($ipCidrRange); - $expectedResponse->setMinThroughput($minThroughput); - $expectedResponse->setMaxThroughput($maxThroughput); - $expectedResponse->setMachineType($machineType); - $expectedResponse->setMinInstances($minInstances); - $expectedResponse->setMaxInstances($maxInstances); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createConnectorTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $connectorId = 'connectorId1928724045'; - $connector = new Connector(); - $response = $gapicClient->createConnector($formattedParent, $connectorId, $connector); - $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.vpcaccess.v1.VpcAccessService/CreateConnector', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getConnectorId(); - $this->assertProtobufEquals($connectorId, $actualValue); - $actualValue = $actualApiRequestObject->getConnector(); - $this->assertProtobufEquals($connector, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createConnectorTest'); - $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 createConnectorExceptionTest() - { - $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/createConnectorTest'); - $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->locationName('[PROJECT]', '[LOCATION]'); - $connectorId = 'connectorId1928724045'; - $connector = new Connector(); - $response = $gapicClient->createConnector($formattedParent, $connectorId, $connector); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createConnectorTest'); - 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 deleteConnectorTest() - { - $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/deleteConnectorTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteConnectorTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - $response = $gapicClient->deleteConnector($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.vpcaccess.v1.VpcAccessService/DeleteConnector', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteConnectorTest'); - $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 deleteConnectorExceptionTest() - { - $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/deleteConnectorTest'); - $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->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - $response = $gapicClient->deleteConnector($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteConnectorTest'); - 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 getConnectorTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $network = 'network1843485230'; - $ipCidrRange = 'ipCidrRange-2049366326'; - $minThroughput = 2064735799; - $maxThroughput = 1407819749; - $machineType = 'machineType1838323762'; - $minInstances = 1491624145; - $maxInstances = 330682013; - $expectedResponse = new Connector(); - $expectedResponse->setName($name2); - $expectedResponse->setNetwork($network); - $expectedResponse->setIpCidrRange($ipCidrRange); - $expectedResponse->setMinThroughput($minThroughput); - $expectedResponse->setMaxThroughput($maxThroughput); - $expectedResponse->setMachineType($machineType); - $expectedResponse->setMinInstances($minInstances); - $expectedResponse->setMaxInstances($maxInstances); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - $response = $gapicClient->getConnector($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.vpcaccess.v1.VpcAccessService/GetConnector', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getConnectorExceptionTest() - { - $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->connectorName('[PROJECT]', '[LOCATION]', '[CONNECTOR]'); - try { - $gapicClient->getConnector($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 listConnectorsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $connectorsElement = new Connector(); - $connectors = [ - $connectorsElement, - ]; - $expectedResponse = new ListConnectorsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setConnectors($connectors); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listConnectors($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getConnectors()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.vpcaccess.v1.VpcAccessService/ListConnectors', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listConnectorsExceptionTest() - { - $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->locationName('[PROJECT]', '[LOCATION]'); - try { - $gapicClient->listConnectors($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 listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $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); - try { - $gapicClient->listLocations(); - // 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()); - } -}