From d2e202ef3a3d1ac2644d3c3c5e4a041fd4ff52af Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 20 Jun 2024 15:41:46 +0000 Subject: [PATCH 1/2] chore!: promote AdvisoryNotifications, ApiKeys, BareMetalSolution, BigQueryAnalyticsHub, BigQueryMigration to v1 --- .repo-metadata-full.json | 12 +- AdvisoryNotifications/.OwlBot.yaml | 4 +- AdvisoryNotifications/README.md | 3 +- AdvisoryNotifications/owlbot.py | 13 +- .../V1/AdvisoryNotificationsServiceClient.php | 34 - .../AdvisoryNotificationsServiceClient.php | 23 +- ...dvisoryNotificationsServiceGapicClient.php | 800 ---- ...AdvisoryNotificationsServiceClientTest.php | 332 -- ...AdvisoryNotificationsServiceClientTest.php | 122 +- ApiKeys/.OwlBot.yaml | 4 +- ApiKeys/owlbot.py | 41 +- ApiKeys/src/V2/AndroidApplication.php | 4 +- ApiKeys/src/V2/ApiKeysClient.php | 34 - ApiKeys/src/V2/ApiTarget.php | 10 +- ApiKeys/src/V2/Client/ApiKeysClient.php | 27 +- ApiKeys/src/V2/CreateKeyRequest.php | 6 +- ApiKeys/src/V2/DeleteKeyRequest.php | 4 +- ApiKeys/src/V2/Gapic/ApiKeysGapicClient.php | 956 ---- ApiKeys/src/V2/GetKeyRequest.php | 2 +- ApiKeys/src/V2/GetKeyStringRequest.php | 2 +- ApiKeys/src/V2/GetKeyStringResponse.php | 2 +- ApiKeys/src/V2/Key.php | 18 +- ApiKeys/src/V2/ListKeysRequest.php | 8 +- ApiKeys/src/V2/ListKeysResponse.php | 2 +- ApiKeys/src/V2/LookupKeyRequest.php | 2 +- ApiKeys/src/V2/LookupKeyResponse.php | 4 +- ApiKeys/src/V2/UndeleteKeyRequest.php | 2 +- ApiKeys/src/V2/UpdateKeyRequest.php | 4 +- ApiKeys/tests/Unit/V2/ApiKeysClientTest.php | 838 ---- .../Unit/V2/Client/ApiKeysClientTest.php | 186 +- BareMetalSolution/.OwlBot.yaml | 4 +- BareMetalSolution/README.md | 5 +- BareMetalSolution/owlbot.py | 46 +- .../src/V2/BareMetalSolutionClient.php | 34 - .../src/V2/BareMetalSolutionGrpcClient.php | 344 -- .../src/V2/Client/BareMetalSolutionClient.php | 107 +- .../src/V2/CreateNfsShareRequest.php | 4 +- .../V2/CreateProvisioningConfigRequest.php | 6 +- .../src/V2/CreateSSHKeyRequest.php | 6 +- .../src/V2/CreateVolumeSnapshotRequest.php | 4 +- .../src/V2/DeleteNfsShareRequest.php | 2 +- .../src/V2/DeleteSSHKeyRequest.php | 2 +- .../src/V2/DeleteVolumeSnapshotRequest.php | 2 +- BareMetalSolution/src/V2/DetachLunRequest.php | 6 +- ...DisableInteractiveSerialConsoleRequest.php | 2 +- .../EnableInteractiveSerialConsoleRequest.php | 2 +- BareMetalSolution/src/V2/EvictLunRequest.php | 2 +- .../src/V2/EvictVolumeRequest.php | 2 +- .../V2/Gapic/BareMetalSolutionGapicClient.php | 3976 ---------------- .../src/V2/GetInstanceRequest.php | 2 +- BareMetalSolution/src/V2/GetLunRequest.php | 2 +- .../src/V2/GetNetworkRequest.php | 2 +- .../src/V2/GetNfsShareRequest.php | 2 +- .../src/V2/GetProvisioningConfigRequest.php | 2 +- BareMetalSolution/src/V2/GetVolumeRequest.php | 2 +- .../src/V2/GetVolumeSnapshotRequest.php | 2 +- BareMetalSolution/src/V2/Instance.php | 28 +- BareMetalSolution/src/V2/Instance/State.php | 2 - BareMetalSolution/src/V2/InstanceConfig.php | 18 +- .../src/V2/InstanceConfig/NetworkAddress.php | 8 +- .../src/V2/InstanceConfig/NetworkConfig.php | 2 - BareMetalSolution/src/V2/InstanceQuota.php | 8 +- .../src/V2/ListInstancesRequest.php | 8 +- .../src/V2/ListInstancesResponse.php | 2 +- BareMetalSolution/src/V2/ListLunsRequest.php | 6 +- BareMetalSolution/src/V2/ListLunsResponse.php | 2 +- .../src/V2/ListNetworkUsageRequest.php | 2 +- .../src/V2/ListNetworksRequest.php | 8 +- .../src/V2/ListNetworksResponse.php | 2 +- .../src/V2/ListNfsSharesRequest.php | 8 +- .../src/V2/ListNfsSharesResponse.php | 2 +- .../src/V2/ListOSImagesRequest.php | 6 +- .../src/V2/ListOSImagesResponse.php | 2 +- .../src/V2/ListProvisioningQuotasRequest.php | 6 +- .../src/V2/ListProvisioningQuotasResponse.php | 2 +- .../src/V2/ListSSHKeysRequest.php | 6 +- .../src/V2/ListSSHKeysResponse.php | 2 +- .../src/V2/ListVolumeSnapshotsRequest.php | 6 +- .../src/V2/ListVolumeSnapshotsResponse.php | 2 +- .../src/V2/ListVolumesRequest.php | 8 +- .../src/V2/ListVolumesResponse.php | 2 +- BareMetalSolution/src/V2/LogicalInterface.php | 2 +- .../LogicalNetworkInterface.php | 12 +- BareMetalSolution/src/V2/Lun.php | 22 +- .../src/V2/Lun/MultiprotocolType.php | 2 - BareMetalSolution/src/V2/Lun/State.php | 2 - BareMetalSolution/src/V2/Lun/StorageType.php | 2 - BareMetalSolution/src/V2/Network.php | 24 +- BareMetalSolution/src/V2/Network/State.php | 2 - BareMetalSolution/src/V2/Network/Type.php | 2 - .../src/V2/NetworkAddressReservation.php | 6 +- BareMetalSolution/src/V2/NetworkConfig.php | 20 +- .../src/V2/NetworkConfig/Bandwidth.php | 2 - .../V2/NetworkConfig/IntakeVlanAttachment.php | 6 +- .../src/V2/NetworkConfig/ServiceCidr.php | 2 - .../src/V2/NetworkConfig/Type.php | 2 - .../src/V2/NetworkMountPoint.php | 8 +- BareMetalSolution/src/V2/NetworkUsage.php | 2 +- BareMetalSolution/src/V2/NfsShare.php | 14 +- .../src/V2/NfsShare/AllowedClient.php | 18 +- .../src/V2/NfsShare/MountPermissions.php | 2 - BareMetalSolution/src/V2/NfsShare/State.php | 2 - .../src/V2/NfsShare/StorageType.php | 2 - BareMetalSolution/src/V2/OSImage.php | 6 +- .../src/V2/OperationMetadata.php | 14 +- .../src/V2/ProvisioningConfig.php | 20 +- .../src/V2/ProvisioningConfig/State.php | 2 - .../src/V2/ProvisioningQuota.php | 10 +- .../src/V2/ProvisioningQuota/AssetType.php | 2 - .../src/V2/RenameInstanceRequest.php | 4 +- .../src/V2/RenameNetworkRequest.php | 4 +- .../src/V2/RenameNfsShareRequest.php | 4 +- .../src/V2/RenameVolumeRequest.php | 4 +- .../src/V2/ResetInstanceRequest.php | 2 +- .../src/V2/ResizeVolumeRequest.php | 4 +- .../src/V2/RestoreVolumeSnapshotRequest.php | 2 +- BareMetalSolution/src/V2/SSHKey.php | 4 +- .../src/V2/ServerNetworkTemplate.php | 2 +- .../LogicalInterface.php | 8 +- .../LogicalInterface/InterfaceType.php | 2 - .../V2/SnapshotSchedulePolicy/Schedule.php | 140 - .../src/V2/StartInstanceRequest.php | 2 +- .../src/V2/StopInstanceRequest.php | 2 +- .../V2/SubmitProvisioningConfigRequest.php | 6 +- .../V2/SubmitProvisioningConfigResponse.php | 2 +- .../src/V2/UpdateInstanceRequest.php | 4 +- .../src/V2/UpdateNetworkRequest.php | 4 +- .../src/V2/UpdateNfsShareRequest.php | 4 +- .../V2/UpdateProvisioningConfigRequest.php | 6 +- .../src/V2/UpdateVolumeRequest.php | 4 +- BareMetalSolution/src/V2/VRF.php | 6 +- BareMetalSolution/src/V2/VRF/QosPolicy.php | 4 +- BareMetalSolution/src/V2/VRF/State.php | 2 - .../src/V2/VRF/VlanAttachment.php | 16 +- BareMetalSolution/src/V2/Volume.php | 44 +- BareMetalSolution/src/V2/Volume/Protocol.php | 2 - .../V2/Volume/SnapshotAutoDeleteBehavior.php | 2 - .../V2/Volume/SnapshotReservationDetail.php | 10 +- BareMetalSolution/src/V2/Volume/State.php | 2 - .../src/V2/Volume/StorageType.php | 2 - .../src/V2/Volume/WorkloadProfile.php | 2 - BareMetalSolution/src/V2/VolumeConfig.php | 18 +- .../src/V2/VolumeConfig/LunRange.php | 6 +- .../src/V2/VolumeConfig/NfsExport.php | 12 +- .../V2/VolumeConfig/NfsExport/Permissions.php | 2 - .../src/V2/VolumeConfig/Protocol.php | 2 - .../src/V2/VolumeConfig/Type.php | 2 - BareMetalSolution/src/V2/VolumeSnapshot.php | 12 +- .../src/V2/VolumeSnapshot/SnapshotType.php | 2 - .../Unit/V2/BareMetalSolutionClientTest.php | 4228 ----------------- .../V2/Client/BareMetalSolutionClientTest.php | 1050 ++-- BigQueryAnalyticsHub/.OwlBot.yaml | 4 +- BigQueryAnalyticsHub/owlbot.py | 41 +- .../src/V1/AnalyticsHubServiceClient.php | 34 - .../V1/Client/AnalyticsHubServiceClient.php | 63 +- .../src/V1/CreateDataExchangeRequest.php | 6 +- .../src/V1/CreateListingRequest.php | 6 +- BigQueryAnalyticsHub/src/V1/DataExchange.php | 16 +- BigQueryAnalyticsHub/src/V1/DataProvider.php | 4 +- .../src/V1/DeleteDataExchangeRequest.php | 2 +- .../src/V1/DeleteListingRequest.php | 2 +- .../src/V1/DeleteSubscriptionRequest.php | 2 +- .../src/V1/DestinationDataset.php | 16 +- .../src/V1/DestinationDatasetReference.php | 4 +- .../Gapic/AnalyticsHubServiceGapicClient.php | 1946 -------- .../src/V1/GetDataExchangeRequest.php | 2 +- .../src/V1/GetListingRequest.php | 2 +- .../src/V1/GetSubscriptionRequest.php | 2 +- .../src/V1/ListDataExchangesRequest.php | 6 +- .../src/V1/ListDataExchangesResponse.php | 2 +- .../src/V1/ListListingsRequest.php | 6 +- .../src/V1/ListListingsResponse.php | 2 +- .../src/V1/ListOrgDataExchangesRequest.php | 6 +- .../src/V1/ListOrgDataExchangesResponse.php | 2 +- ...ListSharedResourceSubscriptionsRequest.php | 8 +- ...istSharedResourceSubscriptionsResponse.php | 2 +- .../src/V1/ListSubscriptionsRequest.php | 8 +- .../src/V1/ListSubscriptionsResponse.php | 2 +- BigQueryAnalyticsHub/src/V1/Listing.php | 22 +- .../src/V1/Listing/BigQueryDatasetSource.php | 2 +- .../src/V1/Listing/RestrictedExportConfig.php | 6 +- .../src/V1/OperationMetadata.php | 14 +- BigQueryAnalyticsHub/src/V1/Publisher.php | 4 +- .../src/V1/RefreshSubscriptionRequest.php | 2 +- .../src/V1/RefreshSubscriptionResponse.php | 2 +- .../src/V1/RevokeSubscriptionRequest.php | 2 +- .../DcrExchangeConfig.php | 4 +- .../src/V1/SubscribeDataExchangeRequest.php | 8 +- .../src/V1/SubscribeDataExchangeResponse.php | 2 +- .../src/V1/SubscribeListingRequest.php | 2 +- .../src/V1/SubscribeListingResponse.php | 2 +- BigQueryAnalyticsHub/src/V1/Subscription.php | 14 +- .../src/V1/UpdateDataExchangeRequest.php | 4 +- .../src/V1/UpdateListingRequest.php | 4 +- .../Unit/V1/AnalyticsHubServiceClientTest.php | 1748 ------- .../Client/AnalyticsHubServiceClientTest.php | 560 ++- BigQueryMigration/.OwlBot.yaml | 4 +- BigQueryMigration/owlbot.py | 41 +- .../src/V2/Client/MigrationServiceClient.php | 38 +- .../src/V2/CreateMigrationWorkflowRequest.php | 4 +- .../src/V2/DeleteMigrationWorkflowRequest.php | 2 +- BigQueryMigration/src/V2/ErrorDetail.php | 4 +- BigQueryMigration/src/V2/ErrorLocation.php | 4 +- .../V2/Gapic/MigrationServiceGapicClient.php | 787 --- .../src/V2/GetMigrationSubtaskRequest.php | 4 +- .../src/V2/GetMigrationWorkflowRequest.php | 4 +- .../src/V2/ListMigrationSubtasksRequest.php | 10 +- .../src/V2/ListMigrationSubtasksResponse.php | 2 +- .../src/V2/ListMigrationWorkflowsRequest.php | 8 +- .../src/V2/ListMigrationWorkflowsResponse.php | 2 +- .../src/V2/MigrationServiceClient.php | 34 - BigQueryMigration/src/V2/MigrationSubtask.php | 16 +- BigQueryMigration/src/V2/MigrationTask.php | 12 +- .../src/V2/MigrationWorkflow.php | 10 +- BigQueryMigration/src/V2/NameMappingKey.php | 10 +- BigQueryMigration/src/V2/NameMappingValue.php | 8 +- .../src/V2/ObjectNameMapping.php | 4 +- BigQueryMigration/src/V2/Point.php | 4 +- .../src/V2/ResourceErrorDetail.php | 4 +- BigQueryMigration/src/V2/SourceEnv.php | 2 +- .../src/V2/StartMigrationWorkflowRequest.php | 2 +- BigQueryMigration/src/V2/TeradataDialect.php | 2 +- BigQueryMigration/src/V2/TimeInterval.php | 4 +- BigQueryMigration/src/V2/TimeSeries.php | 6 +- .../src/V2/TranslationConfigDetails.php | 8 +- .../V2/Client/MigrationServiceClientTest.php | 185 +- .../Unit/V2/MigrationServiceClientTest.php | 509 -- 227 files changed, 1852 insertions(+), 18547 deletions(-) delete mode 100644 AdvisoryNotifications/src/V1/AdvisoryNotificationsServiceClient.php delete mode 100644 AdvisoryNotifications/src/V1/Gapic/AdvisoryNotificationsServiceGapicClient.php delete mode 100644 AdvisoryNotifications/tests/Unit/V1/AdvisoryNotificationsServiceClientTest.php delete mode 100644 ApiKeys/src/V2/ApiKeysClient.php delete mode 100644 ApiKeys/src/V2/Gapic/ApiKeysGapicClient.php delete mode 100644 ApiKeys/tests/Unit/V2/ApiKeysClientTest.php delete mode 100644 BareMetalSolution/src/V2/BareMetalSolutionClient.php delete mode 100644 BareMetalSolution/src/V2/BareMetalSolutionGrpcClient.php delete mode 100644 BareMetalSolution/src/V2/Gapic/BareMetalSolutionGapicClient.php delete mode 100644 BareMetalSolution/src/V2/SnapshotSchedulePolicy/Schedule.php delete mode 100644 BareMetalSolution/tests/Unit/V2/BareMetalSolutionClientTest.php delete mode 100644 BigQueryAnalyticsHub/src/V1/AnalyticsHubServiceClient.php delete mode 100644 BigQueryAnalyticsHub/src/V1/Gapic/AnalyticsHubServiceGapicClient.php delete mode 100644 BigQueryAnalyticsHub/tests/Unit/V1/AnalyticsHubServiceClientTest.php delete mode 100644 BigQueryMigration/src/V2/Gapic/MigrationServiceGapicClient.php delete mode 100644 BigQueryMigration/src/V2/MigrationServiceClient.php delete mode 100644 BigQueryMigration/tests/Unit/V2/MigrationServiceClientTest.php diff --git a/.repo-metadata-full.json b/.repo-metadata-full.json index cfd556523e9..556b02b3e40 100644 --- a/.repo-metadata-full.json +++ b/.repo-metadata-full.json @@ -18,7 +18,7 @@ "AdvisoryNotifications": { "language": "php", "distribution_name": "google/cloud-advisorynotifications", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-advisorynotifications/latest", "library_type": "GAPIC_AUTO", "api_shortname": "advisorynotifications" @@ -66,7 +66,7 @@ "ApiKeys": { "language": "php", "distribution_name": "google/cloud-api-keys", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-api-keys/latest", "library_type": "GAPIC_AUTO", "product_documentation": "https://cloud.google.com/api-keys/docs", @@ -172,7 +172,7 @@ "BareMetalSolution": { "language": "php", "distribution_name": "google/cloud-bare-metal-solution", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-bare-metal-solution/latest", "library_type": "GAPIC_AUTO", "api_shortname": "baremetalsolution" @@ -240,7 +240,7 @@ "BigQueryAnalyticsHub": { "language": "php", "distribution_name": "google/cloud-bigquery-analyticshub", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-bigquery-analyticshub/latest", "library_type": "GAPIC_AUTO", "product_documentation": "https://cloud.google.com/analytics-hub", @@ -258,7 +258,7 @@ "BigQueryDataExchange": { "language": "php", "distribution_name": "google/cloud-bigquery-data-exchange", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-bigquery-data-exchange/latest", "library_type": "GAPIC_AUTO", "api_shortname": "analyticshub" @@ -284,7 +284,7 @@ "BigQueryMigration": { "language": "php", "distribution_name": "google/cloud-bigquery-migration", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-bigquery-migration/latest", "library_type": "GAPIC_AUTO", "product_documentation": "https://cloud.google.com/bigquery/docs/migration-intro/docs", diff --git a/AdvisoryNotifications/.OwlBot.yaml b/AdvisoryNotifications/.OwlBot.yaml index 7a9cb54b239..d1a5801cc0e 100644 --- a/AdvisoryNotifications/.OwlBot.yaml +++ b/AdvisoryNotifications/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/advisorynotifications/v1/.*-php/(.*) - dest: /owl-bot-staging/AdvisoryNotifications/v1/$1 + - source: /google/cloud/advisorynotifications/(v1)/.*-php/(.*) + dest: /owl-bot-staging/AdvisoryNotifications/$1/$2 api-name: AdvisoryNotifications diff --git a/AdvisoryNotifications/README.md b/AdvisoryNotifications/README.md index 26087744db8..52b5d108756 100644 --- a/AdvisoryNotifications/README.md +++ b/AdvisoryNotifications/README.md @@ -38,7 +38,8 @@ See the [samples directory](https://github.com/googleapis/google-cloud-php-advis ### Version -This component is considered alpha. As such, it is still a work-in-progress and is more likely to get backwards-incompatible updates. +This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in +any minor or patch releases. We will address issues and requests with the highest priority. ### Next Steps diff --git a/AdvisoryNotifications/owlbot.py b/AdvisoryNotifications/owlbot.py index bc8fbe1a502..9c2ae1b3b61 100644 --- a/AdvisoryNotifications/owlbot.py +++ b/AdvisoryNotifications/owlbot.py @@ -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( @@ -56,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/AdvisoryNotifications/src/V1/AdvisoryNotificationsServiceClient.php b/AdvisoryNotifications/src/V1/AdvisoryNotificationsServiceClient.php deleted file mode 100644 index 8fee207f568..00000000000 --- a/AdvisoryNotifications/src/V1/AdvisoryNotificationsServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ - [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/advisory_notifications_service_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/advisory_notifications_service_rest_client_config.php', ], ], ]; @@ -168,8 +167,11 @@ public static function organizationLocationName(string $organization, string $lo * * @return string The formatted organization_location_notification resource. */ - public static function organizationLocationNotificationName(string $organization, string $location, string $notification): string - { + public static function organizationLocationNotificationName( + string $organization, + string $location, + string $notification + ): string { return self::getPathTemplate('organizationLocationNotification')->render([ 'organization' => $organization, 'location' => $location, @@ -221,8 +223,11 @@ public static function projectLocationName(string $project, string $location): s * * @return string The formatted project_location_notification resource. */ - public static function projectLocationNotificationName(string $project, string $location, string $notification): string - { + public static function projectLocationNotificationName( + string $project, + string $location, + string $notification + ): string { return self::getPathTemplate('projectLocationNotification')->render([ 'project' => $project, 'location' => $location, diff --git a/AdvisoryNotifications/src/V1/Gapic/AdvisoryNotificationsServiceGapicClient.php b/AdvisoryNotifications/src/V1/Gapic/AdvisoryNotificationsServiceGapicClient.php deleted file mode 100644 index b7246dfce68..00000000000 --- a/AdvisoryNotifications/src/V1/Gapic/AdvisoryNotificationsServiceGapicClient.php +++ /dev/null @@ -1,800 +0,0 @@ -notificationName('[ORGANIZATION]', '[LOCATION]', '[NOTIFICATION]'); - * $response = $advisoryNotificationsServiceClient->getNotification($formattedName); - * } finally { - * $advisoryNotificationsServiceClient->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\AdvisoryNotifications\V1\Client\AdvisoryNotificationsServiceClient}. - */ -class AdvisoryNotificationsServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.advisorynotifications.v1.AdvisoryNotificationsService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'advisorynotifications.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'advisorynotifications.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 $notificationNameTemplate; - - private static $organizationLocationNameTemplate; - - private static $organizationLocationNotificationNameTemplate; - - private static $organizationLocationSettingsNameTemplate; - - private static $projectLocationNameTemplate; - - private static $projectLocationNotificationNameTemplate; - - private static $projectLocationSettingsNameTemplate; - - private static $settingsNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../resources/advisory_notifications_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/advisory_notifications_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../resources/advisory_notifications_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/advisory_notifications_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'organizations/{organization}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getNotificationNameTemplate() - { - if (self::$notificationNameTemplate == null) { - self::$notificationNameTemplate = new PathTemplate( - 'organizations/{organization}/locations/{location}/notifications/{notification}' - ); - } - - return self::$notificationNameTemplate; - } - - private static function getOrganizationLocationNameTemplate() - { - if (self::$organizationLocationNameTemplate == null) { - self::$organizationLocationNameTemplate = new PathTemplate( - 'organizations/{organization}/locations/{location}' - ); - } - - return self::$organizationLocationNameTemplate; - } - - private static function getOrganizationLocationNotificationNameTemplate() - { - if (self::$organizationLocationNotificationNameTemplate == null) { - self::$organizationLocationNotificationNameTemplate = new PathTemplate( - 'organizations/{organization}/locations/{location}/notifications/{notification}' - ); - } - - return self::$organizationLocationNotificationNameTemplate; - } - - private static function getOrganizationLocationSettingsNameTemplate() - { - if (self::$organizationLocationSettingsNameTemplate == null) { - self::$organizationLocationSettingsNameTemplate = new PathTemplate( - 'organizations/{organization}/locations/{location}/settings' - ); - } - - return self::$organizationLocationSettingsNameTemplate; - } - - private static function getProjectLocationNameTemplate() - { - if (self::$projectLocationNameTemplate == null) { - self::$projectLocationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$projectLocationNameTemplate; - } - - private static function getProjectLocationNotificationNameTemplate() - { - if (self::$projectLocationNotificationNameTemplate == null) { - self::$projectLocationNotificationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/notifications/{notification}' - ); - } - - return self::$projectLocationNotificationNameTemplate; - } - - private static function getProjectLocationSettingsNameTemplate() - { - if (self::$projectLocationSettingsNameTemplate == null) { - self::$projectLocationSettingsNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/settings' - ); - } - - return self::$projectLocationSettingsNameTemplate; - } - - private static function getSettingsNameTemplate() - { - if (self::$settingsNameTemplate == null) { - self::$settingsNameTemplate = new PathTemplate( - 'organizations/{organization}/locations/{location}/settings' - ); - } - - return self::$settingsNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'location' => self::getLocationNameTemplate(), - 'notification' => self::getNotificationNameTemplate(), - 'organizationLocation' => self::getOrganizationLocationNameTemplate(), - 'organizationLocationNotification' => self::getOrganizationLocationNotificationNameTemplate(), - 'organizationLocationSettings' => self::getOrganizationLocationSettingsNameTemplate(), - 'projectLocation' => self::getProjectLocationNameTemplate(), - 'projectLocationNotification' => self::getProjectLocationNotificationNameTemplate(), - 'projectLocationSettings' => self::getProjectLocationSettingsNameTemplate(), - 'settings' => self::getSettingsNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $organization - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName($organization, $location) - { - return self::getLocationNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a notification - * resource. - * - * @param string $organization - * @param string $location - * @param string $notification - * - * @return string The formatted notification resource. - */ - public static function notificationName( - $organization, - $location, - $notification - ) { - return self::getNotificationNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - 'notification' => $notification, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location resource. - * - * @param string $organization - * @param string $location - * - * @return string The formatted organization_location resource. - */ - public static function organizationLocationName($organization, $location) - { - return self::getOrganizationLocationNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_notification resource. - * - * @param string $organization - * @param string $location - * @param string $notification - * - * @return string The formatted organization_location_notification resource. - */ - public static function organizationLocationNotificationName( - $organization, - $location, - $notification - ) { - return self::getOrganizationLocationNotificationNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - 'notification' => $notification, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_settings resource. - * - * @param string $organization - * @param string $location - * - * @return string The formatted organization_location_settings resource. - */ - public static function organizationLocationSettingsName( - $organization, - $location - ) { - return self::getOrganizationLocationSettingsNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location resource. - */ - public static function projectLocationName($project, $location) - { - return self::getProjectLocationNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_notification resource. - * - * @param string $project - * @param string $location - * @param string $notification - * - * @return string The formatted project_location_notification resource. - */ - public static function projectLocationNotificationName( - $project, - $location, - $notification - ) { - return self::getProjectLocationNotificationNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'notification' => $notification, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_settings resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_settings resource. - */ - public static function projectLocationSettingsName($project, $location) - { - return self::getProjectLocationSettingsNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a settings - * resource. - * - * @param string $organization - * @param string $location - * - * @return string The formatted settings resource. - */ - public static function settingsName($organization, $location) - { - return self::getSettingsNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: organizations/{organization}/locations/{location} - * - notification: organizations/{organization}/locations/{location}/notifications/{notification} - * - organizationLocation: organizations/{organization}/locations/{location} - * - organizationLocationNotification: organizations/{organization}/locations/{location}/notifications/{notification} - * - organizationLocationSettings: organizations/{organization}/locations/{location}/settings - * - projectLocation: projects/{project}/locations/{location} - * - projectLocationNotification: projects/{project}/locations/{location}/notifications/{notification} - * - projectLocationSettings: projects/{project}/locations/{location}/settings - * - settings: organizations/{organization}/locations/{location}/settings - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($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 'advisorynotifications.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Gets a notification. - * - * Sample code: - * ``` - * $advisoryNotificationsServiceClient = new AdvisoryNotificationsServiceClient(); - * try { - * $formattedName = $advisoryNotificationsServiceClient->notificationName('[ORGANIZATION]', '[LOCATION]', '[NOTIFICATION]'); - * $response = $advisoryNotificationsServiceClient->getNotification($formattedName); - * } finally { - * $advisoryNotificationsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. A name of the notification to retrieve. - * Format: - * organizations/{organization}/locations/{location}/notifications/{notification} - * or projects/{projects}/locations/{location}/notifications/{notification}. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * ISO code for requested localization language. If unset, will be - * interpereted as "en". If the requested language is valid, but not supported - * for this notification, English will be returned with an "Not applicable" - * LocalizationState. If the ISO code is invalid (i.e. not a real language), - * this RPC will throw an error. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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\AdvisoryNotifications\V1\Notification - * - * @throws ApiException if the remote call fails - */ - public function getNotification($name, array $optionalArgs = []) - { - $request = new GetNotificationRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['languageCode'])) { - $request->setLanguageCode($optionalArgs['languageCode']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetNotification', - Notification::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get notification settings. - * - * Sample code: - * ``` - * $advisoryNotificationsServiceClient = new AdvisoryNotificationsServiceClient(); - * try { - * $formattedName = $advisoryNotificationsServiceClient->settingsName('[ORGANIZATION]', '[LOCATION]'); - * $response = $advisoryNotificationsServiceClient->getSettings($formattedName); - * } finally { - * $advisoryNotificationsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the settings to retrieve. - * Format: - * organizations/{organization}/locations/{location}/settings or - * projects/{projects}/locations/{location}/settings. - * @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\AdvisoryNotifications\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(); - } - - /** - * Lists notifications under a given parent. - * - * Sample code: - * ``` - * $advisoryNotificationsServiceClient = new AdvisoryNotificationsServiceClient(); - * try { - * $formattedParent = $advisoryNotificationsServiceClient->locationName('[ORGANIZATION]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $advisoryNotificationsServiceClient->listNotifications($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $advisoryNotificationsServiceClient->listNotifications($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $advisoryNotificationsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent, which owns this collection of notifications. - * Must be of the form "organizations/{organization}/locations/{location}" - * or "projects/{project}/locations/{location}". - * @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 - * Specifies which parts of the notification resource should be returned - * in the response. - * For allowed values, use constants defined on {@see \Google\Cloud\AdvisoryNotifications\V1\NotificationView} - * @type string $languageCode - * ISO code for requested localization language. If unset, will be - * interpereted as "en". If the requested language is valid, but not supported - * for this notification, English will be returned with an "Not applicable" - * LocalizationState. If the ISO code is invalid (i.e. not a real language), - * this RPC will throw an error. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 listNotifications($parent, array $optionalArgs = []) - { - $request = new ListNotificationsRequest(); - $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']); - } - - if (isset($optionalArgs['languageCode'])) { - $request->setLanguageCode($optionalArgs['languageCode']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListNotifications', - $optionalArgs, - ListNotificationsResponse::class, - $request - ); - } - - /** - * Update notification settings. - * - * Sample code: - * ``` - * $advisoryNotificationsServiceClient = new AdvisoryNotificationsServiceClient(); - * try { - * $settings = new Settings(); - * $response = $advisoryNotificationsServiceClient->updateSettings($settings); - * } finally { - * $advisoryNotificationsServiceClient->close(); - * } - * ``` - * - * @param Settings $settings Required. New settings. - * @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\AdvisoryNotifications\V1\Settings - * - * @throws ApiException if the remote call fails - */ - public function updateSettings($settings, array $optionalArgs = []) - { - $request = new UpdateSettingsRequest(); - $requestParamHeaders = []; - $request->setSettings($settings); - $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(); - } -} diff --git a/AdvisoryNotifications/tests/Unit/V1/AdvisoryNotificationsServiceClientTest.php b/AdvisoryNotifications/tests/Unit/V1/AdvisoryNotificationsServiceClientTest.php deleted file mode 100644 index 6989a92dbcb..00000000000 --- a/AdvisoryNotifications/tests/Unit/V1/AdvisoryNotificationsServiceClientTest.php +++ /dev/null @@ -1,332 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return AdvisoryNotificationsServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new AdvisoryNotificationsServiceClient($options); - } - - /** @test */ - public function getNotificationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $expectedResponse = new Notification(); - $expectedResponse->setName($name2); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->notificationName('[ORGANIZATION]', '[LOCATION]', '[NOTIFICATION]'); - $response = $gapicClient->getNotification($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.advisorynotifications.v1.AdvisoryNotificationsService/GetNotification', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getNotificationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->notificationName('[ORGANIZATION]', '[LOCATION]', '[NOTIFICATION]'); - try { - $gapicClient->getNotification($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'; - $etag = 'etag3123477'; - $expectedResponse = new Settings(); - $expectedResponse->setName($name2); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->settingsName('[ORGANIZATION]', '[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.advisorynotifications.v1.AdvisoryNotificationsService/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('[ORGANIZATION]', '[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 listNotificationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $totalSize = 705419236; - $notificationsElement = new Notification(); - $notifications = [ - $notificationsElement, - ]; - $expectedResponse = new ListNotificationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setTotalSize($totalSize); - $expectedResponse->setNotifications($notifications); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[ORGANIZATION]', '[LOCATION]'); - $response = $gapicClient->listNotifications($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getNotifications()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/ListNotifications', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listNotificationsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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('[ORGANIZATION]', '[LOCATION]'); - try { - $gapicClient->listNotifications($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 updateSettingsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $etag = 'etag3123477'; - $expectedResponse = new Settings(); - $expectedResponse->setName($name); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $settings = new Settings(); - $notificationSettingsValue = new NotificationSettings(); - $settingsNotificationSettings = [ - 'notificationSettingsKey' => $notificationSettingsValue, - ]; - $settings->setNotificationSettings($settingsNotificationSettings); - $settingsEtag = 'settingsEtag533925848'; - $settings->setEtag($settingsEtag); - $response = $gapicClient->updateSettings($settings); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/UpdateSettings', $actualFuncCall); - $actualValue = $actualRequestObject->getSettings(); - $this->assertProtobufEquals($settings, $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(); - $notificationSettingsValue = new NotificationSettings(); - $settingsNotificationSettings = [ - 'notificationSettingsKey' => $notificationSettingsValue, - ]; - $settings->setNotificationSettings($settingsNotificationSettings); - $settingsEtag = 'settingsEtag533925848'; - $settings->setEtag($settingsEtag); - try { - $gapicClient->updateSettings($settings); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->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/AdvisoryNotifications/tests/Unit/V1/Client/AdvisoryNotificationsServiceClientTest.php b/AdvisoryNotifications/tests/Unit/V1/Client/AdvisoryNotificationsServiceClientTest.php index c2174baa744..9f809ec1465 100644 --- a/AdvisoryNotifications/tests/Unit/V1/Client/AdvisoryNotificationsServiceClientTest.php +++ b/AdvisoryNotifications/tests/Unit/V1/Client/AdvisoryNotificationsServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return AdvisoryNotificationsServiceClient */ @@ -81,15 +83,17 @@ public function getNotificationTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->notificationName('[ORGANIZATION]', '[LOCATION]', '[NOTIFICATION]'); - $request = (new GetNotificationRequest()) - ->setName($formattedName); + $request = (new GetNotificationRequest())->setName($formattedName); $response = $gapicClient->getNotification($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.advisorynotifications.v1.AdvisoryNotificationsService/GetNotification', $actualFuncCall); + $this->assertSame( + '/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/GetNotification', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -106,17 +110,19 @@ public function getNotificationExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->notificationName('[ORGANIZATION]', '[LOCATION]', '[NOTIFICATION]'); - $request = (new GetNotificationRequest()) - ->setName($formattedName); + $request = (new GetNotificationRequest())->setName($formattedName); try { $gapicClient->getNotification($request); // If the $gapicClient method call did not throw, fail the test @@ -147,15 +153,17 @@ public function getSettingsTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->settingsName('[ORGANIZATION]', '[LOCATION]'); - $request = (new GetSettingsRequest()) - ->setName($formattedName); + $request = (new GetSettingsRequest())->setName($formattedName); $response = $gapicClient->getSettings($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.advisorynotifications.v1.AdvisoryNotificationsService/GetSettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/GetSettings', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -172,17 +180,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('[ORGANIZATION]', '[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 @@ -208,9 +218,7 @@ public function listNotificationsTest() $nextPageToken = ''; $totalSize = 705419236; $notificationsElement = new Notification(); - $notifications = [ - $notificationsElement, - ]; + $notifications = [$notificationsElement]; $expectedResponse = new ListNotificationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setTotalSize($totalSize); @@ -218,8 +226,7 @@ public function listNotificationsTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[ORGANIZATION]', '[LOCATION]'); - $request = (new ListNotificationsRequest()) - ->setParent($formattedParent); + $request = (new ListNotificationsRequest())->setParent($formattedParent); $response = $gapicClient->listNotifications($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -229,7 +236,10 @@ public function listNotificationsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/ListNotifications', $actualFuncCall); + $this->assertSame( + '/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/ListNotifications', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -246,17 +256,19 @@ public function listNotificationsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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('[ORGANIZATION]', '[LOCATION]'); - $request = (new ListNotificationsRequest()) - ->setParent($formattedParent); + $request = (new ListNotificationsRequest())->setParent($formattedParent); try { $gapicClient->listNotifications($request); // If the $gapicClient method call did not throw, fail the test @@ -294,15 +306,17 @@ public function updateSettingsTest() $settings->setNotificationSettings($settingsNotificationSettings); $settingsEtag = 'settingsEtag533925848'; $settings->setEtag($settingsEtag); - $request = (new UpdateSettingsRequest()) - ->setSettings($settings); + $request = (new UpdateSettingsRequest())->setSettings($settings); $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.advisorynotifications.v1.AdvisoryNotificationsService/UpdateSettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/UpdateSettings', + $actualFuncCall + ); $actualValue = $actualRequestObject->getSettings(); $this->assertProtobufEquals($settings, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -319,12 +333,15 @@ 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(); @@ -335,8 +352,7 @@ public function updateSettingsExceptionTest() $settings->setNotificationSettings($settingsNotificationSettings); $settingsEtag = 'settingsEtag533925848'; $settings->setEtag($settingsEtag); - $request = (new UpdateSettingsRequest()) - ->setSettings($settings); + $request = (new UpdateSettingsRequest())->setSettings($settings); try { $gapicClient->updateSettings($request); // If the $gapicClient method call did not throw, fail the test @@ -365,15 +381,17 @@ public function getNotificationAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->notificationName('[ORGANIZATION]', '[LOCATION]', '[NOTIFICATION]'); - $request = (new GetNotificationRequest()) - ->setName($formattedName); + $request = (new GetNotificationRequest())->setName($formattedName); $response = $gapicClient->getNotificationAsync($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.advisorynotifications.v1.AdvisoryNotificationsService/GetNotification', $actualFuncCall); + $this->assertSame( + '/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/GetNotification', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); diff --git a/ApiKeys/.OwlBot.yaml b/ApiKeys/.OwlBot.yaml index 3ffd63eb338..615163c8781 100644 --- a/ApiKeys/.OwlBot.yaml +++ b/ApiKeys/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/api/apikeys/v2/.*-php/(.*) - dest: /owl-bot-staging/ApiKeys/v2/$1 + - source: /google/api/apikeys/(v2)/.*-php/(.*) + dest: /owl-bot-staging/ApiKeys/$1/$2 api-name: ApiKeys diff --git a/ApiKeys/owlbot.py b/ApiKeys/owlbot.py index e09c1aef440..662d0cb057a 100644 --- a/ApiKeys/owlbot.py +++ b/ApiKeys/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2022 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/ApiKeys/src/V2/AndroidApplication.php b/ApiKeys/src/V2/AndroidApplication.php index 49035d0a1e7..74f3d2346b2 100644 --- a/ApiKeys/src/V2/AndroidApplication.php +++ b/ApiKeys/src/V2/AndroidApplication.php @@ -23,13 +23,13 @@ class AndroidApplication extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string sha1_fingerprint = 1; */ - private $sha1_fingerprint = ''; + protected $sha1_fingerprint = ''; /** * The package name of the application. * * Generated from protobuf field string package_name = 2; */ - private $package_name = ''; + protected $package_name = ''; /** * Constructor. diff --git a/ApiKeys/src/V2/ApiKeysClient.php b/ApiKeys/src/V2/ApiKeysClient.php deleted file mode 100644 index 17d33af6043..00000000000 --- a/ApiKeys/src/V2/ApiKeysClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string service = 1; */ - private $service = ''; + protected $service = ''; /** * Optional. List of one or more methods that can be called. * If empty, all methods for the service are allowed. A wildcard @@ -48,7 +48,7 @@ class ApiTarget extends \Google\Protobuf\Internal\Message * @type string $service * The service for this restriction. It should be the canonical * service name, for example: `translate.googleapis.com`. - * You can use [`gcloud services list`](https://cloud.google.com/sdk/gcloud/reference/services/list) + * You can use [`gcloud services list`](/sdk/gcloud/reference/services/list) * to get a list of services that are enabled in the project. * @type array|\Google\Protobuf\Internal\RepeatedField $methods * Optional. List of one or more methods that can be called. @@ -69,7 +69,7 @@ public function __construct($data = NULL) { /** * The service for this restriction. It should be the canonical * service name, for example: `translate.googleapis.com`. - * You can use [`gcloud services list`](https://cloud.google.com/sdk/gcloud/reference/services/list) + * You can use [`gcloud services list`](/sdk/gcloud/reference/services/list) * to get a list of services that are enabled in the project. * * Generated from protobuf field string service = 1; @@ -83,7 +83,7 @@ public function getService() /** * The service for this restriction. It should be the canonical * service name, for example: `translate.googleapis.com`. - * You can use [`gcloud services list`](https://cloud.google.com/sdk/gcloud/reference/services/list) + * You can use [`gcloud services list`](/sdk/gcloud/reference/services/list) * to get a list of services that are enabled in the project. * * Generated from protobuf field string service = 1; diff --git a/ApiKeys/src/V2/Client/ApiKeysClient.php b/ApiKeys/src/V2/Client/ApiKeysClient.php index 19b0988aa42..a0551e4e5ab 100644 --- a/ApiKeys/src/V2/Client/ApiKeysClient.php +++ b/ApiKeys/src/V2/Client/ApiKeysClient.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 key * resource. diff --git a/ApiKeys/src/V2/CreateKeyRequest.php b/ApiKeys/src/V2/CreateKeyRequest.php index e0c6b3efeba..9919979b799 100644 --- a/ApiKeys/src/V2/CreateKeyRequest.php +++ b/ApiKeys/src/V2/CreateKeyRequest.php @@ -20,7 +20,7 @@ class CreateKeyRequest 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 API key fields to set at creation time. * You can configure only the `display_name`, `restrictions`, and @@ -28,7 +28,7 @@ class CreateKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.api.apikeys.v2.Key key = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $key = null; + protected $key = null; /** * User specified key id (optional). If specified, it will become the final * component of the key resource name. @@ -40,7 +40,7 @@ class CreateKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string key_id = 3; */ - private $key_id = ''; + protected $key_id = ''; /** * @param string $parent Required. The project in which the API key is created. Please see diff --git a/ApiKeys/src/V2/DeleteKeyRequest.php b/ApiKeys/src/V2/DeleteKeyRequest.php index ab2d74394d0..203c84e8a5c 100644 --- a/ApiKeys/src/V2/DeleteKeyRequest.php +++ b/ApiKeys/src/V2/DeleteKeyRequest.php @@ -20,14 +20,14 @@ class DeleteKeyRequest 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. The etag known to the client for the expected state of the key. * This is to be used for optimistic concurrency. * * Generated from protobuf field string etag = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $etag = ''; + protected $etag = ''; /** * @param string $name Required. The resource name of the API key to be deleted. Please see diff --git a/ApiKeys/src/V2/Gapic/ApiKeysGapicClient.php b/ApiKeys/src/V2/Gapic/ApiKeysGapicClient.php deleted file mode 100644 index d2d667e6c61..00000000000 --- a/ApiKeys/src/V2/Gapic/ApiKeysGapicClient.php +++ /dev/null @@ -1,956 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $key = new Key(); - * $operationResponse = $apiKeysClient->createKey($formattedParent, $key); - * $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 = $apiKeysClient->createKey($formattedParent, $key); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $apiKeysClient->resumeOperation($operationName, 'createKey'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $apiKeysClient->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\ApiKeys\V2\Client\ApiKeysClient}. - */ -class ApiKeysGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.api.apikeys.v2.ApiKeys'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'apikeys.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'apikeys.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', - ]; - - private static $keyNameTemplate; - - 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/api_keys_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . '/../resources/api_keys_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../resources/api_keys_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/api_keys_rest_client_config.php', - ], - ], - ]; - } - - private static function getKeyNameTemplate() - { - if (self::$keyNameTemplate == null) { - self::$keyNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/keys/{key}' - ); - } - - return self::$keyNameTemplate; - } - - 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 = [ - 'key' => self::getKeyNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a key - * resource. - * - * @param string $project - * @param string $location - * @param string $key - * - * @return string The formatted key resource. - */ - public static function keyName($project, $location, $key) - { - return self::getKeyNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'key' => $key, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName($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 - * - key: projects/{project}/locations/{location}/keys/{key} - * - location: projects/{project}/locations/{location} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($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 'apikeys.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Creates a new API key. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * Sample code: - * ``` - * $apiKeysClient = new ApiKeysClient(); - * try { - * $formattedParent = $apiKeysClient->locationName('[PROJECT]', '[LOCATION]'); - * $key = new Key(); - * $operationResponse = $apiKeysClient->createKey($formattedParent, $key); - * $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 = $apiKeysClient->createKey($formattedParent, $key); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $apiKeysClient->resumeOperation($operationName, 'createKey'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $apiKeysClient->close(); - * } - * ``` - * - * @param string $parent Required. The project in which the API key is created. - * @param Key $key Required. The API key fields to set at creation time. - * You can configure only the `display_name`, `restrictions`, and - * `annotations` fields. - * @param array $optionalArgs { - * Optional. - * - * @type string $keyId - * User specified key id (optional). If specified, it will become the final - * component of the key resource name. - * - * The id must be unique within the project, must conform with RFC-1034, - * is restricted to lower-cased letters, and has a maximum length of 63 - * characters. In another word, the id must match the regular - * expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. - * - * The id must NOT be a UUID-like string. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 createKey($parent, $key, array $optionalArgs = []) - { - $request = new CreateKeyRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setKey($key); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['keyId'])) { - $request->setKeyId($optionalArgs['keyId']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateKey', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes an API key. Deleted key can be retrieved within 30 days of - * deletion. Afterward, key will be purged from the project. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * Sample code: - * ``` - * $apiKeysClient = new ApiKeysClient(); - * try { - * $formattedName = $apiKeysClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - * $operationResponse = $apiKeysClient->deleteKey($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 = $apiKeysClient->deleteKey($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $apiKeysClient->resumeOperation($operationName, 'deleteKey'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $apiKeysClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the API key to be deleted. - * @param array $optionalArgs { - * Optional. - * - * @type string $etag - * Optional. The etag known to the client for the expected state of the key. - * This is to be used for optimistic concurrency. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 deleteKey($name, array $optionalArgs = []) - { - $request = new DeleteKeyRequest(); - $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->startOperationsCall( - 'DeleteKey', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets the metadata for an API key. The key string of the API key - * isn't included in the response. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * Sample code: - * ``` - * $apiKeysClient = new ApiKeysClient(); - * try { - * $formattedName = $apiKeysClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - * $response = $apiKeysClient->getKey($formattedName); - * } finally { - * $apiKeysClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the API key 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\ApiKeys\V2\Key - * - * @throws ApiException if the remote call fails - */ - public function getKey($name, array $optionalArgs = []) - { - $request = new GetKeyRequest(); - $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( - 'GetKey', - Key::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get the key string for an API key. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * Sample code: - * ``` - * $apiKeysClient = new ApiKeysClient(); - * try { - * $formattedName = $apiKeysClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - * $response = $apiKeysClient->getKeyString($formattedName); - * } finally { - * $apiKeysClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the API key to be retrieved. - * @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\ApiKeys\V2\GetKeyStringResponse - * - * @throws ApiException if the remote call fails - */ - public function getKeyString($name, array $optionalArgs = []) - { - $request = new GetKeyStringRequest(); - $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( - 'GetKeyString', - GetKeyStringResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists the API keys owned by a project. The key string of the API key - * isn't included in the response. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * Sample code: - * ``` - * $apiKeysClient = new ApiKeysClient(); - * try { - * $formattedParent = $apiKeysClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $apiKeysClient->listKeys($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $apiKeysClient->listKeys($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $apiKeysClient->close(); - * } - * ``` - * - * @param string $parent Required. Lists all API keys associated with this project. - * @param array $optionalArgs { - * Optional. - * - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type bool $showDeleted - * Optional. Indicate that keys deleted in the past 30 days should also be - * 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 listKeys($parent, array $optionalArgs = []) - { - $request = new ListKeysRequest(); - $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['showDeleted'])) { - $request->setShowDeleted($optionalArgs['showDeleted']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListKeys', - $optionalArgs, - ListKeysResponse::class, - $request - ); - } - - /** - * Find the parent project and resource name of the API - * key that matches the key string in the request. If the API key has been - * purged, resource name will not be set. - * The service account must have the `apikeys.keys.lookup` permission - * on the parent project. - * - * Sample code: - * ``` - * $apiKeysClient = new ApiKeysClient(); - * try { - * $keyString = 'key_string'; - * $response = $apiKeysClient->lookupKey($keyString); - * } finally { - * $apiKeysClient->close(); - * } - * ``` - * - * @param string $keyString Required. Finds the project that owns the key string 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\ApiKeys\V2\LookupKeyResponse - * - * @throws ApiException if the remote call fails - */ - public function lookupKey($keyString, array $optionalArgs = []) - { - $request = new LookupKeyRequest(); - $request->setKeyString($keyString); - return $this->startCall( - 'LookupKey', - LookupKeyResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Undeletes an API key which was deleted within 30 days. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * Sample code: - * ``` - * $apiKeysClient = new ApiKeysClient(); - * try { - * $formattedName = $apiKeysClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - * $operationResponse = $apiKeysClient->undeleteKey($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 = $apiKeysClient->undeleteKey($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $apiKeysClient->resumeOperation($operationName, 'undeleteKey'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $apiKeysClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the API key to be undeleted. - * @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 undeleteKey($name, array $optionalArgs = []) - { - $request = new UndeleteKeyRequest(); - $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( - 'UndeleteKey', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Patches the modifiable fields of an API key. - * The key string of the API key isn't included in the response. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * Sample code: - * ``` - * $apiKeysClient = new ApiKeysClient(); - * try { - * $key = new Key(); - * $operationResponse = $apiKeysClient->updateKey($key); - * $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 = $apiKeysClient->updateKey($key); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $apiKeysClient->resumeOperation($operationName, 'updateKey'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $apiKeysClient->close(); - * } - * ``` - * - * @param Key $key Required. Set the `name` field to the resource name of the API key to be - * updated. You can update only the `display_name`, `restrictions`, and - * `annotations` fields. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The field mask specifies which fields to be updated as part of this - * request. All other fields are ignored. - * Mutable fields are: `display_name`, `restrictions`, and `annotations`. - * If an update mask is not provided, the service treats it as an implied mask - * equivalent to all allowed fields that are set on the wire. If the field - * mask has a special value "*", the service treats it equivalent to replace - * all allowed mutable fields. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 updateKey($key, array $optionalArgs = []) - { - $request = new UpdateKeyRequest(); - $requestParamHeaders = []; - $request->setKey($key); - $requestParamHeaders['key.name'] = $key->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->startOperationsCall( - 'UpdateKey', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } -} diff --git a/ApiKeys/src/V2/GetKeyRequest.php b/ApiKeys/src/V2/GetKeyRequest.php index e9d137c7dea..e062f1a91d1 100644 --- a/ApiKeys/src/V2/GetKeyRequest.php +++ b/ApiKeys/src/V2/GetKeyRequest.php @@ -20,7 +20,7 @@ class GetKeyRequest 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 API key to get. Please see diff --git a/ApiKeys/src/V2/GetKeyStringRequest.php b/ApiKeys/src/V2/GetKeyStringRequest.php index 9366e02c076..fbaa776ed03 100644 --- a/ApiKeys/src/V2/GetKeyStringRequest.php +++ b/ApiKeys/src/V2/GetKeyStringRequest.php @@ -20,7 +20,7 @@ class GetKeyStringRequest 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 API key to be retrieved. Please see diff --git a/ApiKeys/src/V2/GetKeyStringResponse.php b/ApiKeys/src/V2/GetKeyStringResponse.php index a01394939db..e54c1d58be2 100644 --- a/ApiKeys/src/V2/GetKeyStringResponse.php +++ b/ApiKeys/src/V2/GetKeyStringResponse.php @@ -20,7 +20,7 @@ class GetKeyStringResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string key_string = 1; */ - private $key_string = ''; + protected $key_string = ''; /** * Constructor. diff --git a/ApiKeys/src/V2/Key.php b/ApiKeys/src/V2/Key.php index 8183887403c..3b1d10e0fe4 100644 --- a/ApiKeys/src/V2/Key.php +++ b/ApiKeys/src/V2/Key.php @@ -26,48 +26,48 @@ class Key extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Output only. Unique id in UUID4 format. * * Generated from protobuf field string uid = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Human-readable display name of this key that you can modify. * The maximum length is 63 characters. * * Generated from protobuf field string display_name = 2; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. An encrypted and signed value held by this key. * This field can be accessed only through the `GetKeyString` method. * * Generated from protobuf field string key_string = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $key_string = ''; + protected $key_string = ''; /** * Output only. A timestamp identifying the time this key was originally * 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. A timestamp identifying the time this key was last * updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Output only. A timestamp when this key was deleted. If the resource is not * deleted, this must be empty. * * Generated from protobuf field .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $delete_time = null; + protected $delete_time = null; /** * Annotations is an unstructured key-value map stored with a policy that * may be set by external tools to store and retrieve arbitrary metadata. @@ -81,7 +81,7 @@ class Key extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.api.apikeys.v2.Restrictions restrictions = 9; */ - private $restrictions = null; + protected $restrictions = null; /** * Output only. A checksum computed by the server based on the current value * of the Key resource. This may be sent on update and delete requests to @@ -90,7 +90,7 @@ class Key extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $etag = ''; + protected $etag = ''; /** * Constructor. diff --git a/ApiKeys/src/V2/ListKeysRequest.php b/ApiKeys/src/V2/ListKeysRequest.php index 7f78cb01a8d..04454c325db 100644 --- a/ApiKeys/src/V2/ListKeysRequest.php +++ b/ApiKeys/src/V2/ListKeysRequest.php @@ -20,26 +20,26 @@ class ListKeysRequest 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. Specifies the maximum number of results to be returned at a time. * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. Requests a specific page of results. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. Indicate that keys deleted in the past 30 days should also be * returned. * * Generated from protobuf field bool show_deleted = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $show_deleted = false; + protected $show_deleted = false; /** * @param string $parent Required. Lists all API keys associated with this project. Please see diff --git a/ApiKeys/src/V2/ListKeysResponse.php b/ApiKeys/src/V2/ListKeysResponse.php index 17c89adb0a9..e4bbd0c0d46 100644 --- a/ApiKeys/src/V2/ListKeysResponse.php +++ b/ApiKeys/src/V2/ListKeysResponse.php @@ -26,7 +26,7 @@ class ListKeysResponse 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/ApiKeys/src/V2/LookupKeyRequest.php b/ApiKeys/src/V2/LookupKeyRequest.php index e1e7272d126..4a9246dee32 100644 --- a/ApiKeys/src/V2/LookupKeyRequest.php +++ b/ApiKeys/src/V2/LookupKeyRequest.php @@ -20,7 +20,7 @@ class LookupKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string key_string = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $key_string = ''; + protected $key_string = ''; /** * Constructor. diff --git a/ApiKeys/src/V2/LookupKeyResponse.php b/ApiKeys/src/V2/LookupKeyResponse.php index 2c2f9693340..be7d242b0d0 100644 --- a/ApiKeys/src/V2/LookupKeyResponse.php +++ b/ApiKeys/src/V2/LookupKeyResponse.php @@ -20,14 +20,14 @@ class LookupKeyResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1; */ - private $parent = ''; + protected $parent = ''; /** * The resource name of the API key. If the API key has been purged, * resource name is empty. * * Generated from protobuf field string name = 2; */ - private $name = ''; + protected $name = ''; /** * Constructor. diff --git a/ApiKeys/src/V2/UndeleteKeyRequest.php b/ApiKeys/src/V2/UndeleteKeyRequest.php index 3f046f7001e..4c3776147f8 100644 --- a/ApiKeys/src/V2/UndeleteKeyRequest.php +++ b/ApiKeys/src/V2/UndeleteKeyRequest.php @@ -20,7 +20,7 @@ class UndeleteKeyRequest 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 = ''; /** * Constructor. diff --git a/ApiKeys/src/V2/UpdateKeyRequest.php b/ApiKeys/src/V2/UpdateKeyRequest.php index c3bf1a08d73..4ea641ec88f 100644 --- a/ApiKeys/src/V2/UpdateKeyRequest.php +++ b/ApiKeys/src/V2/UpdateKeyRequest.php @@ -22,7 +22,7 @@ class UpdateKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.api.apikeys.v2.Key key = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $key = null; + protected $key = null; /** * The field mask specifies which fields to be updated as part of this * request. All other fields are ignored. @@ -34,7 +34,7 @@ class UpdateKeyRequest 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\ApiKeys\V2\Key $key Required. Set the `name` field to the resource name of the API key to be diff --git a/ApiKeys/tests/Unit/V2/ApiKeysClientTest.php b/ApiKeys/tests/Unit/V2/ApiKeysClientTest.php deleted file mode 100644 index 21885d9695e..00000000000 --- a/ApiKeys/tests/Unit/V2/ApiKeysClientTest.php +++ /dev/null @@ -1,838 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ApiKeysClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ApiKeysClient($options); - } - - /** @test */ - public function createKeyTest() - { - $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/createKeyTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $uid = 'uid115792'; - $displayName = 'displayName1615086568'; - $keyString = 'keyString526755313'; - $etag = 'etag3123477'; - $expectedResponse = new Key(); - $expectedResponse->setName($name); - $expectedResponse->setUid($uid); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setKeyString($keyString); - $expectedResponse->setEtag($etag); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createKeyTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $key = new Key(); - $response = $gapicClient->createKey($formattedParent, $key); - $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.api.apikeys.v2.ApiKeys/CreateKey', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getKey(); - $this->assertProtobufEquals($key, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createKeyTest'); - $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 createKeyExceptionTest() - { - $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/createKeyTest'); - $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]'); - $key = new Key(); - $response = $gapicClient->createKey($formattedParent, $key); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createKeyTest'); - 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 deleteKeyTest() - { - $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/deleteKeyTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $displayName = 'displayName1615086568'; - $keyString = 'keyString526755313'; - $etag2 = 'etag2-1293302904'; - $expectedResponse = new Key(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setKeyString($keyString); - $expectedResponse->setEtag($etag2); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteKeyTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $response = $gapicClient->deleteKey($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.api.apikeys.v2.ApiKeys/DeleteKey', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteKeyTest'); - $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 deleteKeyExceptionTest() - { - $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/deleteKeyTest'); - $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->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $response = $gapicClient->deleteKey($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteKeyTest'); - 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 getKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $displayName = 'displayName1615086568'; - $keyString = 'keyString526755313'; - $etag = 'etag3123477'; - $expectedResponse = new Key(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setKeyString($keyString); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $response = $gapicClient->getKey($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.api.apikeys.v2.ApiKeys/GetKey', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getKeyExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - try { - $gapicClient->getKey($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 getKeyStringTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $keyString = 'keyString526755313'; - $expectedResponse = new GetKeyStringResponse(); - $expectedResponse->setKeyString($keyString); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $response = $gapicClient->getKeyString($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.api.apikeys.v2.ApiKeys/GetKeyString', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getKeyStringExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - try { - $gapicClient->getKeyString($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 listKeysTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $keysElement = new Key(); - $keys = [ - $keysElement, - ]; - $expectedResponse = new ListKeysResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setKeys($keys); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listKeys($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getKeys()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.api.apikeys.v2.ApiKeys/ListKeys', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listKeysExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listKeys($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 lookupKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $parent = 'parent-995424086'; - $name = 'name3373707'; - $expectedResponse = new LookupKeyResponse(); - $expectedResponse->setParent($parent); - $expectedResponse->setName($name); - $transport->addResponse($expectedResponse); - // Mock request - $keyString = 'keyString526755313'; - $response = $gapicClient->lookupKey($keyString); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.api.apikeys.v2.ApiKeys/LookupKey', $actualFuncCall); - $actualValue = $actualRequestObject->getKeyString(); - $this->assertProtobufEquals($keyString, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function lookupKeyExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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 - $keyString = 'keyString526755313'; - try { - $gapicClient->lookupKey($keyString); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function undeleteKeyTest() - { - $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/undeleteKeyTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $uid = 'uid115792'; - $displayName = 'displayName1615086568'; - $keyString = 'keyString526755313'; - $etag = 'etag3123477'; - $expectedResponse = new Key(); - $expectedResponse->setName($name2); - $expectedResponse->setUid($uid); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setKeyString($keyString); - $expectedResponse->setEtag($etag); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/undeleteKeyTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $response = $gapicClient->undeleteKey($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.api.apikeys.v2.ApiKeys/UndeleteKey', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/undeleteKeyTest'); - $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 undeleteKeyExceptionTest() - { - $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/undeleteKeyTest'); - $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->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $response = $gapicClient->undeleteKey($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/undeleteKeyTest'); - 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 updateKeyTest() - { - $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/updateKeyTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $uid = 'uid115792'; - $displayName = 'displayName1615086568'; - $keyString = 'keyString526755313'; - $etag = 'etag3123477'; - $expectedResponse = new Key(); - $expectedResponse->setName($name); - $expectedResponse->setUid($uid); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setKeyString($keyString); - $expectedResponse->setEtag($etag); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateKeyTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $key = new Key(); - $response = $gapicClient->updateKey($key); - $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.api.apikeys.v2.ApiKeys/UpdateKey', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getKey(); - $this->assertProtobufEquals($key, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateKeyTest'); - $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 updateKeyExceptionTest() - { - $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/updateKeyTest'); - $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 - $key = new Key(); - $response = $gapicClient->updateKey($key); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateKeyTest'); - 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/ApiKeys/tests/Unit/V2/Client/ApiKeysClientTest.php b/ApiKeys/tests/Unit/V2/Client/ApiKeysClientTest.php index aa7dd6cdcc8..b9d22ffd97c 100644 --- a/ApiKeys/tests/Unit/V2/Client/ApiKeysClientTest.php +++ b/ApiKeys/tests/Unit/V2/Client/ApiKeysClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ApiKeysClient */ @@ -116,9 +118,7 @@ public function createKeyTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $key = new Key(); - $request = (new CreateKeyRequest()) - ->setParent($formattedParent) - ->setKey($key); + $request = (new CreateKeyRequest())->setParent($formattedParent)->setKey($key); $response = $gapicClient->createKey($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -176,19 +176,20 @@ public function createKeyExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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]'); $key = new Key(); - $request = (new CreateKeyRequest()) - ->setParent($formattedParent) - ->setKey($key); + $request = (new CreateKeyRequest())->setParent($formattedParent)->setKey($key); $response = $gapicClient->createKey($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -252,8 +253,7 @@ public function deleteKeyTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $request = (new DeleteKeyRequest()) - ->setName($formattedName); + $request = (new DeleteKeyRequest())->setName($formattedName); $response = $gapicClient->deleteKey($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -309,17 +309,19 @@ public function deleteKeyExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $request = (new DeleteKeyRequest()) - ->setName($formattedName); + $request = (new DeleteKeyRequest())->setName($formattedName); $response = $gapicClient->deleteKey($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -365,8 +367,7 @@ public function getKeyTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $request = (new GetKeyRequest()) - ->setName($formattedName); + $request = (new GetKeyRequest())->setName($formattedName); $response = $gapicClient->getKey($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -390,17 +391,19 @@ public function getKeyExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $request = (new GetKeyRequest()) - ->setName($formattedName); + $request = (new GetKeyRequest())->setName($formattedName); try { $gapicClient->getKey($request); // If the $gapicClient method call did not throw, fail the test @@ -429,8 +432,7 @@ public function getKeyStringTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $request = (new GetKeyStringRequest()) - ->setName($formattedName); + $request = (new GetKeyStringRequest())->setName($formattedName); $response = $gapicClient->getKeyString($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -454,17 +456,19 @@ public function getKeyStringExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $request = (new GetKeyStringRequest()) - ->setName($formattedName); + $request = (new GetKeyStringRequest())->setName($formattedName); try { $gapicClient->getKeyString($request); // If the $gapicClient method call did not throw, fail the test @@ -489,17 +493,14 @@ public function listKeysTest() // Mock response $nextPageToken = ''; $keysElement = new Key(); - $keys = [ - $keysElement, - ]; + $keys = [$keysElement]; $expectedResponse = new ListKeysResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setKeys($keys); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListKeysRequest()) - ->setParent($formattedParent); + $request = (new ListKeysRequest())->setParent($formattedParent); $response = $gapicClient->listKeys($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -526,17 +527,19 @@ public function listKeysExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListKeysRequest()) - ->setParent($formattedParent); + $request = (new ListKeysRequest())->setParent($formattedParent); try { $gapicClient->listKeys($request); // If the $gapicClient method call did not throw, fail the test @@ -567,8 +570,7 @@ public function lookupKeyTest() $transport->addResponse($expectedResponse); // Mock request $keyString = 'keyString526755313'; - $request = (new LookupKeyRequest()) - ->setKeyString($keyString); + $request = (new LookupKeyRequest())->setKeyString($keyString); $response = $gapicClient->lookupKey($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -592,17 +594,19 @@ public function lookupKeyExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $keyString = 'keyString526755313'; - $request = (new LookupKeyRequest()) - ->setKeyString($keyString); + $request = (new LookupKeyRequest())->setKeyString($keyString); try { $gapicClient->lookupKey($request); // If the $gapicClient method call did not throw, fail the test @@ -657,8 +661,7 @@ public function undeleteKeyTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $request = (new UndeleteKeyRequest()) - ->setName($formattedName); + $request = (new UndeleteKeyRequest())->setName($formattedName); $response = $gapicClient->undeleteKey($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -714,17 +717,19 @@ public function undeleteKeyExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->keyName('[PROJECT]', '[LOCATION]', '[KEY]'); - $request = (new UndeleteKeyRequest()) - ->setName($formattedName); + $request = (new UndeleteKeyRequest())->setName($formattedName); $response = $gapicClient->undeleteKey($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -788,8 +793,7 @@ public function updateKeyTest() $operationsTransport->addResponse($completeOperation); // Mock request $key = new Key(); - $request = (new UpdateKeyRequest()) - ->setKey($key); + $request = (new UpdateKeyRequest())->setKey($key); $response = $gapicClient->updateKey($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -845,17 +849,19 @@ public function updateKeyExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $key = new Key(); - $request = (new UpdateKeyRequest()) - ->setKey($key); + $request = (new UpdateKeyRequest())->setKey($key); $response = $gapicClient->updateKey($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -920,9 +926,7 @@ public function createKeyAsyncTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $key = new Key(); - $request = (new CreateKeyRequest()) - ->setParent($formattedParent) - ->setKey($key); + $request = (new CreateKeyRequest())->setParent($formattedParent)->setKey($key); $response = $gapicClient->createKeyAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); diff --git a/BareMetalSolution/.OwlBot.yaml b/BareMetalSolution/.OwlBot.yaml index c72a66c3f46..e8955b25437 100644 --- a/BareMetalSolution/.OwlBot.yaml +++ b/BareMetalSolution/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/baremetalsolution/v2/.*-php/(.*) - dest: /owl-bot-staging/BareMetalSolution/v2/$1 + - source: /google/cloud/baremetalsolution/(v2)/.*-php/(.*) + dest: /owl-bot-staging/BareMetalSolution/$1/$2 api-name: BareMetalSolution diff --git a/BareMetalSolution/README.md b/BareMetalSolution/README.md index ad1a21aca80..943e6cad96d 100644 --- a/BareMetalSolution/README.md +++ b/BareMetalSolution/README.md @@ -30,9 +30,8 @@ on authenticating your client. Once authenticated, you'll be ready to start maki ### Version -This component is considered beta. As such, it should be expected to be mostly -stable and we're working towards a release candidate. We will address issues -and requests with a higher priority. +This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in +any minor or patch releases. We will address issues and requests with the highest priority. ### Next Steps diff --git a/BareMetalSolution/owlbot.py b/BareMetalSolution/owlbot.py index fa2e47441dd..8decb8c9591 100644 --- a/BareMetalSolution/owlbot.py +++ b/BareMetalSolution/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2022 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,40 +30,16 @@ # 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) - -### [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([ @@ -73,8 +49,8 @@ '--package=@prettier/plugin-php@^0.16', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', - '--print-width=80']) \ No newline at end of file + '--print-width=120']) diff --git a/BareMetalSolution/src/V2/BareMetalSolutionClient.php b/BareMetalSolution/src/V2/BareMetalSolutionClient.php deleted file mode 100644 index a2f7413b886..00000000000 --- a/BareMetalSolution/src/V2/BareMetalSolutionClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListInstances', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\ListInstancesResponse', 'decode'], - $metadata, $options); - } - - /** - * Get details about a single server. - * @param \Google\Cloud\BareMetalSolution\V2\GetInstanceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetInstance(\Google\Cloud\BareMetalSolution\V2\GetInstanceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/GetInstance', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\Instance', 'decode'], - $metadata, $options); - } - - /** - * Update details of a single server. - * @param \Google\Cloud\BareMetalSolution\V2\UpdateInstanceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateInstance(\Google\Cloud\BareMetalSolution\V2\UpdateInstanceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateInstance', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Perform an ungraceful, hard reset on a server. Equivalent to shutting the - * power off and then turning it back on. - * @param \Google\Cloud\BareMetalSolution\V2\ResetInstanceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ResetInstance(\Google\Cloud\BareMetalSolution\V2\ResetInstanceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/ResetInstance', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Starts a server that was shutdown. - * @param \Google\Cloud\BareMetalSolution\V2\StartInstanceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function StartInstance(\Google\Cloud\BareMetalSolution\V2\StartInstanceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/StartInstance', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Stop a running server. - * @param \Google\Cloud\BareMetalSolution\V2\StopInstanceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function StopInstance(\Google\Cloud\BareMetalSolution\V2\StopInstanceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/StopInstance', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Detach LUN from Instance. - * @param \Google\Cloud\BareMetalSolution\V2\DetachLunRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DetachLun(\Google\Cloud\BareMetalSolution\V2\DetachLunRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/DetachLun', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * List storage volumes in a given project and location. - * @param \Google\Cloud\BareMetalSolution\V2\ListVolumesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListVolumes(\Google\Cloud\BareMetalSolution\V2\ListVolumesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListVolumes', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\ListVolumesResponse', 'decode'], - $metadata, $options); - } - - /** - * Get details of a single storage volume. - * @param \Google\Cloud\BareMetalSolution\V2\GetVolumeRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetVolume(\Google\Cloud\BareMetalSolution\V2\GetVolumeRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/GetVolume', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\Volume', 'decode'], - $metadata, $options); - } - - /** - * Update details of a single storage volume. - * @param \Google\Cloud\BareMetalSolution\V2\UpdateVolumeRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateVolume(\Google\Cloud\BareMetalSolution\V2\UpdateVolumeRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateVolume', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Emergency Volume resize. - * @param \Google\Cloud\BareMetalSolution\V2\ResizeVolumeRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ResizeVolume(\Google\Cloud\BareMetalSolution\V2\ResizeVolumeRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/ResizeVolume', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * List network in a given project and location. - * @param \Google\Cloud\BareMetalSolution\V2\ListNetworksRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListNetworks(\Google\Cloud\BareMetalSolution\V2\ListNetworksRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNetworks', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\ListNetworksResponse', 'decode'], - $metadata, $options); - } - - /** - * List all Networks (and used IPs for each Network) in the vendor account - * associated with the specified project. - * @param \Google\Cloud\BareMetalSolution\V2\ListNetworkUsageRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListNetworkUsage(\Google\Cloud\BareMetalSolution\V2\ListNetworkUsageRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNetworkUsage', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\ListNetworkUsageResponse', 'decode'], - $metadata, $options); - } - - /** - * Get details of a single network. - * @param \Google\Cloud\BareMetalSolution\V2\GetNetworkRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetNetwork(\Google\Cloud\BareMetalSolution\V2\GetNetworkRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/GetNetwork', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\Network', 'decode'], - $metadata, $options); - } - - /** - * Update details of a single network. - * @param \Google\Cloud\BareMetalSolution\V2\UpdateNetworkRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateNetwork(\Google\Cloud\BareMetalSolution\V2\UpdateNetworkRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateNetwork', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Get details of a single storage logical unit number(LUN). - * @param \Google\Cloud\BareMetalSolution\V2\GetLunRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetLun(\Google\Cloud\BareMetalSolution\V2\GetLunRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/GetLun', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\Lun', 'decode'], - $metadata, $options); - } - - /** - * List storage volume luns for given storage volume. - * @param \Google\Cloud\BareMetalSolution\V2\ListLunsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListLuns(\Google\Cloud\BareMetalSolution\V2\ListLunsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListLuns', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\ListLunsResponse', 'decode'], - $metadata, $options); - } - - /** - * Get details of a single NFS share. - * @param \Google\Cloud\BareMetalSolution\V2\GetNfsShareRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetNfsShare(\Google\Cloud\BareMetalSolution\V2\GetNfsShareRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/GetNfsShare', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\NfsShare', 'decode'], - $metadata, $options); - } - - /** - * List NFS shares. - * @param \Google\Cloud\BareMetalSolution\V2\ListNfsSharesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListNfsShares(\Google\Cloud\BareMetalSolution\V2\ListNfsSharesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNfsShares', - $argument, - ['\Google\Cloud\BareMetalSolution\V2\ListNfsSharesResponse', 'decode'], - $metadata, $options); - } - - /** - * Update details of a single NFS share. - * @param \Google\Cloud\BareMetalSolution\V2\UpdateNfsShareRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateNfsShare(\Google\Cloud\BareMetalSolution\V2\UpdateNfsShareRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateNfsShare', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - -} diff --git a/BareMetalSolution/src/V2/Client/BareMetalSolutionClient.php b/BareMetalSolution/src/V2/Client/BareMetalSolutionClient.php index 46d8e876600..bd66a99103f 100644 --- a/BareMetalSolution/src/V2/Client/BareMetalSolutionClient.php +++ b/BareMetalSolution/src/V2/Client/BareMetalSolutionClient.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 instance * resource. @@ -287,8 +306,11 @@ public static function instanceConfigName(string $project, string $location, str * * @return string The formatted interconnect_attachment resource. */ - public static function interconnectAttachmentName(string $project, string $region, string $interconnectAttachment): string - { + public static function interconnectAttachmentName( + string $project, + string $region, + string $interconnectAttachment + ): string { return self::getPathTemplate('interconnectAttachment')->render([ 'project' => $project, 'region' => $region, @@ -420,8 +442,11 @@ public static function provisioningConfigName(string $project, string $location, * * @return string The formatted server_network_template resource. */ - public static function serverNetworkTemplateName(string $project, string $location, string $serverNetworkTemplate): string - { + public static function serverNetworkTemplateName( + string $project, + string $location, + string $serverNetworkTemplate + ): string { return self::getPathTemplate('serverNetworkTemplate')->render([ 'project' => $project, 'location' => $location, @@ -497,8 +522,12 @@ public static function volumeConfigName(string $project, string $location, strin * * @return string The formatted volume_snapshot resource. */ - public static function volumeSnapshotName(string $project, string $location, string $volume, string $snapshot): string - { + public static function volumeSnapshotName( + string $project, + string $location, + string $volume, + string $snapshot + ): string { return self::getPathTemplate('volumeSnapshot')->render([ 'project' => $project, 'location' => $location, @@ -664,8 +693,10 @@ public function createNfsShare(CreateNfsShareRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function createProvisioningConfig(CreateProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig - { + public function createProvisioningConfig( + CreateProvisioningConfigRequest $request, + array $callOptions = [] + ): ProvisioningConfig { return $this->startApiCall('CreateProvisioningConfig', $request, $callOptions)->wait(); } @@ -848,8 +879,10 @@ public function detachLun(DetachLunRequest $request, array $callOptions = []): O * * @throws ApiException Thrown if the API call fails. */ - public function disableInteractiveSerialConsole(DisableInteractiveSerialConsoleRequest $request, array $callOptions = []): OperationResponse - { + public function disableInteractiveSerialConsole( + DisableInteractiveSerialConsoleRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('DisableInteractiveSerialConsole', $request, $callOptions)->wait(); } @@ -875,8 +908,10 @@ public function disableInteractiveSerialConsole(DisableInteractiveSerialConsoleR * * @throws ApiException Thrown if the API call fails. */ - public function enableInteractiveSerialConsole(EnableInteractiveSerialConsoleRequest $request, array $callOptions = []): OperationResponse - { + public function enableInteractiveSerialConsole( + EnableInteractiveSerialConsoleRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('EnableInteractiveSerialConsole', $request, $callOptions)->wait(); } @@ -1060,8 +1095,10 @@ public function getNfsShare(GetNfsShareRequest $request, array $callOptions = [] * * @throws ApiException Thrown if the API call fails. */ - public function getProvisioningConfig(GetProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig - { + public function getProvisioningConfig( + GetProvisioningConfigRequest $request, + array $callOptions = [] + ): ProvisioningConfig { return $this->startApiCall('GetProvisioningConfig', $request, $callOptions)->wait(); } @@ -1192,8 +1229,10 @@ public function listLuns(ListLunsRequest $request, array $callOptions = []): Pag * * @throws ApiException Thrown if the API call fails. */ - public function listNetworkUsage(ListNetworkUsageRequest $request, array $callOptions = []): ListNetworkUsageResponse - { + public function listNetworkUsage( + ListNetworkUsageRequest $request, + array $callOptions = [] + ): ListNetworkUsageResponse { return $this->startApiCall('ListNetworkUsage', $request, $callOptions)->wait(); } @@ -1297,8 +1336,10 @@ public function listOSImages(ListOSImagesRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function listProvisioningQuotas(ListProvisioningQuotasRequest $request, array $callOptions = []): PagedListResponse - { + public function listProvisioningQuotas( + ListProvisioningQuotasRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListProvisioningQuotas', $request, $callOptions); } @@ -1568,8 +1609,10 @@ public function resizeVolume(ResizeVolumeRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function restoreVolumeSnapshot(RestoreVolumeSnapshotRequest $request, array $callOptions = []): OperationResponse - { + public function restoreVolumeSnapshot( + RestoreVolumeSnapshotRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('RestoreVolumeSnapshot', $request, $callOptions)->wait(); } @@ -1647,8 +1690,10 @@ public function stopInstance(StopInstanceRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function submitProvisioningConfig(SubmitProvisioningConfigRequest $request, array $callOptions = []): SubmitProvisioningConfigResponse - { + public function submitProvisioningConfig( + SubmitProvisioningConfigRequest $request, + array $callOptions = [] + ): SubmitProvisioningConfigResponse { return $this->startApiCall('SubmitProvisioningConfig', $request, $callOptions)->wait(); } @@ -1752,8 +1797,10 @@ public function updateNfsShare(UpdateNfsShareRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function updateProvisioningConfig(UpdateProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig - { + public function updateProvisioningConfig( + UpdateProvisioningConfigRequest $request, + array $callOptions = [] + ): ProvisioningConfig { return $this->startApiCall('UpdateProvisioningConfig', $request, $callOptions)->wait(); } diff --git a/BareMetalSolution/src/V2/CreateNfsShareRequest.php b/BareMetalSolution/src/V2/CreateNfsShareRequest.php index 2e24a4849ce..7440bd8a955 100644 --- a/BareMetalSolution/src/V2/CreateNfsShareRequest.php +++ b/BareMetalSolution/src/V2/CreateNfsShareRequest.php @@ -20,13 +20,13 @@ class CreateNfsShareRequest 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 NfsShare to create. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.NfsShare nfs_share = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $nfs_share = null; + protected $nfs_share = null; /** * @param string $parent Required. The parent project and location. Please see diff --git a/BareMetalSolution/src/V2/CreateProvisioningConfigRequest.php b/BareMetalSolution/src/V2/CreateProvisioningConfigRequest.php index 276516a8394..af131bba0df 100644 --- a/BareMetalSolution/src/V2/CreateProvisioningConfigRequest.php +++ b/BareMetalSolution/src/V2/CreateProvisioningConfigRequest.php @@ -21,20 +21,20 @@ class CreateProvisioningConfigRequest 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 ProvisioningConfig to create. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.ProvisioningConfig provisioning_config = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $provisioning_config = null; + protected $provisioning_config = null; /** * Optional. Email provided to send a confirmation with provisioning config * to. * * Generated from protobuf field string email = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $email = ''; + protected $email = ''; /** * @param string $parent Required. The parent project and location containing the diff --git a/BareMetalSolution/src/V2/CreateSSHKeyRequest.php b/BareMetalSolution/src/V2/CreateSSHKeyRequest.php index 9f4f02658e3..cfedc394524 100644 --- a/BareMetalSolution/src/V2/CreateSSHKeyRequest.php +++ b/BareMetalSolution/src/V2/CreateSSHKeyRequest.php @@ -20,13 +20,13 @@ class CreateSSHKeyRequest 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 key to register. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.SSHKey ssh_key = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $ssh_key = null; + protected $ssh_key = null; /** * Required. The ID to use for the key, which will become the final component * of the key's resource name. @@ -35,7 +35,7 @@ class CreateSSHKeyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string ssh_key_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $ssh_key_id = ''; + protected $ssh_key_id = ''; /** * @param string $parent Required. The parent containing the SSH keys. Please see diff --git a/BareMetalSolution/src/V2/CreateVolumeSnapshotRequest.php b/BareMetalSolution/src/V2/CreateVolumeSnapshotRequest.php index 6743a98fb5a..596dbb03246 100644 --- a/BareMetalSolution/src/V2/CreateVolumeSnapshotRequest.php +++ b/BareMetalSolution/src/V2/CreateVolumeSnapshotRequest.php @@ -20,13 +20,13 @@ class CreateVolumeSnapshotRequest 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 snapshot to create. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VolumeSnapshot volume_snapshot = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $volume_snapshot = null; + protected $volume_snapshot = null; /** * @param string $parent Required. The volume to snapshot. Please see diff --git a/BareMetalSolution/src/V2/DeleteNfsShareRequest.php b/BareMetalSolution/src/V2/DeleteNfsShareRequest.php index 3d70ecd1924..f3f766e0479 100644 --- a/BareMetalSolution/src/V2/DeleteNfsShareRequest.php +++ b/BareMetalSolution/src/V2/DeleteNfsShareRequest.php @@ -20,7 +20,7 @@ class DeleteNfsShareRequest 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 NFS share to delete. Please see diff --git a/BareMetalSolution/src/V2/DeleteSSHKeyRequest.php b/BareMetalSolution/src/V2/DeleteSSHKeyRequest.php index e158da86312..814572e4b1b 100644 --- a/BareMetalSolution/src/V2/DeleteSSHKeyRequest.php +++ b/BareMetalSolution/src/V2/DeleteSSHKeyRequest.php @@ -21,7 +21,7 @@ class DeleteSSHKeyRequest 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 SSH key to delete. diff --git a/BareMetalSolution/src/V2/DeleteVolumeSnapshotRequest.php b/BareMetalSolution/src/V2/DeleteVolumeSnapshotRequest.php index b487e0db3c1..19119d332bc 100644 --- a/BareMetalSolution/src/V2/DeleteVolumeSnapshotRequest.php +++ b/BareMetalSolution/src/V2/DeleteVolumeSnapshotRequest.php @@ -20,7 +20,7 @@ class DeleteVolumeSnapshotRequest 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 snapshot to delete. Please see diff --git a/BareMetalSolution/src/V2/DetachLunRequest.php b/BareMetalSolution/src/V2/DetachLunRequest.php index 5af2a4fa2b2..81712c80e09 100644 --- a/BareMetalSolution/src/V2/DetachLunRequest.php +++ b/BareMetalSolution/src/V2/DetachLunRequest.php @@ -20,19 +20,19 @@ class DetachLunRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string instance = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $instance = ''; + protected $instance = ''; /** * Required. Name of the Lun to detach. * * Generated from protobuf field string lun = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $lun = ''; + protected $lun = ''; /** * If true, performs lun unmapping without instance reboot. * * Generated from protobuf field bool skip_reboot = 3; */ - private $skip_reboot = false; + protected $skip_reboot = false; /** * @param string $instance Required. Name of the instance. Please see diff --git a/BareMetalSolution/src/V2/DisableInteractiveSerialConsoleRequest.php b/BareMetalSolution/src/V2/DisableInteractiveSerialConsoleRequest.php index f3403950cf1..aa3868a802a 100644 --- a/BareMetalSolution/src/V2/DisableInteractiveSerialConsoleRequest.php +++ b/BareMetalSolution/src/V2/DisableInteractiveSerialConsoleRequest.php @@ -20,7 +20,7 @@ class DisableInteractiveSerialConsoleRequest 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 = ''; /** * @param string $name Required. Name of the resource. Please see diff --git a/BareMetalSolution/src/V2/EnableInteractiveSerialConsoleRequest.php b/BareMetalSolution/src/V2/EnableInteractiveSerialConsoleRequest.php index 9ed4c87a324..6f2964df785 100644 --- a/BareMetalSolution/src/V2/EnableInteractiveSerialConsoleRequest.php +++ b/BareMetalSolution/src/V2/EnableInteractiveSerialConsoleRequest.php @@ -20,7 +20,7 @@ class EnableInteractiveSerialConsoleRequest extends \Google\Protobuf\Internal\Me * * 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. Please see diff --git a/BareMetalSolution/src/V2/EvictLunRequest.php b/BareMetalSolution/src/V2/EvictLunRequest.php index a3edd7223e6..38c315af1d6 100644 --- a/BareMetalSolution/src/V2/EvictLunRequest.php +++ b/BareMetalSolution/src/V2/EvictLunRequest.php @@ -20,7 +20,7 @@ class EvictLunRequest 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 lun. Please see diff --git a/BareMetalSolution/src/V2/EvictVolumeRequest.php b/BareMetalSolution/src/V2/EvictVolumeRequest.php index 3c29c35ef70..3f04fee83e5 100644 --- a/BareMetalSolution/src/V2/EvictVolumeRequest.php +++ b/BareMetalSolution/src/V2/EvictVolumeRequest.php @@ -20,7 +20,7 @@ class EvictVolumeRequest 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 Volume. Please see diff --git a/BareMetalSolution/src/V2/Gapic/BareMetalSolutionGapicClient.php b/BareMetalSolution/src/V2/Gapic/BareMetalSolutionGapicClient.php deleted file mode 100644 index f6c755250da..00000000000 --- a/BareMetalSolution/src/V2/Gapic/BareMetalSolutionGapicClient.php +++ /dev/null @@ -1,3976 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $nfsShare = new NfsShare(); - * $operationResponse = $bareMetalSolutionClient->createNfsShare($formattedParent, $nfsShare); - * $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 = $bareMetalSolutionClient->createNfsShare($formattedParent, $nfsShare); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'createNfsShare'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->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\BareMetalSolution\V2\Client\BareMetalSolutionClient}. - */ -class BareMetalSolutionGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.baremetalsolution.v2.BareMetalSolution'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'baremetalsolution.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'baremetalsolution.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 $instanceNameTemplate; - - private static $instanceConfigNameTemplate; - - private static $interconnectAttachmentNameTemplate; - - private static $locationNameTemplate; - - private static $lunNameTemplate; - - private static $nFSShareNameTemplate; - - private static $networkNameTemplate; - - private static $networkConfigNameTemplate; - - private static $provisioningConfigNameTemplate; - - private static $serverNetworkTemplateNameTemplate; - - private static $sshKeyNameTemplate; - - private static $volumeNameTemplate; - - private static $volumeConfigNameTemplate; - - private static $volumeSnapshotNameTemplate; - - 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/bare_metal_solution_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/bare_metal_solution_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../resources/bare_metal_solution_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/bare_metal_solution_rest_client_config.php', - ], - ], - ]; - } - - private static function getInstanceNameTemplate() - { - if (self::$instanceNameTemplate == null) { - self::$instanceNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' - ); - } - - return self::$instanceNameTemplate; - } - - private static function getInstanceConfigNameTemplate() - { - if (self::$instanceConfigNameTemplate == null) { - self::$instanceConfigNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/instanceConfigs/{instance_config}' - ); - } - - return self::$instanceConfigNameTemplate; - } - - private static function getInterconnectAttachmentNameTemplate() - { - if (self::$interconnectAttachmentNameTemplate == null) { - self::$interconnectAttachmentNameTemplate = new PathTemplate( - 'projects/{project}/regions/{region}/interconnectAttachments/{interconnect_attachment}' - ); - } - - 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 getLunNameTemplate() - { - if (self::$lunNameTemplate == null) { - self::$lunNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/volumes/{volume}/luns/{lun}' - ); - } - - return self::$lunNameTemplate; - } - - private static function getNFSShareNameTemplate() - { - if (self::$nFSShareNameTemplate == null) { - self::$nFSShareNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/nfsShares/{nfs_share}' - ); - } - - return self::$nFSShareNameTemplate; - } - - private static function getNetworkNameTemplate() - { - if (self::$networkNameTemplate == null) { - self::$networkNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/networks/{network}' - ); - } - - return self::$networkNameTemplate; - } - - private static function getNetworkConfigNameTemplate() - { - if (self::$networkConfigNameTemplate == null) { - self::$networkConfigNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/networkConfigs/{network_config}' - ); - } - - return self::$networkConfigNameTemplate; - } - - private static function getProvisioningConfigNameTemplate() - { - if (self::$provisioningConfigNameTemplate == null) { - self::$provisioningConfigNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/provisioningConfigs/{provisioning_config}' - ); - } - - return self::$provisioningConfigNameTemplate; - } - - private static function getServerNetworkTemplateNameTemplate() - { - if (self::$serverNetworkTemplateNameTemplate == null) { - self::$serverNetworkTemplateNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/serverNetworkTemplate/{server_network_template}' - ); - } - - return self::$serverNetworkTemplateNameTemplate; - } - - private static function getSshKeyNameTemplate() - { - if (self::$sshKeyNameTemplate == null) { - self::$sshKeyNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/sshKeys/{ssh_key}' - ); - } - - return self::$sshKeyNameTemplate; - } - - private static function getVolumeNameTemplate() - { - if (self::$volumeNameTemplate == null) { - self::$volumeNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/volumes/{volume}' - ); - } - - return self::$volumeNameTemplate; - } - - private static function getVolumeConfigNameTemplate() - { - if (self::$volumeConfigNameTemplate == null) { - self::$volumeConfigNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/volumeConfigs/{volume_config}' - ); - } - - return self::$volumeConfigNameTemplate; - } - - private static function getVolumeSnapshotNameTemplate() - { - if (self::$volumeSnapshotNameTemplate == null) { - self::$volumeSnapshotNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot}' - ); - } - - return self::$volumeSnapshotNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'instance' => self::getInstanceNameTemplate(), - 'instanceConfig' => self::getInstanceConfigNameTemplate(), - 'interconnectAttachment' => self::getInterconnectAttachmentNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'lun' => self::getLunNameTemplate(), - 'nFSShare' => self::getNFSShareNameTemplate(), - 'network' => self::getNetworkNameTemplate(), - 'networkConfig' => self::getNetworkConfigNameTemplate(), - 'provisioningConfig' => self::getProvisioningConfigNameTemplate(), - 'serverNetworkTemplate' => self::getServerNetworkTemplateNameTemplate(), - 'sshKey' => self::getSshKeyNameTemplate(), - 'volume' => self::getVolumeNameTemplate(), - 'volumeConfig' => self::getVolumeConfigNameTemplate(), - 'volumeSnapshot' => self::getVolumeSnapshotNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * 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 - * instance_config resource. - * - * @param string $project - * @param string $location - * @param string $instanceConfig - * - * @return string The formatted instance_config resource. - */ - public static function instanceConfigName( - $project, - $location, - $instanceConfig - ) { - return self::getInstanceConfigNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'instance_config' => $instanceConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * interconnect_attachment resource. - * - * @param string $project - * @param string $region - * @param string $interconnectAttachment - * - * @return string The formatted interconnect_attachment resource. - */ - public static function interconnectAttachmentName( - $project, - $region, - $interconnectAttachment - ) { - return self::getInterconnectAttachmentNameTemplate()->render([ - 'project' => $project, - 'region' => $region, - 'interconnect_attachment' => $interconnectAttachment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName($project, $location) - { - return self::getLocationNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a lun - * resource. - * - * @param string $project - * @param string $location - * @param string $volume - * @param string $lun - * - * @return string The formatted lun resource. - */ - public static function lunName($project, $location, $volume, $lun) - { - return self::getLunNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - 'lun' => $lun, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a nfs_share - * resource. - * - * @param string $project - * @param string $location - * @param string $nfsShare - * - * @return string The formatted nfs_share resource. - */ - public static function nFSShareName($project, $location, $nfsShare) - { - return self::getNFSShareNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'nfs_share' => $nfsShare, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $location - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName($project, $location, $network) - { - return self::getNetworkNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * network_config resource. - * - * @param string $project - * @param string $location - * @param string $networkConfig - * - * @return string The formatted network_config resource. - */ - public static function networkConfigName( - $project, - $location, - $networkConfig - ) { - return self::getNetworkConfigNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'network_config' => $networkConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * provisioning_config resource. - * - * @param string $project - * @param string $location - * @param string $provisioningConfig - * - * @return string The formatted provisioning_config resource. - */ - public static function provisioningConfigName( - $project, - $location, - $provisioningConfig - ) { - return self::getProvisioningConfigNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'provisioning_config' => $provisioningConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * server_network_template resource. - * - * @param string $project - * @param string $location - * @param string $serverNetworkTemplate - * - * @return string The formatted server_network_template resource. - */ - public static function serverNetworkTemplateName( - $project, - $location, - $serverNetworkTemplate - ) { - return self::getServerNetworkTemplateNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'server_network_template' => $serverNetworkTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a ssh_key - * resource. - * - * @param string $project - * @param string $location - * @param string $sshKey - * - * @return string The formatted ssh_key resource. - */ - public static function sshKeyName($project, $location, $sshKey) - { - return self::getSshKeyNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'ssh_key' => $sshKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a volume - * resource. - * - * @param string $project - * @param string $location - * @param string $volume - * - * @return string The formatted volume resource. - */ - public static function volumeName($project, $location, $volume) - { - return self::getVolumeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * volume_config resource. - * - * @param string $project - * @param string $location - * @param string $volumeConfig - * - * @return string The formatted volume_config resource. - */ - public static function volumeConfigName($project, $location, $volumeConfig) - { - return self::getVolumeConfigNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'volume_config' => $volumeConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * volume_snapshot resource. - * - * @param string $project - * @param string $location - * @param string $volume - * @param string $snapshot - * - * @return string The formatted volume_snapshot resource. - */ - public static function volumeSnapshotName( - $project, - $location, - $volume, - $snapshot - ) { - return self::getVolumeSnapshotNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - 'snapshot' => $snapshot, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - instance: projects/{project}/locations/{location}/instances/{instance} - * - instanceConfig: projects/{project}/locations/{location}/instanceConfigs/{instance_config} - * - interconnectAttachment: projects/{project}/regions/{region}/interconnectAttachments/{interconnect_attachment} - * - location: projects/{project}/locations/{location} - * - lun: projects/{project}/locations/{location}/volumes/{volume}/luns/{lun} - * - nFSShare: projects/{project}/locations/{location}/nfsShares/{nfs_share} - * - network: projects/{project}/locations/{location}/networks/{network} - * - networkConfig: projects/{project}/locations/{location}/networkConfigs/{network_config} - * - provisioningConfig: projects/{project}/locations/{location}/provisioningConfigs/{provisioning_config} - * - serverNetworkTemplate: projects/{project}/locations/{location}/serverNetworkTemplate/{server_network_template} - * - sshKey: projects/{project}/locations/{location}/sshKeys/{ssh_key} - * - volume: projects/{project}/locations/{location}/volumes/{volume} - * - volumeConfig: projects/{project}/locations/{location}/volumeConfigs/{volume_config} - * - volumeSnapshot: projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($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 'baremetalsolution.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Create an NFS share. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * $nfsShare = new NfsShare(); - * $operationResponse = $bareMetalSolutionClient->createNfsShare($formattedParent, $nfsShare); - * $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 = $bareMetalSolutionClient->createNfsShare($formattedParent, $nfsShare); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'createNfsShare'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent project and location. - * @param NfsShare $nfsShare Required. The NfsShare 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 createNfsShare($parent, $nfsShare, array $optionalArgs = []) - { - $request = new CreateNfsShareRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setNfsShare($nfsShare); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateNfsShare', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Create new ProvisioningConfig. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * $provisioningConfig = new ProvisioningConfig(); - * $response = $bareMetalSolutionClient->createProvisioningConfig($formattedParent, $provisioningConfig); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent project and location containing the - * ProvisioningConfig. - * @param ProvisioningConfig $provisioningConfig Required. The ProvisioningConfig to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $email - * Optional. Email provided to send a confirmation with provisioning config - * 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\Cloud\BareMetalSolution\V2\ProvisioningConfig - * - * @throws ApiException if the remote call fails - */ - public function createProvisioningConfig( - $parent, - $provisioningConfig, - array $optionalArgs = [] - ) { - $request = new CreateProvisioningConfigRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setProvisioningConfig($provisioningConfig); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['email'])) { - $request->setEmail($optionalArgs['email']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateProvisioningConfig', - ProvisioningConfig::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Register a public SSH key in the specified project for use with the - * interactive serial console feature. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * $sshKey = new SSHKey(); - * $sshKeyId = 'ssh_key_id'; - * $response = $bareMetalSolutionClient->createSSHKey($formattedParent, $sshKey, $sshKeyId); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent containing the SSH keys. - * @param SSHKey $sshKey Required. The SSH key to register. - * @param string $sshKeyId Required. The ID to use for the key, which will become the final component - * of the key's resource name. - * - * This value must match the regex: - * [a-zA-Z0-9@.\-_]{1,64} - * @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\BareMetalSolution\V2\SSHKey - * - * @throws ApiException if the remote call fails - */ - public function createSSHKey( - $parent, - $sshKey, - $sshKeyId, - array $optionalArgs = [] - ) { - $request = new CreateSSHKeyRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setSshKey($sshKey); - $request->setSshKeyId($sshKeyId); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateSSHKey', - SSHKey::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Takes a snapshot of a boot volume. - * Returns INVALID_ARGUMENT if called for a non-boot volume. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - * $volumeSnapshot = new VolumeSnapshot(); - * $response = $bareMetalSolutionClient->createVolumeSnapshot($formattedParent, $volumeSnapshot); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. The volume to snapshot. - * @param VolumeSnapshot $volumeSnapshot Required. The snapshot 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\BareMetalSolution\V2\VolumeSnapshot - * - * @throws ApiException if the remote call fails - */ - public function createVolumeSnapshot( - $parent, - $volumeSnapshot, - array $optionalArgs = [] - ) { - $request = new CreateVolumeSnapshotRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setVolumeSnapshot($volumeSnapshot); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateVolumeSnapshot', - VolumeSnapshot::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Delete an NFS share. The underlying volume is automatically deleted. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - * $operationResponse = $bareMetalSolutionClient->deleteNfsShare($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 = $bareMetalSolutionClient->deleteNfsShare($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'deleteNfsShare'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the NFS share 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 deleteNfsShare($name, array $optionalArgs = []) - { - $request = new DeleteNfsShareRequest(); - $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( - 'DeleteNfsShare', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a public SSH key registered in the specified project. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->sshKeyName('[PROJECT]', '[LOCATION]', '[SSH_KEY]'); - * $bareMetalSolutionClient->deleteSSHKey($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the SSH key to delete. - * Currently, the only valid value for the location is "global". - * @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 deleteSSHKey($name, array $optionalArgs = []) - { - $request = new DeleteSSHKeyRequest(); - $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( - 'DeleteSSHKey', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a volume snapshot. - * Returns INVALID_ARGUMENT if called for a non-boot volume. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - * $bareMetalSolutionClient->deleteVolumeSnapshot($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the snapshot 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 deleteVolumeSnapshot($name, array $optionalArgs = []) - { - $request = new DeleteVolumeSnapshotRequest(); - $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( - 'DeleteVolumeSnapshot', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Detach LUN from Instance. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedInstance = $bareMetalSolutionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $formattedLun = $bareMetalSolutionClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - * $operationResponse = $bareMetalSolutionClient->detachLun($formattedInstance, $formattedLun); - * $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 = $bareMetalSolutionClient->detachLun($formattedInstance, $formattedLun); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'detachLun'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $instance Required. Name of the instance. - * @param string $lun Required. Name of the Lun to detach. - * @param array $optionalArgs { - * Optional. - * - * @type bool $skipReboot - * If true, performs lun unmapping without instance reboot. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 detachLun($instance, $lun, array $optionalArgs = []) - { - $request = new DetachLunRequest(); - $requestParamHeaders = []; - $request->setInstance($instance); - $request->setLun($lun); - $requestParamHeaders['instance'] = $instance; - if (isset($optionalArgs['skipReboot'])) { - $request->setSkipReboot($optionalArgs['skipReboot']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DetachLun', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Disable the interactive serial console feature on an instance. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $operationResponse = $bareMetalSolutionClient->disableInteractiveSerialConsole($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 = $bareMetalSolutionClient->disableInteractiveSerialConsole($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'disableInteractiveSerialConsole'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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 disableInteractiveSerialConsole( - $name, - array $optionalArgs = [] - ) { - $request = new DisableInteractiveSerialConsoleRequest(); - $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( - 'DisableInteractiveSerialConsole', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Enable the interactive serial console feature on an instance. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $operationResponse = $bareMetalSolutionClient->enableInteractiveSerialConsole($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 = $bareMetalSolutionClient->enableInteractiveSerialConsole($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'enableInteractiveSerialConsole'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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 enableInteractiveSerialConsole( - $name, - array $optionalArgs = [] - ) { - $request = new EnableInteractiveSerialConsoleRequest(); - $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( - 'EnableInteractiveSerialConsole', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Skips lun's cooloff and deletes it now. - * Lun must be in cooloff state. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - * $operationResponse = $bareMetalSolutionClient->evictLun($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 = $bareMetalSolutionClient->evictLun($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'evictLun'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the lun. - * @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 evictLun($name, array $optionalArgs = []) - { - $request = new EvictLunRequest(); - $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( - 'EvictLun', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Skips volume's cooloff and deletes it now. - * Volume must be in cooloff state. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - * $operationResponse = $bareMetalSolutionClient->evictVolume($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 = $bareMetalSolutionClient->evictVolume($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'evictVolume'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the Volume. - * @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 evictVolume($name, array $optionalArgs = []) - { - $request = new EvictVolumeRequest(); - $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( - 'EvictVolume', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Get details about a single server. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $response = $bareMetalSolutionClient->getInstance($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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\BareMetalSolution\V2\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(); - } - - /** - * Get details of a single storage logical unit number(LUN). - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - * $response = $bareMetalSolutionClient->getLun($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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\BareMetalSolution\V2\Lun - * - * @throws ApiException if the remote call fails - */ - public function getLun($name, array $optionalArgs = []) - { - $request = new GetLunRequest(); - $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( - 'GetLun', - Lun::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get details of a single network. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); - * $response = $bareMetalSolutionClient->getNetwork($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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\BareMetalSolution\V2\Network - * - * @throws ApiException if the remote call fails - */ - public function getNetwork($name, array $optionalArgs = []) - { - $request = new GetNetworkRequest(); - $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( - 'GetNetwork', - Network::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get details of a single NFS share. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - * $response = $bareMetalSolutionClient->getNfsShare($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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\BareMetalSolution\V2\NfsShare - * - * @throws ApiException if the remote call fails - */ - public function getNfsShare($name, array $optionalArgs = []) - { - $request = new GetNfsShareRequest(); - $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( - 'GetNfsShare', - NfsShare::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get ProvisioningConfig by name. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->provisioningConfigName('[PROJECT]', '[LOCATION]', '[PROVISIONING_CONFIG]'); - * $response = $bareMetalSolutionClient->getProvisioningConfig($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the ProvisioningConfig. - * @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\BareMetalSolution\V2\ProvisioningConfig - * - * @throws ApiException if the remote call fails - */ - public function getProvisioningConfig($name, array $optionalArgs = []) - { - $request = new GetProvisioningConfigRequest(); - $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( - 'GetProvisioningConfig', - ProvisioningConfig::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Get details of a single storage volume. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - * $response = $bareMetalSolutionClient->getVolume($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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\BareMetalSolution\V2\Volume - * - * @throws ApiException if the remote call fails - */ - public function getVolume($name, array $optionalArgs = []) - { - $request = new GetVolumeRequest(); - $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( - 'GetVolume', - Volume::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Returns the specified snapshot resource. - * Returns INVALID_ARGUMENT if called for a non-boot volume. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - * $response = $bareMetalSolutionClient->getVolumeSnapshot($formattedName); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the snapshot. - * @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\BareMetalSolution\V2\VolumeSnapshot - * - * @throws ApiException if the remote call fails - */ - public function getVolumeSnapshot($name, array $optionalArgs = []) - { - $request = new GetVolumeSnapshotRequest(); - $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( - 'GetVolumeSnapshot', - VolumeSnapshot::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * List servers in a given project and location. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listInstances($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listInstances($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListInstancesRequest. - * @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 - * 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['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 - ); - } - - /** - * List storage volume luns for given storage volume. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listLuns($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listLuns($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListLunsRequest. - * @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 listLuns($parent, array $optionalArgs = []) - { - $request = new ListLunsRequest(); - $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( - 'ListLuns', - $optionalArgs, - ListLunsResponse::class, - $request - ); - } - - /** - * List all Networks (and used IPs for each Network) in the vendor account - * associated with the specified project. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedLocation = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * $response = $bareMetalSolutionClient->listNetworkUsage($formattedLocation); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $location Required. Parent value (project and location). - * @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\BareMetalSolution\V2\ListNetworkUsageResponse - * - * @throws ApiException if the remote call fails - */ - public function listNetworkUsage($location, array $optionalArgs = []) - { - $request = new ListNetworkUsageRequest(); - $requestParamHeaders = []; - $request->setLocation($location); - $requestParamHeaders['location'] = $location; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'ListNetworkUsage', - ListNetworkUsageResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * List network in a given project and location. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listNetworks($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listNetworks($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListNetworksRequest. - * @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 - * 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 listNetworks($parent, array $optionalArgs = []) - { - $request = new ListNetworksRequest(); - $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( - 'ListNetworks', - $optionalArgs, - ListNetworksResponse::class, - $request - ); - } - - /** - * List NFS shares. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listNfsShares($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listNfsShares($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListNfsSharesRequest. - * @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 - * 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 listNfsShares($parent, array $optionalArgs = []) - { - $request = new ListNfsSharesRequest(); - $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( - 'ListNfsShares', - $optionalArgs, - ListNfsSharesResponse::class, - $request - ); - } - - /** - * Retrieves the list of OS images which are currently approved. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listOSImages($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listOSImages($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListProvisioningQuotasRequest. - * @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 listOSImages($parent, array $optionalArgs = []) - { - $request = new ListOSImagesRequest(); - $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( - 'ListOSImages', - $optionalArgs, - ListOSImagesResponse::class, - $request - ); - } - - /** - * List the budget details to provision resources on a given project. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listProvisioningQuotas($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listProvisioningQuotas($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListProvisioningQuotasRequest. - * @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 listProvisioningQuotas($parent, array $optionalArgs = []) - { - $request = new ListProvisioningQuotasRequest(); - $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( - 'ListProvisioningQuotas', - $optionalArgs, - ListProvisioningQuotasResponse::class, - $request - ); - } - - /** - * Lists the public SSH keys registered for the specified project. - * These SSH keys are used only for the interactive serial console feature. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listSSHKeys($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listSSHKeys($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent containing the SSH keys. - * Currently, the only valid value for the location is "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 RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 listSSHKeys($parent, array $optionalArgs = []) - { - $request = new ListSSHKeysRequest(); - $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( - 'ListSSHKeys', - $optionalArgs, - ListSSHKeysResponse::class, - $request - ); - } - - /** - * Retrieves the list of snapshots for the specified volume. - * Returns a response with an empty list of snapshots if called - * for a non-boot volume. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listVolumeSnapshots($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listVolumeSnapshots($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListVolumesRequest. - * @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 listVolumeSnapshots($parent, array $optionalArgs = []) - { - $request = new ListVolumeSnapshotsRequest(); - $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( - 'ListVolumeSnapshots', - $optionalArgs, - ListVolumeSnapshotsResponse::class, - $request - ); - } - - /** - * List storage volumes in a given project and location. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listVolumes($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listVolumes($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListVolumesRequest. - * @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 - * 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 listVolumes($parent, array $optionalArgs = []) - { - $request = new ListVolumesRequest(); - $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( - 'ListVolumes', - $optionalArgs, - ListVolumesResponse::class, - $request - ); - } - - /** - * RenameInstance sets a new name for an instance. - * Use with caution, previous names become immediately invalidated. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $newInstanceId = 'new_instance_id'; - * $response = $bareMetalSolutionClient->renameInstance($formattedName, $newInstanceId); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The `name` field is used to identify the instance. - * Format: projects/{project}/locations/{location}/instances/{instance} - * @param string $newInstanceId Required. The new `id` of the 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\Cloud\BareMetalSolution\V2\Instance - * - * @throws ApiException if the remote call fails - */ - public function renameInstance( - $name, - $newInstanceId, - array $optionalArgs = [] - ) { - $request = new RenameInstanceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setNewInstanceId($newInstanceId); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'RenameInstance', - Instance::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * RenameNetwork sets a new name for a network. - * Use with caution, previous names become immediately invalidated. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); - * $newNetworkId = 'new_network_id'; - * $response = $bareMetalSolutionClient->renameNetwork($formattedName, $newNetworkId); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The `name` field is used to identify the network. - * Format: projects/{project}/locations/{location}/networks/{network} - * @param string $newNetworkId Required. The new `id` of the network. - * @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\BareMetalSolution\V2\Network - * - * @throws ApiException if the remote call fails - */ - public function renameNetwork( - $name, - $newNetworkId, - array $optionalArgs = [] - ) { - $request = new RenameNetworkRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setNewNetworkId($newNetworkId); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'RenameNetwork', - Network::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * RenameNfsShare sets a new name for an nfsshare. - * Use with caution, previous names become immediately invalidated. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - * $newNfsshareId = 'new_nfsshare_id'; - * $response = $bareMetalSolutionClient->renameNfsShare($formattedName, $newNfsshareId); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The `name` field is used to identify the nfsshare. - * Format: projects/{project}/locations/{location}/nfsshares/{nfsshare} - * @param string $newNfsshareId Required. The new `id` of the nfsshare. - * @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\BareMetalSolution\V2\NfsShare - * - * @throws ApiException if the remote call fails - */ - public function renameNfsShare( - $name, - $newNfsshareId, - array $optionalArgs = [] - ) { - $request = new RenameNfsShareRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setNewNfsshareId($newNfsshareId); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'RenameNfsShare', - NfsShare::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * RenameVolume sets a new name for a volume. - * Use with caution, previous names become immediately invalidated. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - * $newVolumeId = 'new_volume_id'; - * $response = $bareMetalSolutionClient->renameVolume($formattedName, $newVolumeId); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. The `name` field is used to identify the volume. - * Format: projects/{project}/locations/{location}/volumes/{volume} - * @param string $newVolumeId Required. The new `id` of the volume. - * @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\BareMetalSolution\V2\Volume - * - * @throws ApiException if the remote call fails - */ - public function renameVolume($name, $newVolumeId, array $optionalArgs = []) - { - $request = new RenameVolumeRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setNewVolumeId($newVolumeId); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'RenameVolume', - Volume::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Perform an ungraceful, hard reset on a server. Equivalent to shutting the - * power off and then turning it back on. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $operationResponse = $bareMetalSolutionClient->resetInstance($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 = $bareMetalSolutionClient->resetInstance($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'resetInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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 resetInstance($name, array $optionalArgs = []) - { - $request = new ResetInstanceRequest(); - $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( - 'ResetInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Emergency Volume resize. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedVolume = $bareMetalSolutionClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - * $operationResponse = $bareMetalSolutionClient->resizeVolume($formattedVolume); - * $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 = $bareMetalSolutionClient->resizeVolume($formattedVolume); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'resizeVolume'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $volume Required. Volume to resize. - * @param array $optionalArgs { - * Optional. - * - * @type int $sizeGib - * New Volume size, in GiB. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 resizeVolume($volume, array $optionalArgs = []) - { - $request = new ResizeVolumeRequest(); - $requestParamHeaders = []; - $request->setVolume($volume); - $requestParamHeaders['volume'] = $volume; - if (isset($optionalArgs['sizeGib'])) { - $request->setSizeGib($optionalArgs['sizeGib']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'ResizeVolume', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Uses the specified snapshot to restore its parent volume. - * Returns INVALID_ARGUMENT if called for a non-boot volume. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedVolumeSnapshot = $bareMetalSolutionClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - * $operationResponse = $bareMetalSolutionClient->restoreVolumeSnapshot($formattedVolumeSnapshot); - * $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 = $bareMetalSolutionClient->restoreVolumeSnapshot($formattedVolumeSnapshot); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'restoreVolumeSnapshot'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $volumeSnapshot Required. Name of the snapshot which will be used to restore its parent - * volume. - * @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 restoreVolumeSnapshot( - $volumeSnapshot, - array $optionalArgs = [] - ) { - $request = new RestoreVolumeSnapshotRequest(); - $requestParamHeaders = []; - $request->setVolumeSnapshot($volumeSnapshot); - $requestParamHeaders['volume_snapshot'] = $volumeSnapshot; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'RestoreVolumeSnapshot', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Starts a server that was shutdown. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $operationResponse = $bareMetalSolutionClient->startInstance($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 = $bareMetalSolutionClient->startInstance($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'startInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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 startInstance($name, array $optionalArgs = []) - { - $request = new StartInstanceRequest(); - $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( - 'StartInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Stop a running server. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedName = $bareMetalSolutionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - * $operationResponse = $bareMetalSolutionClient->stopInstance($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 = $bareMetalSolutionClient->stopInstance($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'stopInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the 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 stopInstance($name, array $optionalArgs = []) - { - $request = new StopInstanceRequest(); - $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( - 'StopInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Submit a provisiong configuration for a given project. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $formattedParent = $bareMetalSolutionClient->locationName('[PROJECT]', '[LOCATION]'); - * $provisioningConfig = new ProvisioningConfig(); - * $response = $bareMetalSolutionClient->submitProvisioningConfig($formattedParent, $provisioningConfig); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent project and location containing the - * ProvisioningConfig. - * @param ProvisioningConfig $provisioningConfig Required. The ProvisioningConfig to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $email - * Optional. Email provided to send a confirmation with provisioning config - * 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\Cloud\BareMetalSolution\V2\SubmitProvisioningConfigResponse - * - * @throws ApiException if the remote call fails - */ - public function submitProvisioningConfig( - $parent, - $provisioningConfig, - array $optionalArgs = [] - ) { - $request = new SubmitProvisioningConfigRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setProvisioningConfig($provisioningConfig); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['email'])) { - $request->setEmail($optionalArgs['email']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'SubmitProvisioningConfig', - SubmitProvisioningConfigResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Update details of a single server. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $instance = new Instance(); - * $operationResponse = $bareMetalSolutionClient->updateInstance($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 = $bareMetalSolutionClient->updateInstance($instance); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->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 { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param Instance $instance Required. The server to update. - * - * The `name` field is used to identify the instance to update. - * Format: projects/{project}/locations/{location}/instances/{instance} - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to update. - * The currently supported fields are: - * `labels` - * `hyperthreading_enabled` - * `os_image` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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($instance, array $optionalArgs = []) - { - $request = new UpdateInstanceRequest(); - $requestParamHeaders = []; - $request->setInstance($instance); - $requestParamHeaders['instance.name'] = $instance->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->startOperationsCall( - 'UpdateInstance', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Update details of a single network. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $network = new Network(); - * $operationResponse = $bareMetalSolutionClient->updateNetwork($network); - * $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 = $bareMetalSolutionClient->updateNetwork($network); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'updateNetwork'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param Network $network Required. The network to update. - * - * The `name` field is used to identify the instance to update. - * Format: projects/{project}/locations/{location}/networks/{network} - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to update. - * The only currently supported fields are: - * `labels`, `reservations`, `vrf.vlan_attachments` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 updateNetwork($network, array $optionalArgs = []) - { - $request = new UpdateNetworkRequest(); - $requestParamHeaders = []; - $request->setNetwork($network); - $requestParamHeaders['network.name'] = $network->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->startOperationsCall( - 'UpdateNetwork', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Update details of a single NFS share. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $nfsShare = new NfsShare(); - * $operationResponse = $bareMetalSolutionClient->updateNfsShare($nfsShare); - * $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 = $bareMetalSolutionClient->updateNfsShare($nfsShare); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'updateNfsShare'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param NfsShare $nfsShare Required. The NFS share to update. - * - * The `name` field is used to identify the NFS share to update. - * Format: projects/{project}/locations/{location}/nfsShares/{nfs_share} - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to update. - * The only currently supported fields are: - * `labels` - * `allowed_clients` - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 updateNfsShare($nfsShare, array $optionalArgs = []) - { - $request = new UpdateNfsShareRequest(); - $requestParamHeaders = []; - $request->setNfsShare($nfsShare); - $requestParamHeaders['nfs_share.name'] = $nfsShare->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->startOperationsCall( - 'UpdateNfsShare', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Update existing ProvisioningConfig. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $provisioningConfig = new ProvisioningConfig(); - * $updateMask = new FieldMask(); - * $response = $bareMetalSolutionClient->updateProvisioningConfig($provisioningConfig, $updateMask); - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param ProvisioningConfig $provisioningConfig Required. The ProvisioningConfig to update. - * @param FieldMask $updateMask Required. The list of fields to update. - * @param array $optionalArgs { - * Optional. - * - * @type string $email - * Optional. Email provided to send a confirmation with provisioning config - * 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\Cloud\BareMetalSolution\V2\ProvisioningConfig - * - * @throws ApiException if the remote call fails - */ - public function updateProvisioningConfig( - $provisioningConfig, - $updateMask, - array $optionalArgs = [] - ) { - $request = new UpdateProvisioningConfigRequest(); - $requestParamHeaders = []; - $request->setProvisioningConfig($provisioningConfig); - $request->setUpdateMask($updateMask); - $requestParamHeaders[ - 'provisioning_config.name' - ] = $provisioningConfig->getName(); - if (isset($optionalArgs['email'])) { - $request->setEmail($optionalArgs['email']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'UpdateProvisioningConfig', - ProvisioningConfig::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Update details of a single storage volume. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $volume = new Volume(); - * $operationResponse = $bareMetalSolutionClient->updateVolume($volume); - * $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 = $bareMetalSolutionClient->updateVolume($volume); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bareMetalSolutionClient->resumeOperation($operationName, 'updateVolume'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bareMetalSolutionClient->close(); - * } - * ``` - * - * @param Volume $volume Required. The volume to update. - * - * The `name` field is used to identify the volume to update. - * Format: projects/{project}/locations/{location}/volumes/{volume} - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The list of fields to update. - * The only currently supported fields are: - * 'labels' - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 updateVolume($volume, array $optionalArgs = []) - { - $request = new UpdateVolumeRequest(); - $requestParamHeaders = []; - $request->setVolume($volume); - $requestParamHeaders['volume.name'] = $volume->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->startOperationsCall( - 'UpdateVolume', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * $response = $bareMetalSolutionClient->getLocation(); - * } finally { - * $bareMetalSolutionClient->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: - * ``` - * $bareMetalSolutionClient = new BareMetalSolutionClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $bareMetalSolutionClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bareMetalSolutionClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bareMetalSolutionClient->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/BareMetalSolution/src/V2/GetInstanceRequest.php b/BareMetalSolution/src/V2/GetInstanceRequest.php index d7e28a3e1c9..7a98047a6e5 100644 --- a/BareMetalSolution/src/V2/GetInstanceRequest.php +++ b/BareMetalSolution/src/V2/GetInstanceRequest.php @@ -20,7 +20,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. Name of the resource. Please see diff --git a/BareMetalSolution/src/V2/GetLunRequest.php b/BareMetalSolution/src/V2/GetLunRequest.php index 0a050a1b382..1b3818ef606 100644 --- a/BareMetalSolution/src/V2/GetLunRequest.php +++ b/BareMetalSolution/src/V2/GetLunRequest.php @@ -20,7 +20,7 @@ class GetLunRequest 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. Please see diff --git a/BareMetalSolution/src/V2/GetNetworkRequest.php b/BareMetalSolution/src/V2/GetNetworkRequest.php index f1ab274ee7b..b176df8e005 100644 --- a/BareMetalSolution/src/V2/GetNetworkRequest.php +++ b/BareMetalSolution/src/V2/GetNetworkRequest.php @@ -20,7 +20,7 @@ class GetNetworkRequest 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. Please see diff --git a/BareMetalSolution/src/V2/GetNfsShareRequest.php b/BareMetalSolution/src/V2/GetNfsShareRequest.php index 7699023eb89..95048183c5a 100644 --- a/BareMetalSolution/src/V2/GetNfsShareRequest.php +++ b/BareMetalSolution/src/V2/GetNfsShareRequest.php @@ -20,7 +20,7 @@ class GetNfsShareRequest 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. Please see diff --git a/BareMetalSolution/src/V2/GetProvisioningConfigRequest.php b/BareMetalSolution/src/V2/GetProvisioningConfigRequest.php index 3b2b1c2504c..79256f54066 100644 --- a/BareMetalSolution/src/V2/GetProvisioningConfigRequest.php +++ b/BareMetalSolution/src/V2/GetProvisioningConfigRequest.php @@ -20,7 +20,7 @@ class GetProvisioningConfigRequest 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 ProvisioningConfig. Please see diff --git a/BareMetalSolution/src/V2/GetVolumeRequest.php b/BareMetalSolution/src/V2/GetVolumeRequest.php index 50e02fdc1e8..16d3f54aa0b 100644 --- a/BareMetalSolution/src/V2/GetVolumeRequest.php +++ b/BareMetalSolution/src/V2/GetVolumeRequest.php @@ -20,7 +20,7 @@ class GetVolumeRequest 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. Please see diff --git a/BareMetalSolution/src/V2/GetVolumeSnapshotRequest.php b/BareMetalSolution/src/V2/GetVolumeSnapshotRequest.php index d4e4bb76129..49af9dcb744 100644 --- a/BareMetalSolution/src/V2/GetVolumeSnapshotRequest.php +++ b/BareMetalSolution/src/V2/GetVolumeSnapshotRequest.php @@ -20,7 +20,7 @@ class GetVolumeSnapshotRequest 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 snapshot. Please see diff --git a/BareMetalSolution/src/V2/Instance.php b/BareMetalSolution/src/V2/Instance.php index 30c3dd3bd9f..85e0e58624a 100644 --- a/BareMetalSolution/src/V2/Instance.php +++ b/BareMetalSolution/src/V2/Instance.php @@ -24,25 +24,25 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. An identifier for the `Instance`, generated by the backend. * * Generated from protobuf field string id = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $id = ''; + protected $id = ''; /** * Output only. Create a time stamp. * * 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. Update a time stamp. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Immutable. The server type. * [Available server @@ -50,20 +50,20 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string machine_type = 4 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $machine_type = ''; + protected $machine_type = ''; /** * Output only. The state of the server. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Instance.State state = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * True if you enable hyperthreading for the server, otherwise false. * The default value is false. * * Generated from protobuf field bool hyperthreading_enabled = 6; */ - private $hyperthreading_enabled = false; + protected $hyperthreading_enabled = false; /** * Labels as key value pairs. * @@ -95,13 +95,13 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool interactive_serial_console_enabled = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $interactive_serial_console_enabled = false; + protected $interactive_serial_console_enabled = false; /** * The OS image currently installed on the server. * * Generated from protobuf field string os_image = 12; */ - private $os_image = ''; + protected $os_image = ''; /** * Immutable. Pod name. * Pod is an independent part of infrastructure. @@ -110,7 +110,7 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string pod = 13 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $pod = ''; + protected $pod = ''; /** * Instance network template name. For eg, bondaa-bondaa, bondab-nic, etc. * Generally, the template name follows the syntax of @@ -118,7 +118,7 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network_template = 14 [(.google.api.resource_reference) = { */ - private $network_template = ''; + protected $network_template = ''; /** * List of logical interfaces for the instance. The number of logical * interfaces will be the same as number of hardware bond/nic on the chosen @@ -136,19 +136,19 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string login_info = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $login_info = ''; + protected $login_info = ''; /** * The workload profile for the instance. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.WorkloadProfile workload_profile = 18; */ - private $workload_profile = 0; + protected $workload_profile = 0; /** * Output only. The firmware version for the instance. * * Generated from protobuf field string firmware_version = 19 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $firmware_version = ''; + protected $firmware_version = ''; /** * Constructor. diff --git a/BareMetalSolution/src/V2/Instance/State.php b/BareMetalSolution/src/V2/Instance/State.php index 9a746059a3d..53118b79741 100644 --- a/BareMetalSolution/src/V2/Instance/State.php +++ b/BareMetalSolution/src/V2/Instance/State.php @@ -94,6 +94,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\BareMetalSolution\V2\Instance_State::class); diff --git a/BareMetalSolution/src/V2/InstanceConfig.php b/BareMetalSolution/src/V2/InstanceConfig.php index 1a8b16609d5..1e77b13cf9b 100644 --- a/BareMetalSolution/src/V2/InstanceConfig.php +++ b/BareMetalSolution/src/V2/InstanceConfig.php @@ -20,14 +20,14 @@ class InstanceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * A transient unique identifier to idenfity an instance within an * ProvisioningConfig request. * * Generated from protobuf field string id = 2; */ - private $id = ''; + protected $id = ''; /** * Instance type. * [Available @@ -35,13 +35,13 @@ class InstanceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string instance_type = 3; */ - private $instance_type = ''; + protected $instance_type = ''; /** * Whether the instance should be provisioned with Hyperthreading enabled. * * Generated from protobuf field bool hyperthreading = 4; */ - private $hyperthreading = false; + protected $hyperthreading = false; /** * OS image to initialize the instance. * [Available @@ -49,7 +49,7 @@ class InstanceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string os_image = 5; */ - private $os_image = ''; + protected $os_image = ''; /** * Client network address. Filled if InstanceConfig.multivlan_config is false. * @@ -71,26 +71,26 @@ class InstanceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string user_note = 8; */ - private $user_note = ''; + protected $user_note = ''; /** * If true networks can be from different projects of the same vendor account. * * Generated from protobuf field bool account_networks_enabled = 9; */ - private $account_networks_enabled = false; + protected $account_networks_enabled = false; /** * The type of network configuration on the instance. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.InstanceConfig.NetworkConfig network_config = 10; */ - private $network_config = 0; + protected $network_config = 0; /** * Server network template name. Filled if InstanceConfig.multivlan_config is * true. * * Generated from protobuf field string network_template = 11; */ - private $network_template = ''; + protected $network_template = ''; /** * List of logical interfaces for the instance. The number of logical * interfaces will be the same as number of hardware bond/nic on the chosen diff --git a/BareMetalSolution/src/V2/InstanceConfig/NetworkAddress.php b/BareMetalSolution/src/V2/InstanceConfig/NetworkAddress.php index 10e6abdd32b..5a2911c49c9 100644 --- a/BareMetalSolution/src/V2/InstanceConfig/NetworkAddress.php +++ b/BareMetalSolution/src/V2/InstanceConfig/NetworkAddress.php @@ -20,19 +20,19 @@ class NetworkAddress extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network_id = 1; */ - private $network_id = ''; + protected $network_id = ''; /** * IPv4 address to be assigned to the server. * * Generated from protobuf field string address = 2; */ - private $address = ''; + protected $address = ''; /** * Name of the existing network to use. * * Generated from protobuf field string existing_network_id = 3; */ - private $existing_network_id = ''; + protected $existing_network_id = ''; /** * Constructor. @@ -133,6 +133,4 @@ public function setExistingNetworkId($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(NetworkAddress::class, \Google\Cloud\BareMetalSolution\V2\InstanceConfig_NetworkAddress::class); diff --git a/BareMetalSolution/src/V2/InstanceConfig/NetworkConfig.php b/BareMetalSolution/src/V2/InstanceConfig/NetworkConfig.php index 30f7aa107cd..9639c2cfc87 100644 --- a/BareMetalSolution/src/V2/InstanceConfig/NetworkConfig.php +++ b/BareMetalSolution/src/V2/InstanceConfig/NetworkConfig.php @@ -60,6 +60,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(NetworkConfig::class, \Google\Cloud\BareMetalSolution\V2\InstanceConfig_NetworkConfig::class); diff --git a/BareMetalSolution/src/V2/InstanceQuota.php b/BareMetalSolution/src/V2/InstanceQuota.php index 4e6b4ae806d..21db20745c7 100644 --- a/BareMetalSolution/src/V2/InstanceQuota.php +++ b/BareMetalSolution/src/V2/InstanceQuota.php @@ -20,7 +20,7 @@ class InstanceQuota extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Instance type. * Deprecated: use gcp_service. @@ -34,20 +34,20 @@ class InstanceQuota extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string gcp_service = 5; */ - private $gcp_service = ''; + protected $gcp_service = ''; /** * Location where the quota applies. * * Generated from protobuf field string location = 3; */ - private $location = ''; + protected $location = ''; /** * Number of machines than can be created for the given location and * instance_type. * * Generated from protobuf field int32 available_machine_count = 4; */ - private $available_machine_count = 0; + protected $available_machine_count = 0; /** * Constructor. diff --git a/BareMetalSolution/src/V2/ListInstancesRequest.php b/BareMetalSolution/src/V2/ListInstancesRequest.php index 316a7a6ebd7..b8df2634e29 100644 --- a/BareMetalSolution/src/V2/ListInstancesRequest.php +++ b/BareMetalSolution/src/V2/ListInstancesRequest.php @@ -20,26 +20,26 @@ 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 = ''; /** * Requested page size. Server may return fewer items than requested. * If unspecified, the server will pick an appropriate default. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying a page of results from the server. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * List filter. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. Parent value for ListInstancesRequest. Please see diff --git a/BareMetalSolution/src/V2/ListInstancesResponse.php b/BareMetalSolution/src/V2/ListInstancesResponse.php index fb86e950663..7bc39330cde 100644 --- a/BareMetalSolution/src/V2/ListInstancesResponse.php +++ b/BareMetalSolution/src/V2/ListInstancesResponse.php @@ -26,7 +26,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/BareMetalSolution/src/V2/ListLunsRequest.php b/BareMetalSolution/src/V2/ListLunsRequest.php index ed41afcbe5e..46a9980f6ad 100644 --- a/BareMetalSolution/src/V2/ListLunsRequest.php +++ b/BareMetalSolution/src/V2/ListLunsRequest.php @@ -20,20 +20,20 @@ class ListLunsRequest 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 = ''; /** * Requested page size. The server might return fewer items than requested. * If unspecified, server will pick an appropriate default. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying a page of results from the server. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Parent value for ListLunsRequest. Please see diff --git a/BareMetalSolution/src/V2/ListLunsResponse.php b/BareMetalSolution/src/V2/ListLunsResponse.php index 024469de406..c15be31a1ac 100644 --- a/BareMetalSolution/src/V2/ListLunsResponse.php +++ b/BareMetalSolution/src/V2/ListLunsResponse.php @@ -26,7 +26,7 @@ class ListLunsResponse 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/BareMetalSolution/src/V2/ListNetworkUsageRequest.php b/BareMetalSolution/src/V2/ListNetworkUsageRequest.php index d74b673fd85..6c9b2360d47 100644 --- a/BareMetalSolution/src/V2/ListNetworkUsageRequest.php +++ b/BareMetalSolution/src/V2/ListNetworkUsageRequest.php @@ -20,7 +20,7 @@ class ListNetworkUsageRequest 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 = ''; /** * @param string $location Required. Parent value (project and location). Please see diff --git a/BareMetalSolution/src/V2/ListNetworksRequest.php b/BareMetalSolution/src/V2/ListNetworksRequest.php index 2e78fca0aff..83913f7e576 100644 --- a/BareMetalSolution/src/V2/ListNetworksRequest.php +++ b/BareMetalSolution/src/V2/ListNetworksRequest.php @@ -20,26 +20,26 @@ class ListNetworksRequest 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 = ''; /** * Requested page size. The server might return fewer items than requested. * If unspecified, server will pick an appropriate default. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying a page of results from the server. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * List filter. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. Parent value for ListNetworksRequest. Please see diff --git a/BareMetalSolution/src/V2/ListNetworksResponse.php b/BareMetalSolution/src/V2/ListNetworksResponse.php index 4257abcef30..864d99abb0e 100644 --- a/BareMetalSolution/src/V2/ListNetworksResponse.php +++ b/BareMetalSolution/src/V2/ListNetworksResponse.php @@ -26,7 +26,7 @@ class ListNetworksResponse 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/BareMetalSolution/src/V2/ListNfsSharesRequest.php b/BareMetalSolution/src/V2/ListNfsSharesRequest.php index 0c079132692..cc06bdec66a 100644 --- a/BareMetalSolution/src/V2/ListNfsSharesRequest.php +++ b/BareMetalSolution/src/V2/ListNfsSharesRequest.php @@ -20,26 +20,26 @@ class ListNfsSharesRequest 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 = ''; /** * Requested page size. The server might return fewer items than requested. * If unspecified, server will pick an appropriate default. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying a page of results from the server. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * List filter. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. Parent value for ListNfsSharesRequest. Please see diff --git a/BareMetalSolution/src/V2/ListNfsSharesResponse.php b/BareMetalSolution/src/V2/ListNfsSharesResponse.php index ebd1401d691..1af3d5e7c36 100644 --- a/BareMetalSolution/src/V2/ListNfsSharesResponse.php +++ b/BareMetalSolution/src/V2/ListNfsSharesResponse.php @@ -26,7 +26,7 @@ class ListNfsSharesResponse 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/BareMetalSolution/src/V2/ListOSImagesRequest.php b/BareMetalSolution/src/V2/ListOSImagesRequest.php index 317c99ab036..195fef9c922 100644 --- a/BareMetalSolution/src/V2/ListOSImagesRequest.php +++ b/BareMetalSolution/src/V2/ListOSImagesRequest.php @@ -20,7 +20,7 @@ class ListOSImagesRequest 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 = ''; /** * Requested page size. The server might return fewer items than requested. * If unspecified, server will pick an appropriate default. @@ -29,13 +29,13 @@ class ListOSImagesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying a page of results from the server. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Parent value for ListProvisioningQuotasRequest. Please see diff --git a/BareMetalSolution/src/V2/ListOSImagesResponse.php b/BareMetalSolution/src/V2/ListOSImagesResponse.php index 22c8b260b35..92783d7acf4 100644 --- a/BareMetalSolution/src/V2/ListOSImagesResponse.php +++ b/BareMetalSolution/src/V2/ListOSImagesResponse.php @@ -27,7 +27,7 @@ class ListOSImagesResponse 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/BareMetalSolution/src/V2/ListProvisioningQuotasRequest.php b/BareMetalSolution/src/V2/ListProvisioningQuotasRequest.php index 17885e394b7..ef418f0024c 100644 --- a/BareMetalSolution/src/V2/ListProvisioningQuotasRequest.php +++ b/BareMetalSolution/src/V2/ListProvisioningQuotasRequest.php @@ -20,7 +20,7 @@ class ListProvisioningQuotasRequest 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 = ''; /** * Requested page size. The server might return fewer items than requested. * If unspecified, server will pick an appropriate default. @@ -29,13 +29,13 @@ class ListProvisioningQuotasRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying a page of results from the server. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Parent value for ListProvisioningQuotasRequest. Please see diff --git a/BareMetalSolution/src/V2/ListProvisioningQuotasResponse.php b/BareMetalSolution/src/V2/ListProvisioningQuotasResponse.php index 3b120579fec..a470f638416 100644 --- a/BareMetalSolution/src/V2/ListProvisioningQuotasResponse.php +++ b/BareMetalSolution/src/V2/ListProvisioningQuotasResponse.php @@ -27,7 +27,7 @@ class ListProvisioningQuotasResponse 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/BareMetalSolution/src/V2/ListSSHKeysRequest.php b/BareMetalSolution/src/V2/ListSSHKeysRequest.php index 1c604226cdc..9903fca07ca 100644 --- a/BareMetalSolution/src/V2/ListSSHKeysRequest.php +++ b/BareMetalSolution/src/V2/ListSSHKeysRequest.php @@ -21,19 +21,19 @@ class ListSSHKeysRequest 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. The parent containing the SSH keys. diff --git a/BareMetalSolution/src/V2/ListSSHKeysResponse.php b/BareMetalSolution/src/V2/ListSSHKeysResponse.php index fe1771bf718..149698e30a9 100644 --- a/BareMetalSolution/src/V2/ListSSHKeysResponse.php +++ b/BareMetalSolution/src/V2/ListSSHKeysResponse.php @@ -27,7 +27,7 @@ class ListSSHKeysResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 90; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/BareMetalSolution/src/V2/ListVolumeSnapshotsRequest.php b/BareMetalSolution/src/V2/ListVolumeSnapshotsRequest.php index 88c8415016d..a867334d12c 100644 --- a/BareMetalSolution/src/V2/ListVolumeSnapshotsRequest.php +++ b/BareMetalSolution/src/V2/ListVolumeSnapshotsRequest.php @@ -20,20 +20,20 @@ class ListVolumeSnapshotsRequest 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 = ''; /** * Requested page size. The server might return fewer items than requested. * If unspecified, server will pick an appropriate default. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying a page of results from the server. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. Parent value for ListVolumesRequest. Please see diff --git a/BareMetalSolution/src/V2/ListVolumeSnapshotsResponse.php b/BareMetalSolution/src/V2/ListVolumeSnapshotsResponse.php index 01c24e52400..0905ddc4a4e 100644 --- a/BareMetalSolution/src/V2/ListVolumeSnapshotsResponse.php +++ b/BareMetalSolution/src/V2/ListVolumeSnapshotsResponse.php @@ -26,7 +26,7 @@ class ListVolumeSnapshotsResponse 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/BareMetalSolution/src/V2/ListVolumesRequest.php b/BareMetalSolution/src/V2/ListVolumesRequest.php index c253e4ea61b..cc4000006dc 100644 --- a/BareMetalSolution/src/V2/ListVolumesRequest.php +++ b/BareMetalSolution/src/V2/ListVolumesRequest.php @@ -20,26 +20,26 @@ class ListVolumesRequest 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 = ''; /** * Requested page size. The server might return fewer items than requested. * If unspecified, server will pick an appropriate default. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * A token identifying a page of results from the server. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * List filter. * * Generated from protobuf field string filter = 4; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. Parent value for ListVolumesRequest. Please see diff --git a/BareMetalSolution/src/V2/ListVolumesResponse.php b/BareMetalSolution/src/V2/ListVolumesResponse.php index 09bb6f78ac1..c6df4005c65 100644 --- a/BareMetalSolution/src/V2/ListVolumesResponse.php +++ b/BareMetalSolution/src/V2/ListVolumesResponse.php @@ -26,7 +26,7 @@ class ListVolumesResponse 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/BareMetalSolution/src/V2/LogicalInterface.php b/BareMetalSolution/src/V2/LogicalInterface.php index 9ca1407242c..b5f309a88f6 100644 --- a/BareMetalSolution/src/V2/LogicalInterface.php +++ b/BareMetalSolution/src/V2/LogicalInterface.php @@ -30,7 +30,7 @@ class LogicalInterface extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 2; */ - private $name = ''; + protected $name = ''; /** * The index of the logical interface mapping to the index of the hardware * bond or nic on the chosen network template. This field is deprecated. diff --git a/BareMetalSolution/src/V2/LogicalInterface/LogicalNetworkInterface.php b/BareMetalSolution/src/V2/LogicalInterface/LogicalNetworkInterface.php index 8e939c1d715..e49980aaad4 100644 --- a/BareMetalSolution/src/V2/LogicalInterface/LogicalNetworkInterface.php +++ b/BareMetalSolution/src/V2/LogicalInterface/LogicalNetworkInterface.php @@ -20,32 +20,32 @@ class LogicalNetworkInterface extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network = 1; */ - private $network = ''; + protected $network = ''; /** * IP address in the network * * Generated from protobuf field string ip_address = 2; */ - private $ip_address = ''; + protected $ip_address = ''; /** * Whether this interface is the default gateway for the instance. Only * one interface can be the default gateway for the instance. * * Generated from protobuf field bool default_gateway = 3; */ - private $default_gateway = false; + protected $default_gateway = false; /** * Type of network. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Network.Type network_type = 4; */ - private $network_type = 0; + protected $network_type = 0; /** * An identifier for the `Network`, generated by the backend. * * Generated from protobuf field string id = 5; */ - private $id = ''; + protected $id = ''; /** * Constructor. @@ -205,6 +205,4 @@ public function setId($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(LogicalNetworkInterface::class, \Google\Cloud\BareMetalSolution\V2\LogicalInterface_LogicalNetworkInterface::class); diff --git a/BareMetalSolution/src/V2/Lun.php b/BareMetalSolution/src/V2/Lun.php index 96a7b655ec5..d7d50ce6f8b 100644 --- a/BareMetalSolution/src/V2/Lun.php +++ b/BareMetalSolution/src/V2/Lun.php @@ -20,69 +20,69 @@ class Lun extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * An identifier for the LUN, generated by the backend. * * Generated from protobuf field string id = 10; */ - private $id = ''; + protected $id = ''; /** * The state of this storage volume. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Lun.State state = 2; */ - private $state = 0; + protected $state = 0; /** * The size of this LUN, in gigabytes. * * Generated from protobuf field int64 size_gb = 3; */ - private $size_gb = 0; + protected $size_gb = 0; /** * The LUN multiprotocol type ensures the characteristics of the LUN are * optimized for each operating system. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Lun.MultiprotocolType multiprotocol_type = 4; */ - private $multiprotocol_type = 0; + protected $multiprotocol_type = 0; /** * Display the storage volume for this LUN. * * Generated from protobuf field string storage_volume = 5 [(.google.api.resource_reference) = { */ - private $storage_volume = ''; + protected $storage_volume = ''; /** * Display if this LUN can be shared between multiple physical servers. * * Generated from protobuf field bool shareable = 6; */ - private $shareable = false; + protected $shareable = false; /** * Display if this LUN is a boot LUN. * * Generated from protobuf field bool boot_lun = 7; */ - private $boot_lun = false; + protected $boot_lun = false; /** * The storage type for this LUN. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Lun.StorageType storage_type = 8; */ - private $storage_type = 0; + protected $storage_type = 0; /** * The WWID for this LUN. * * Generated from protobuf field string wwid = 9; */ - private $wwid = ''; + protected $wwid = ''; /** * Output only. Time after which LUN will be fully deleted. * It is filled only for LUNs in COOL_OFF state. * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $expire_time = null; + protected $expire_time = null; /** * Output only. Instances this Lun is attached to. * diff --git a/BareMetalSolution/src/V2/Lun/MultiprotocolType.php b/BareMetalSolution/src/V2/Lun/MultiprotocolType.php index c9390ce0990..7dea5c802e7 100644 --- a/BareMetalSolution/src/V2/Lun/MultiprotocolType.php +++ b/BareMetalSolution/src/V2/Lun/MultiprotocolType.php @@ -52,6 +52,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(MultiprotocolType::class, \Google\Cloud\BareMetalSolution\V2\Lun_MultiprotocolType::class); diff --git a/BareMetalSolution/src/V2/Lun/State.php b/BareMetalSolution/src/V2/Lun/State.php index 0d226c38865..0c1ddd6b6fa 100644 --- a/BareMetalSolution/src/V2/Lun/State.php +++ b/BareMetalSolution/src/V2/Lun/State.php @@ -80,6 +80,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\BareMetalSolution\V2\Lun_State::class); diff --git a/BareMetalSolution/src/V2/Lun/StorageType.php b/BareMetalSolution/src/V2/Lun/StorageType.php index f6896f77e40..5a8af50fac1 100644 --- a/BareMetalSolution/src/V2/Lun/StorageType.php +++ b/BareMetalSolution/src/V2/Lun/StorageType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(StorageType::class, \Google\Cloud\BareMetalSolution\V2\Lun_StorageType::class); diff --git a/BareMetalSolution/src/V2/Network.php b/BareMetalSolution/src/V2/Network.php index 6c6a09b1bb0..22f2706398d 100644 --- a/BareMetalSolution/src/V2/Network.php +++ b/BareMetalSolution/src/V2/Network.php @@ -24,25 +24,25 @@ class Network extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * An identifier for the `Network`, generated by the backend. * * Generated from protobuf field string id = 10; */ - private $id = ''; + protected $id = ''; /** * The type of this network. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Network.Type type = 2; */ - private $type = 0; + protected $type = 0; /** * IP address configured. * * Generated from protobuf field string ip_address = 3; */ - private $ip_address = ''; + protected $ip_address = ''; /** * List of physical interfaces. * @@ -54,25 +54,25 @@ class Network extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Network.State state = 6; */ - private $state = 0; + protected $state = 0; /** * The vlan id of the Network. * * Generated from protobuf field string vlan_id = 7; */ - private $vlan_id = ''; + protected $vlan_id = ''; /** * The cidr of the Network. * * Generated from protobuf field string cidr = 8; */ - private $cidr = ''; + protected $cidr = ''; /** * The vrf for the Network. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VRF vrf = 9; */ - private $vrf = null; + protected $vrf = null; /** * Labels as key value pairs. * @@ -84,7 +84,7 @@ class Network extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string services_cidr = 12; */ - private $services_cidr = ''; + protected $services_cidr = ''; /** * List of IP address reservations in this network. * When updating this field, an error will be generated if a reservation @@ -98,7 +98,7 @@ class Network extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string pod = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $pod = ''; + protected $pod = ''; /** * Input only. List of mount points to attach the network to. * @@ -110,13 +110,13 @@ class Network extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool jumbo_frames_enabled = 16; */ - private $jumbo_frames_enabled = false; + protected $jumbo_frames_enabled = false; /** * Output only. Gateway ip address. * * Generated from protobuf field string gateway_ip = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $gateway_ip = ''; + protected $gateway_ip = ''; /** * Constructor. diff --git a/BareMetalSolution/src/V2/Network/State.php b/BareMetalSolution/src/V2/Network/State.php index 461eaa871ee..267120814c6 100644 --- a/BareMetalSolution/src/V2/Network/State.php +++ b/BareMetalSolution/src/V2/Network/State.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\BareMetalSolution\V2\Network_State::class); diff --git a/BareMetalSolution/src/V2/Network/Type.php b/BareMetalSolution/src/V2/Network/Type.php index 5b7a71e8a63..efa4ae0f4bf 100644 --- a/BareMetalSolution/src/V2/Network/Type.php +++ b/BareMetalSolution/src/V2/Network/Type.php @@ -63,6 +63,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Type::class, \Google\Cloud\BareMetalSolution\V2\Network_Type::class); diff --git a/BareMetalSolution/src/V2/NetworkAddressReservation.php b/BareMetalSolution/src/V2/NetworkAddressReservation.php index b50b05b6a0e..e9164232774 100644 --- a/BareMetalSolution/src/V2/NetworkAddressReservation.php +++ b/BareMetalSolution/src/V2/NetworkAddressReservation.php @@ -21,7 +21,7 @@ class NetworkAddressReservation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string start_address = 1; */ - private $start_address = ''; + protected $start_address = ''; /** * The last address of this reservation block, inclusive. I.e., for cases when * reservations are only single addresses, end_address and start_address will @@ -30,13 +30,13 @@ class NetworkAddressReservation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string end_address = 2; */ - private $end_address = ''; + protected $end_address = ''; /** * A note about this reservation, intended for human consumption. * * Generated from protobuf field string note = 3; */ - private $note = ''; + protected $note = ''; /** * Constructor. diff --git a/BareMetalSolution/src/V2/NetworkConfig.php b/BareMetalSolution/src/V2/NetworkConfig.php index 8ec1d936a35..85659bf9e24 100644 --- a/BareMetalSolution/src/V2/NetworkConfig.php +++ b/BareMetalSolution/src/V2/NetworkConfig.php @@ -20,26 +20,26 @@ class NetworkConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * A transient unique identifier to identify a volume within an * ProvisioningConfig request. * * Generated from protobuf field string id = 2; */ - private $id = ''; + protected $id = ''; /** * The type of this network, either Client or Private. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.NetworkConfig.Type type = 3; */ - private $type = 0; + protected $type = 0; /** * Interconnect bandwidth. Set only when type is CLIENT. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.NetworkConfig.Bandwidth bandwidth = 4; */ - private $bandwidth = 0; + protected $bandwidth = 0; /** * List of VLAN attachments. As of now there are always 2 attachments, but it * is going to change in the future (multi vlan). @@ -52,39 +52,39 @@ class NetworkConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cidr = 6; */ - private $cidr = ''; + protected $cidr = ''; /** * Service CIDR, if any. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.NetworkConfig.ServiceCidr service_cidr = 7; */ - private $service_cidr = 0; + protected $service_cidr = 0; /** * User note field, it can be used by customers to add additional information * for the BMS Ops team . * * Generated from protobuf field string user_note = 8; */ - private $user_note = ''; + protected $user_note = ''; /** * The GCP service of the network. Available gcp_service are in * https://cloud.google.com/bare-metal/docs/bms-planning. * * Generated from protobuf field string gcp_service = 9; */ - private $gcp_service = ''; + protected $gcp_service = ''; /** * Whether the VLAN attachment pair is located in the same project. * * Generated from protobuf field bool vlan_same_project = 10; */ - private $vlan_same_project = false; + protected $vlan_same_project = false; /** * The JumboFramesEnabled option for customer to set. * * Generated from protobuf field bool jumbo_frames_enabled = 11; */ - private $jumbo_frames_enabled = false; + protected $jumbo_frames_enabled = false; /** * Constructor. diff --git a/BareMetalSolution/src/V2/NetworkConfig/Bandwidth.php b/BareMetalSolution/src/V2/NetworkConfig/Bandwidth.php index b1f187f83d1..3315aa77fb9 100644 --- a/BareMetalSolution/src/V2/NetworkConfig/Bandwidth.php +++ b/BareMetalSolution/src/V2/NetworkConfig/Bandwidth.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Bandwidth::class, \Google\Cloud\BareMetalSolution\V2\NetworkConfig_Bandwidth::class); diff --git a/BareMetalSolution/src/V2/NetworkConfig/IntakeVlanAttachment.php b/BareMetalSolution/src/V2/NetworkConfig/IntakeVlanAttachment.php index b95620c8215..34f2d3cea3f 100644 --- a/BareMetalSolution/src/V2/NetworkConfig/IntakeVlanAttachment.php +++ b/BareMetalSolution/src/V2/NetworkConfig/IntakeVlanAttachment.php @@ -20,13 +20,13 @@ class IntakeVlanAttachment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * Attachment pairing key. * * Generated from protobuf field string pairing_key = 2; */ - private $pairing_key = ''; + protected $pairing_key = ''; /** * Constructor. @@ -99,6 +99,4 @@ public function setPairingKey($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(IntakeVlanAttachment::class, \Google\Cloud\BareMetalSolution\V2\NetworkConfig_IntakeVlanAttachment::class); diff --git a/BareMetalSolution/src/V2/NetworkConfig/ServiceCidr.php b/BareMetalSolution/src/V2/NetworkConfig/ServiceCidr.php index fef9ef5310e..e6eb5c7e324 100644 --- a/BareMetalSolution/src/V2/NetworkConfig/ServiceCidr.php +++ b/BareMetalSolution/src/V2/NetworkConfig/ServiceCidr.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(ServiceCidr::class, \Google\Cloud\BareMetalSolution\V2\NetworkConfig_ServiceCidr::class); diff --git a/BareMetalSolution/src/V2/NetworkConfig/Type.php b/BareMetalSolution/src/V2/NetworkConfig/Type.php index 7ad2e6357a0..ddfc098bb27 100644 --- a/BareMetalSolution/src/V2/NetworkConfig/Type.php +++ b/BareMetalSolution/src/V2/NetworkConfig/Type.php @@ -63,6 +63,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Type::class, \Google\Cloud\BareMetalSolution\V2\NetworkConfig_Type::class); diff --git a/BareMetalSolution/src/V2/NetworkMountPoint.php b/BareMetalSolution/src/V2/NetworkMountPoint.php index d1b0631ea9c..a147b3f1fa5 100644 --- a/BareMetalSolution/src/V2/NetworkMountPoint.php +++ b/BareMetalSolution/src/V2/NetworkMountPoint.php @@ -20,25 +20,25 @@ class NetworkMountPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string instance = 1 [(.google.api.resource_reference) = { */ - private $instance = ''; + protected $instance = ''; /** * Logical interface to detach from. * * Generated from protobuf field string logical_interface = 2; */ - private $logical_interface = ''; + protected $logical_interface = ''; /** * Network should be a default gateway. * * Generated from protobuf field bool default_gateway = 3; */ - private $default_gateway = false; + protected $default_gateway = false; /** * Ip address of the server. * * Generated from protobuf field string ip_address = 4; */ - private $ip_address = ''; + protected $ip_address = ''; /** * Constructor. diff --git a/BareMetalSolution/src/V2/NetworkUsage.php b/BareMetalSolution/src/V2/NetworkUsage.php index c80cc50efcc..789ec3aa94c 100644 --- a/BareMetalSolution/src/V2/NetworkUsage.php +++ b/BareMetalSolution/src/V2/NetworkUsage.php @@ -20,7 +20,7 @@ class NetworkUsage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Network network = 1; */ - private $network = null; + protected $network = null; /** * All used IP addresses in this network. * diff --git a/BareMetalSolution/src/V2/NfsShare.php b/BareMetalSolution/src/V2/NfsShare.php index 112aa21ffe3..2362d9d2676 100644 --- a/BareMetalSolution/src/V2/NfsShare.php +++ b/BareMetalSolution/src/V2/NfsShare.php @@ -20,34 +20,34 @@ class NfsShare extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * Output only. An identifier for the NFS share, generated by the backend. * This field will be deprecated in the future, use `id` instead. * * Generated from protobuf field string nfs_share_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $nfs_share_id = ''; + protected $nfs_share_id = ''; /** * Output only. An identifier for the NFS share, generated by the backend. * This is the same value as nfs_share_id and will replace it in the future. * * Generated from protobuf field string id = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $id = ''; + protected $id = ''; /** * Output only. The state of the NFS share. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.NfsShare.State state = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The underlying volume of the share. Created automatically * during provisioning. * * Generated from protobuf field string volume = 4 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $volume = ''; + protected $volume = ''; /** * List of allowed access points. * @@ -65,13 +65,13 @@ class NfsShare extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 requested_size_gib = 7; */ - private $requested_size_gib = 0; + protected $requested_size_gib = 0; /** * Immutable. The storage type of the underlying volume. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.NfsShare.StorageType storage_type = 9 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $storage_type = 0; + protected $storage_type = 0; /** * Constructor. diff --git a/BareMetalSolution/src/V2/NfsShare/AllowedClient.php b/BareMetalSolution/src/V2/NfsShare/AllowedClient.php index 0910a32dce3..5db25629336 100644 --- a/BareMetalSolution/src/V2/NfsShare/AllowedClient.php +++ b/BareMetalSolution/src/V2/NfsShare/AllowedClient.php @@ -20,38 +20,38 @@ class AllowedClient extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network = 1 [(.google.api.resource_reference) = { */ - private $network = ''; + protected $network = ''; /** * Output only. The IP address of the share on this network. Assigned * automatically during provisioning based on the network's services_cidr. * * Generated from protobuf field string share_ip = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $share_ip = ''; + protected $share_ip = ''; /** * The subnet of IP addresses permitted to access the share. * * Generated from protobuf field string allowed_clients_cidr = 3; */ - private $allowed_clients_cidr = ''; + protected $allowed_clients_cidr = ''; /** * Mount permissions. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.NfsShare.MountPermissions mount_permissions = 4; */ - private $mount_permissions = 0; + protected $mount_permissions = 0; /** * Allow dev flag. Which controls whether to allow creation of devices. * * Generated from protobuf field bool allow_dev = 5; */ - private $allow_dev = false; + protected $allow_dev = false; /** * Allow the setuid flag. * * Generated from protobuf field bool allow_suid = 6; */ - private $allow_suid = false; + protected $allow_suid = false; /** * Disable root squashing, which is a feature of NFS. * Root squash is a special mapping of the remote superuser (root) identity @@ -59,7 +59,7 @@ class AllowedClient extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool no_root_squash = 7; */ - private $no_root_squash = false; + protected $no_root_squash = false; /** * Output only. The path to access NFS, in format shareIP:/InstanceID * InstanceID is the generated ID instead of customer provided name. @@ -67,7 +67,7 @@ class AllowedClient extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string nfs_path = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $nfs_path = ''; + protected $nfs_path = ''; /** * Constructor. @@ -323,6 +323,4 @@ public function setNfsPath($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(AllowedClient::class, \Google\Cloud\BareMetalSolution\V2\NfsShare_AllowedClient::class); diff --git a/BareMetalSolution/src/V2/NfsShare/MountPermissions.php b/BareMetalSolution/src/V2/NfsShare/MountPermissions.php index dadf339aea7..4bbb225fd46 100644 --- a/BareMetalSolution/src/V2/NfsShare/MountPermissions.php +++ b/BareMetalSolution/src/V2/NfsShare/MountPermissions.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(MountPermissions::class, \Google\Cloud\BareMetalSolution\V2\NfsShare_MountPermissions::class); diff --git a/BareMetalSolution/src/V2/NfsShare/State.php b/BareMetalSolution/src/V2/NfsShare/State.php index 33726a32ec7..a038d9fd6c8 100644 --- a/BareMetalSolution/src/V2/NfsShare/State.php +++ b/BareMetalSolution/src/V2/NfsShare/State.php @@ -73,6 +73,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\BareMetalSolution\V2\NfsShare_State::class); diff --git a/BareMetalSolution/src/V2/NfsShare/StorageType.php b/BareMetalSolution/src/V2/NfsShare/StorageType.php index 3d002a9bee9..177f64ab6b3 100644 --- a/BareMetalSolution/src/V2/NfsShare/StorageType.php +++ b/BareMetalSolution/src/V2/NfsShare/StorageType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(StorageType::class, \Google\Cloud\BareMetalSolution\V2\NfsShare_StorageType::class); diff --git a/BareMetalSolution/src/V2/OSImage.php b/BareMetalSolution/src/V2/OSImage.php index b3b60d8cf8e..46442969f67 100644 --- a/BareMetalSolution/src/V2/OSImage.php +++ b/BareMetalSolution/src/V2/OSImage.php @@ -20,19 +20,19 @@ class OSImage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * OS Image code. * * Generated from protobuf field string code = 2; */ - private $code = ''; + protected $code = ''; /** * OS Image description. * * Generated from protobuf field string description = 3; */ - private $description = ''; + protected $description = ''; /** * Instance types this image is applicable to. * [Available diff --git a/BareMetalSolution/src/V2/OperationMetadata.php b/BareMetalSolution/src/V2/OperationMetadata.php index 87d27c8d028..e6061c8bf25 100644 --- a/BareMetalSolution/src/V2/OperationMetadata.php +++ b/BareMetalSolution/src/V2/OperationMetadata.php @@ -20,31 +20,31 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.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 action 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 requested the cancellation * of the operation. Operations that have been successfully 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 with 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/BareMetalSolution/src/V2/ProvisioningConfig.php b/BareMetalSolution/src/V2/ProvisioningConfig.php index 483d8d35ed3..9aedd8c65bf 100644 --- a/BareMetalSolution/src/V2/ProvisioningConfig.php +++ b/BareMetalSolution/src/V2/ProvisioningConfig.php @@ -21,7 +21,7 @@ class ProvisioningConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Instances to be created. * @@ -45,14 +45,14 @@ class ProvisioningConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string ticket_id = 5; */ - private $ticket_id = ''; + protected $ticket_id = ''; /** * A service account to enable customers to access instance credentials upon * handover. * * Generated from protobuf field string handover_service_account = 6; */ - private $handover_service_account = ''; + protected $handover_service_account = ''; /** * Email provided to send a confirmation with provisioning config to. * Deprecated in favour of email field in request messages. @@ -66,44 +66,44 @@ class ProvisioningConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.ProvisioningConfig.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Optional. Location name of this ProvisioningConfig. * It is optional only for Intake UI transition period. * * Generated from protobuf field string location = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - private $location = ''; + protected $location = ''; /** * Output only. Last update timestamp. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Output only. URI to Cloud Console UI view of this provisioning config. * * Generated from protobuf field string cloud_console_uri = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $cloud_console_uri = ''; + protected $cloud_console_uri = ''; /** * If true, VPC SC is enabled for the cluster. * * Generated from protobuf field bool vpc_sc_enabled = 12; */ - private $vpc_sc_enabled = false; + protected $vpc_sc_enabled = false; /** * Optional status messages associated with the FAILED state. * * Generated from protobuf field string status_message = 13; */ - private $status_message = ''; + protected $status_message = ''; /** * Optional. The user-defined identifier of the provisioning config. * * Generated from protobuf field string custom_id = 14 [(.google.api.field_behavior) = OPTIONAL]; */ - private $custom_id = ''; + protected $custom_id = ''; /** * Constructor. diff --git a/BareMetalSolution/src/V2/ProvisioningConfig/State.php b/BareMetalSolution/src/V2/ProvisioningConfig/State.php index 227318e8082..425c5c0ba44 100644 --- a/BareMetalSolution/src/V2/ProvisioningConfig/State.php +++ b/BareMetalSolution/src/V2/ProvisioningConfig/State.php @@ -97,6 +97,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\BareMetalSolution\V2\ProvisioningConfig_State::class); diff --git a/BareMetalSolution/src/V2/ProvisioningQuota.php b/BareMetalSolution/src/V2/ProvisioningQuota.php index 37505221f62..e93a6c0f70a 100644 --- a/BareMetalSolution/src/V2/ProvisioningQuota.php +++ b/BareMetalSolution/src/V2/ProvisioningQuota.php @@ -20,31 +20,31 @@ class ProvisioningQuota extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * The asset type of this provisioning quota. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.ProvisioningQuota.AssetType asset_type = 2; */ - private $asset_type = 0; + protected $asset_type = 0; /** * The gcp service of the provisioning quota. * * Generated from protobuf field string gcp_service = 3; */ - private $gcp_service = ''; + protected $gcp_service = ''; /** * The specific location of the provisioining quota. * * Generated from protobuf field string location = 4; */ - private $location = ''; + protected $location = ''; /** * The available count of the provisioning quota. * * Generated from protobuf field int32 available_count = 5; */ - private $available_count = 0; + protected $available_count = 0; protected $quota; protected $availability; diff --git a/BareMetalSolution/src/V2/ProvisioningQuota/AssetType.php b/BareMetalSolution/src/V2/ProvisioningQuota/AssetType.php index ed4619ec1e6..56c474fee88 100644 --- a/BareMetalSolution/src/V2/ProvisioningQuota/AssetType.php +++ b/BareMetalSolution/src/V2/ProvisioningQuota/AssetType.php @@ -66,6 +66,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(AssetType::class, \Google\Cloud\BareMetalSolution\V2\ProvisioningQuota_AssetType::class); diff --git a/BareMetalSolution/src/V2/RenameInstanceRequest.php b/BareMetalSolution/src/V2/RenameInstanceRequest.php index da595a79bef..168cff7da42 100644 --- a/BareMetalSolution/src/V2/RenameInstanceRequest.php +++ b/BareMetalSolution/src/V2/RenameInstanceRequest.php @@ -21,13 +21,13 @@ class RenameInstanceRequest 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 the instance. * * Generated from protobuf field string new_instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_instance_id = ''; + protected $new_instance_id = ''; /** * @param string $name Required. The `name` field is used to identify the instance. diff --git a/BareMetalSolution/src/V2/RenameNetworkRequest.php b/BareMetalSolution/src/V2/RenameNetworkRequest.php index e8e27c9d6aa..ee6b7a98640 100644 --- a/BareMetalSolution/src/V2/RenameNetworkRequest.php +++ b/BareMetalSolution/src/V2/RenameNetworkRequest.php @@ -21,13 +21,13 @@ class RenameNetworkRequest 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 the network. * * Generated from protobuf field string new_network_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_network_id = ''; + protected $new_network_id = ''; /** * @param string $name Required. The `name` field is used to identify the network. diff --git a/BareMetalSolution/src/V2/RenameNfsShareRequest.php b/BareMetalSolution/src/V2/RenameNfsShareRequest.php index d77e926e990..32c07a6d621 100644 --- a/BareMetalSolution/src/V2/RenameNfsShareRequest.php +++ b/BareMetalSolution/src/V2/RenameNfsShareRequest.php @@ -21,13 +21,13 @@ class RenameNfsShareRequest 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 the nfsshare. * * Generated from protobuf field string new_nfsshare_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_nfsshare_id = ''; + protected $new_nfsshare_id = ''; /** * @param string $name Required. The `name` field is used to identify the nfsshare. diff --git a/BareMetalSolution/src/V2/RenameVolumeRequest.php b/BareMetalSolution/src/V2/RenameVolumeRequest.php index d1f5d3eb576..c74a86a8d25 100644 --- a/BareMetalSolution/src/V2/RenameVolumeRequest.php +++ b/BareMetalSolution/src/V2/RenameVolumeRequest.php @@ -21,13 +21,13 @@ class RenameVolumeRequest 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 the volume. * * Generated from protobuf field string new_volume_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $new_volume_id = ''; + protected $new_volume_id = ''; /** * @param string $name Required. The `name` field is used to identify the volume. diff --git a/BareMetalSolution/src/V2/ResetInstanceRequest.php b/BareMetalSolution/src/V2/ResetInstanceRequest.php index f9f90000b75..fad5d277038 100644 --- a/BareMetalSolution/src/V2/ResetInstanceRequest.php +++ b/BareMetalSolution/src/V2/ResetInstanceRequest.php @@ -20,7 +20,7 @@ class ResetInstanceRequest 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. Please see diff --git a/BareMetalSolution/src/V2/ResizeVolumeRequest.php b/BareMetalSolution/src/V2/ResizeVolumeRequest.php index 46fe33196be..7cb2d386c50 100644 --- a/BareMetalSolution/src/V2/ResizeVolumeRequest.php +++ b/BareMetalSolution/src/V2/ResizeVolumeRequest.php @@ -20,13 +20,13 @@ class ResizeVolumeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string volume = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $volume = ''; + protected $volume = ''; /** * New Volume size, in GiB. * * Generated from protobuf field int64 size_gib = 2; */ - private $size_gib = 0; + protected $size_gib = 0; /** * @param string $volume Required. Volume to resize. Please see diff --git a/BareMetalSolution/src/V2/RestoreVolumeSnapshotRequest.php b/BareMetalSolution/src/V2/RestoreVolumeSnapshotRequest.php index 20ecfc78426..2f0b9e7c7ff 100644 --- a/BareMetalSolution/src/V2/RestoreVolumeSnapshotRequest.php +++ b/BareMetalSolution/src/V2/RestoreVolumeSnapshotRequest.php @@ -21,7 +21,7 @@ class RestoreVolumeSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string volume_snapshot = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $volume_snapshot = ''; + protected $volume_snapshot = ''; /** * @param string $volumeSnapshot Required. Name of the snapshot which will be used to restore its parent diff --git a/BareMetalSolution/src/V2/SSHKey.php b/BareMetalSolution/src/V2/SSHKey.php index d23807d9a6f..f219549b1c9 100644 --- a/BareMetalSolution/src/V2/SSHKey.php +++ b/BareMetalSolution/src/V2/SSHKey.php @@ -21,13 +21,13 @@ class SSHKey extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * The public SSH key. This must be in OpenSSH .authorized_keys format. * * Generated from protobuf field string public_key = 2; */ - private $public_key = ''; + protected $public_key = ''; /** * Constructor. diff --git a/BareMetalSolution/src/V2/ServerNetworkTemplate.php b/BareMetalSolution/src/V2/ServerNetworkTemplate.php index 3af9aaa9294..9374bd6b1e6 100644 --- a/BareMetalSolution/src/V2/ServerNetworkTemplate.php +++ b/BareMetalSolution/src/V2/ServerNetworkTemplate.php @@ -24,7 +24,7 @@ class ServerNetworkTemplate extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Instance types this template is applicable to. * diff --git a/BareMetalSolution/src/V2/ServerNetworkTemplate/LogicalInterface.php b/BareMetalSolution/src/V2/ServerNetworkTemplate/LogicalInterface.php index 08147fc85b3..00b8a008414 100644 --- a/BareMetalSolution/src/V2/ServerNetworkTemplate/LogicalInterface.php +++ b/BareMetalSolution/src/V2/ServerNetworkTemplate/LogicalInterface.php @@ -24,19 +24,19 @@ class LogicalInterface extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Interface type. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.ServerNetworkTemplate.LogicalInterface.InterfaceType type = 2; */ - private $type = 0; + protected $type = 0; /** * If true, interface must have network connected. * * Generated from protobuf field bool required = 3; */ - private $required = false; + protected $required = false; /** * Constructor. @@ -149,6 +149,4 @@ public function setRequired($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(LogicalInterface::class, \Google\Cloud\BareMetalSolution\V2\ServerNetworkTemplate_LogicalInterface::class); diff --git a/BareMetalSolution/src/V2/ServerNetworkTemplate/LogicalInterface/InterfaceType.php b/BareMetalSolution/src/V2/ServerNetworkTemplate/LogicalInterface/InterfaceType.php index 45e03a1e772..c118601fbd7 100644 --- a/BareMetalSolution/src/V2/ServerNetworkTemplate/LogicalInterface/InterfaceType.php +++ b/BareMetalSolution/src/V2/ServerNetworkTemplate/LogicalInterface/InterfaceType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(InterfaceType::class, \Google\Cloud\BareMetalSolution\V2\ServerNetworkTemplate_LogicalInterface_InterfaceType::class); diff --git a/BareMetalSolution/src/V2/SnapshotSchedulePolicy/Schedule.php b/BareMetalSolution/src/V2/SnapshotSchedulePolicy/Schedule.php deleted file mode 100644 index b7e773e3981..00000000000 --- a/BareMetalSolution/src/V2/SnapshotSchedulePolicy/Schedule.php +++ /dev/null @@ -1,140 +0,0 @@ -google.cloud.baremetalsolution.v2.SnapshotSchedulePolicy.Schedule - */ -class Schedule extends \Google\Protobuf\Internal\Message -{ - /** - * A crontab-like specification that the schedule uses to take - * snapshots. - * - * Generated from protobuf field string crontab_spec = 1; - */ - private $crontab_spec = ''; - /** - * The maximum number of snapshots to retain in this schedule. - * - * Generated from protobuf field int32 retention_count = 2; - */ - private $retention_count = 0; - /** - * A list of snapshot names created in this schedule. - * - * Generated from protobuf field string prefix = 3; - */ - private $prefix = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $crontab_spec - * A crontab-like specification that the schedule uses to take - * snapshots. - * @type int $retention_count - * The maximum number of snapshots to retain in this schedule. - * @type string $prefix - * A list of snapshot names created in this schedule. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Cloud\Baremetalsolution\V2\Baremetalsolution::initOnce(); - parent::__construct($data); - } - - /** - * A crontab-like specification that the schedule uses to take - * snapshots. - * - * Generated from protobuf field string crontab_spec = 1; - * @return string - */ - public function getCrontabSpec() - { - return $this->crontab_spec; - } - - /** - * A crontab-like specification that the schedule uses to take - * snapshots. - * - * Generated from protobuf field string crontab_spec = 1; - * @param string $var - * @return $this - */ - public function setCrontabSpec($var) - { - GPBUtil::checkString($var, True); - $this->crontab_spec = $var; - - return $this; - } - - /** - * The maximum number of snapshots to retain in this schedule. - * - * Generated from protobuf field int32 retention_count = 2; - * @return int - */ - public function getRetentionCount() - { - return $this->retention_count; - } - - /** - * The maximum number of snapshots to retain in this schedule. - * - * Generated from protobuf field int32 retention_count = 2; - * @param int $var - * @return $this - */ - public function setRetentionCount($var) - { - GPBUtil::checkInt32($var); - $this->retention_count = $var; - - return $this; - } - - /** - * A list of snapshot names created in this schedule. - * - * Generated from protobuf field string prefix = 3; - * @return string - */ - public function getPrefix() - { - return $this->prefix; - } - - /** - * A list of snapshot names created in this schedule. - * - * Generated from protobuf field string prefix = 3; - * @param string $var - * @return $this - */ - public function setPrefix($var) - { - GPBUtil::checkString($var, True); - $this->prefix = $var; - - return $this; - } - -} - - diff --git a/BareMetalSolution/src/V2/StartInstanceRequest.php b/BareMetalSolution/src/V2/StartInstanceRequest.php index ac899e87e1d..11a471958fa 100644 --- a/BareMetalSolution/src/V2/StartInstanceRequest.php +++ b/BareMetalSolution/src/V2/StartInstanceRequest.php @@ -20,7 +20,7 @@ class StartInstanceRequest 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. Please see diff --git a/BareMetalSolution/src/V2/StopInstanceRequest.php b/BareMetalSolution/src/V2/StopInstanceRequest.php index 93a98e71ac4..c838273d128 100644 --- a/BareMetalSolution/src/V2/StopInstanceRequest.php +++ b/BareMetalSolution/src/V2/StopInstanceRequest.php @@ -20,7 +20,7 @@ class StopInstanceRequest 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. Please see diff --git a/BareMetalSolution/src/V2/SubmitProvisioningConfigRequest.php b/BareMetalSolution/src/V2/SubmitProvisioningConfigRequest.php index 74598749eaa..2def6642afc 100644 --- a/BareMetalSolution/src/V2/SubmitProvisioningConfigRequest.php +++ b/BareMetalSolution/src/V2/SubmitProvisioningConfigRequest.php @@ -21,20 +21,20 @@ class SubmitProvisioningConfigRequest 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 ProvisioningConfig to create. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.ProvisioningConfig provisioning_config = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $provisioning_config = null; + protected $provisioning_config = null; /** * Optional. Email provided to send a confirmation with provisioning config * to. * * Generated from protobuf field string email = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $email = ''; + protected $email = ''; /** * @param string $parent Required. The parent project and location containing the diff --git a/BareMetalSolution/src/V2/SubmitProvisioningConfigResponse.php b/BareMetalSolution/src/V2/SubmitProvisioningConfigResponse.php index 89c70c34474..35a3c9651f5 100644 --- a/BareMetalSolution/src/V2/SubmitProvisioningConfigResponse.php +++ b/BareMetalSolution/src/V2/SubmitProvisioningConfigResponse.php @@ -20,7 +20,7 @@ class SubmitProvisioningConfigResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.ProvisioningConfig provisioning_config = 1; */ - private $provisioning_config = null; + protected $provisioning_config = null; /** * Constructor. diff --git a/BareMetalSolution/src/V2/UpdateInstanceRequest.php b/BareMetalSolution/src/V2/UpdateInstanceRequest.php index 678f9a38bd8..60546eef353 100644 --- a/BareMetalSolution/src/V2/UpdateInstanceRequest.php +++ b/BareMetalSolution/src/V2/UpdateInstanceRequest.php @@ -22,7 +22,7 @@ class UpdateInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $instance = null; + protected $instance = null; /** * The list of fields to update. * The currently supported fields are: @@ -32,7 +32,7 @@ class UpdateInstanceRequest 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\BareMetalSolution\V2\Instance $instance Required. The server to update. diff --git a/BareMetalSolution/src/V2/UpdateNetworkRequest.php b/BareMetalSolution/src/V2/UpdateNetworkRequest.php index e6694329daf..87eeb260f62 100644 --- a/BareMetalSolution/src/V2/UpdateNetworkRequest.php +++ b/BareMetalSolution/src/V2/UpdateNetworkRequest.php @@ -22,7 +22,7 @@ class UpdateNetworkRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Network network = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $network = null; + protected $network = null; /** * The list of fields to update. * The only currently supported fields are: @@ -30,7 +30,7 @@ class UpdateNetworkRequest 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\BareMetalSolution\V2\Network $network Required. The network to update. diff --git a/BareMetalSolution/src/V2/UpdateNfsShareRequest.php b/BareMetalSolution/src/V2/UpdateNfsShareRequest.php index e0162106c99..63a98b61ec2 100644 --- a/BareMetalSolution/src/V2/UpdateNfsShareRequest.php +++ b/BareMetalSolution/src/V2/UpdateNfsShareRequest.php @@ -22,7 +22,7 @@ class UpdateNfsShareRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.NfsShare nfs_share = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $nfs_share = null; + protected $nfs_share = null; /** * The list of fields to update. * The only currently supported fields are: @@ -31,7 +31,7 @@ class UpdateNfsShareRequest 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\BareMetalSolution\V2\NfsShare $nfsShare Required. The NFS share to update. diff --git a/BareMetalSolution/src/V2/UpdateProvisioningConfigRequest.php b/BareMetalSolution/src/V2/UpdateProvisioningConfigRequest.php index cb7831fab0c..d9f98f9de39 100644 --- a/BareMetalSolution/src/V2/UpdateProvisioningConfigRequest.php +++ b/BareMetalSolution/src/V2/UpdateProvisioningConfigRequest.php @@ -20,20 +20,20 @@ class UpdateProvisioningConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.ProvisioningConfig provisioning_config = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $provisioning_config = null; + protected $provisioning_config = null; /** * Required. The list of fields to update. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Optional. Email provided to send a confirmation with provisioning config * to. * * Generated from protobuf field string email = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $email = ''; + protected $email = ''; /** * @param \Google\Cloud\BareMetalSolution\V2\ProvisioningConfig $provisioningConfig Required. The ProvisioningConfig to update. diff --git a/BareMetalSolution/src/V2/UpdateVolumeRequest.php b/BareMetalSolution/src/V2/UpdateVolumeRequest.php index b311a0f77e3..d4fa695d3f0 100644 --- a/BareMetalSolution/src/V2/UpdateVolumeRequest.php +++ b/BareMetalSolution/src/V2/UpdateVolumeRequest.php @@ -22,7 +22,7 @@ class UpdateVolumeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Volume volume = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $volume = null; + protected $volume = null; /** * The list of fields to update. * The only currently supported fields are: @@ -30,7 +30,7 @@ class UpdateVolumeRequest 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\BareMetalSolution\V2\Volume $volume Required. The volume to update. diff --git a/BareMetalSolution/src/V2/VRF.php b/BareMetalSolution/src/V2/VRF.php index 52323fa822e..217c29708d7 100644 --- a/BareMetalSolution/src/V2/VRF.php +++ b/BareMetalSolution/src/V2/VRF.php @@ -20,13 +20,13 @@ class VRF extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The possible state of VRF. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VRF.State state = 5; */ - private $state = 0; + protected $state = 0; /** * The QOS policy applied to this VRF. * The value is only meaningful when all the vlan attachments have the same @@ -35,7 +35,7 @@ class VRF extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VRF.QosPolicy qos_policy = 6; */ - private $qos_policy = null; + protected $qos_policy = null; /** * The list of VLAN attachments for the VRF. * diff --git a/BareMetalSolution/src/V2/VRF/QosPolicy.php b/BareMetalSolution/src/V2/VRF/QosPolicy.php index 85b2b187bc8..d783f228d2f 100644 --- a/BareMetalSolution/src/V2/VRF/QosPolicy.php +++ b/BareMetalSolution/src/V2/VRF/QosPolicy.php @@ -20,7 +20,7 @@ class QosPolicy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double bandwidth_gbps = 1; */ - private $bandwidth_gbps = 0.0; + protected $bandwidth_gbps = 0.0; /** * Constructor. @@ -65,6 +65,4 @@ public function setBandwidthGbps($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(QosPolicy::class, \Google\Cloud\BareMetalSolution\V2\VRF_QosPolicy::class); diff --git a/BareMetalSolution/src/V2/VRF/State.php b/BareMetalSolution/src/V2/VRF/State.php index 77a76204cec..366e5a11663 100644 --- a/BareMetalSolution/src/V2/VRF/State.php +++ b/BareMetalSolution/src/V2/VRF/State.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\BareMetalSolution\V2\VRF_State::class); diff --git a/BareMetalSolution/src/V2/VRF/VlanAttachment.php b/BareMetalSolution/src/V2/VRF/VlanAttachment.php index f24505853a7..bc22afbed08 100644 --- a/BareMetalSolution/src/V2/VRF/VlanAttachment.php +++ b/BareMetalSolution/src/V2/VRF/VlanAttachment.php @@ -20,45 +20,45 @@ class VlanAttachment extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 peer_vlan_id = 1; */ - private $peer_vlan_id = 0; + protected $peer_vlan_id = 0; /** * The peer IP of the attachment. * * Generated from protobuf field string peer_ip = 2; */ - private $peer_ip = ''; + protected $peer_ip = ''; /** * The router IP of the attachment. * * Generated from protobuf field string router_ip = 3; */ - private $router_ip = ''; + protected $router_ip = ''; /** * Input only. Pairing key. * * Generated from protobuf field string pairing_key = 4 [(.google.api.field_behavior) = INPUT_ONLY]; */ - private $pairing_key = ''; + protected $pairing_key = ''; /** * The QOS policy applied to this VLAN attachment. * This value should be preferred to using qos at vrf level. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VRF.QosPolicy qos_policy = 5; */ - private $qos_policy = null; + protected $qos_policy = null; /** * Immutable. The identifier of the attachment within vrf. * * Generated from protobuf field string id = 6 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $id = ''; + protected $id = ''; /** * Optional. The name of the vlan attachment within vrf. This is of the form * projects/{project_number}/regions/{region}/interconnectAttachments/{interconnect_attachment} * * Generated from protobuf field string interconnect_attachment = 7 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $interconnect_attachment = ''; + protected $interconnect_attachment = ''; /** * Constructor. @@ -287,6 +287,4 @@ public function setInterconnectAttachment($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(VlanAttachment::class, \Google\Cloud\BareMetalSolution\V2\VRF_VlanAttachment::class); diff --git a/BareMetalSolution/src/V2/Volume.php b/BareMetalSolution/src/V2/Volume.php index 578580fe9c9..47b35834e0a 100644 --- a/BareMetalSolution/src/V2/Volume.php +++ b/BareMetalSolution/src/V2/Volume.php @@ -24,37 +24,37 @@ class Volume extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * An identifier for the `Volume`, generated by the backend. * * Generated from protobuf field string id = 11; */ - private $id = ''; + protected $id = ''; /** * The storage type for this volume. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Volume.StorageType storage_type = 2; */ - private $storage_type = 0; + protected $storage_type = 0; /** * The state of this storage volume. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Volume.State state = 3; */ - private $state = 0; + protected $state = 0; /** * The requested size of this storage volume, in GiB. * * Generated from protobuf field int64 requested_size_gib = 4; */ - private $requested_size_gib = 0; + protected $requested_size_gib = 0; /** * Originally requested size, in GiB. * * Generated from protobuf field int64 originally_requested_size_gib = 16; */ - private $originally_requested_size_gib = 0; + protected $originally_requested_size_gib = 0; /** * The current size of this storage volume, in GiB, including space reserved * for snapshots. This size might be different than the requested size if the @@ -62,46 +62,46 @@ class Volume extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 current_size_gib = 5; */ - private $current_size_gib = 0; + protected $current_size_gib = 0; /** * Additional emergency size that was requested for this Volume, in GiB. * current_size_gib includes this value. * * Generated from protobuf field int64 emergency_size_gib = 14; */ - private $emergency_size_gib = 0; + protected $emergency_size_gib = 0; /** * Maximum size volume can be expanded to in case of evergency, in GiB. * * Generated from protobuf field int64 max_size_gib = 17; */ - private $max_size_gib = 0; + protected $max_size_gib = 0; /** * The size, in GiB, that this storage volume has expanded as a result of an * auto grow policy. In the absence of auto-grow, the value is 0. * * Generated from protobuf field int64 auto_grown_size_gib = 6; */ - private $auto_grown_size_gib = 0; + protected $auto_grown_size_gib = 0; /** * The space remaining in the storage volume for new LUNs, in GiB, excluding * space reserved for snapshots. * * Generated from protobuf field int64 remaining_space_gib = 7; */ - private $remaining_space_gib = 0; + protected $remaining_space_gib = 0; /** * Details about snapshot space reservation and usage on the storage volume. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Volume.SnapshotReservationDetail snapshot_reservation_detail = 8; */ - private $snapshot_reservation_detail = null; + protected $snapshot_reservation_detail = null; /** * The behavior to use when snapshot reserved space is full. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Volume.SnapshotAutoDeleteBehavior snapshot_auto_delete_behavior = 9; */ - private $snapshot_auto_delete_behavior = 0; + protected $snapshot_auto_delete_behavior = 0; /** * Labels as key value pairs. * @@ -113,53 +113,53 @@ class Volume extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool snapshot_enabled = 13; */ - private $snapshot_enabled = false; + protected $snapshot_enabled = false; /** * Immutable. Pod name. * * Generated from protobuf field string pod = 15 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $pod = ''; + protected $pod = ''; /** * Output only. Storage protocol for the Volume. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Volume.Protocol protocol = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $protocol = 0; + protected $protocol = 0; /** * Output only. Whether this volume is a boot volume. A boot volume is one * which contains a boot LUN. * * Generated from protobuf field bool boot_volume = 19 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $boot_volume = false; + protected $boot_volume = false; /** * Immutable. Performance tier of the Volume. * Default is SHARED. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VolumePerformanceTier performance_tier = 20 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $performance_tier = 0; + protected $performance_tier = 0; /** * Input only. User-specified notes for new Volume. * Used to provision Volumes that require manual intervention. * * Generated from protobuf field string notes = 21 [(.google.api.field_behavior) = INPUT_ONLY]; */ - private $notes = ''; + protected $notes = ''; /** * The workload profile for the volume. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.Volume.WorkloadProfile workload_profile = 22; */ - private $workload_profile = 0; + protected $workload_profile = 0; /** * Output only. Time after which volume will be fully deleted. * It is filled only for volumes in COOLOFF state. * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 24 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $expire_time = null; + protected $expire_time = null; /** * Output only. Instances this Volume is attached to. * This field is set only in Get requests. @@ -174,7 +174,7 @@ class Volume extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool attached = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $attached = false; + protected $attached = false; /** * Constructor. diff --git a/BareMetalSolution/src/V2/Volume/Protocol.php b/BareMetalSolution/src/V2/Volume/Protocol.php index 4fa04cff895..832166a996e 100644 --- a/BareMetalSolution/src/V2/Volume/Protocol.php +++ b/BareMetalSolution/src/V2/Volume/Protocol.php @@ -60,6 +60,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Protocol::class, \Google\Cloud\BareMetalSolution\V2\Volume_Protocol::class); diff --git a/BareMetalSolution/src/V2/Volume/SnapshotAutoDeleteBehavior.php b/BareMetalSolution/src/V2/Volume/SnapshotAutoDeleteBehavior.php index c00ae75623d..6d320e49019 100644 --- a/BareMetalSolution/src/V2/Volume/SnapshotAutoDeleteBehavior.php +++ b/BareMetalSolution/src/V2/Volume/SnapshotAutoDeleteBehavior.php @@ -68,6 +68,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(SnapshotAutoDeleteBehavior::class, \Google\Cloud\BareMetalSolution\V2\Volume_SnapshotAutoDeleteBehavior::class); diff --git a/BareMetalSolution/src/V2/Volume/SnapshotReservationDetail.php b/BareMetalSolution/src/V2/Volume/SnapshotReservationDetail.php index 3a5f5a3e7d6..2c250d0b706 100644 --- a/BareMetalSolution/src/V2/Volume/SnapshotReservationDetail.php +++ b/BareMetalSolution/src/V2/Volume/SnapshotReservationDetail.php @@ -20,7 +20,7 @@ class SnapshotReservationDetail extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 reserved_space_gib = 1; */ - private $reserved_space_gib = 0; + protected $reserved_space_gib = 0; /** * The percent of snapshot space on this storage volume actually being used * by the snapshot copies. This value might be higher than 100% if the @@ -29,14 +29,14 @@ class SnapshotReservationDetail extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 reserved_space_used_percent = 2; */ - private $reserved_space_used_percent = 0; + protected $reserved_space_used_percent = 0; /** * The amount, in GiB, of available space in this storage volume's reserved * snapshot space. * * Generated from protobuf field int64 reserved_space_remaining_gib = 3; */ - private $reserved_space_remaining_gib = 0; + protected $reserved_space_remaining_gib = 0; /** * Percent of the total Volume size reserved for snapshot copies. * Enabling snapshots requires reserving 20% or more of @@ -46,7 +46,7 @@ class SnapshotReservationDetail extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 reserved_space_percent = 4; */ - private $reserved_space_percent = 0; + protected $reserved_space_percent = 0; /** * Constructor. @@ -199,6 +199,4 @@ public function setReservedSpacePercent($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(SnapshotReservationDetail::class, \Google\Cloud\BareMetalSolution\V2\Volume_SnapshotReservationDetail::class); diff --git a/BareMetalSolution/src/V2/Volume/State.php b/BareMetalSolution/src/V2/Volume/State.php index 6f0294162c2..c266611eb9f 100644 --- a/BareMetalSolution/src/V2/Volume/State.php +++ b/BareMetalSolution/src/V2/Volume/State.php @@ -81,6 +81,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(State::class, \Google\Cloud\BareMetalSolution\V2\Volume_State::class); diff --git a/BareMetalSolution/src/V2/Volume/StorageType.php b/BareMetalSolution/src/V2/Volume/StorageType.php index 2ccb93087f7..31ba6d17dd6 100644 --- a/BareMetalSolution/src/V2/Volume/StorageType.php +++ b/BareMetalSolution/src/V2/Volume/StorageType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(StorageType::class, \Google\Cloud\BareMetalSolution\V2\Volume_StorageType::class); diff --git a/BareMetalSolution/src/V2/Volume/WorkloadProfile.php b/BareMetalSolution/src/V2/Volume/WorkloadProfile.php index dc4e299c0d9..e9d2f4fcdbd 100644 --- a/BareMetalSolution/src/V2/Volume/WorkloadProfile.php +++ b/BareMetalSolution/src/V2/Volume/WorkloadProfile.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(WorkloadProfile::class, \Google\Cloud\BareMetalSolution\V2\Volume_WorkloadProfile::class); diff --git a/BareMetalSolution/src/V2/VolumeConfig.php b/BareMetalSolution/src/V2/VolumeConfig.php index 88fe0aef696..7778d4373a6 100644 --- a/BareMetalSolution/src/V2/VolumeConfig.php +++ b/BareMetalSolution/src/V2/VolumeConfig.php @@ -20,38 +20,38 @@ class VolumeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * A transient unique identifier to identify a volume within an * ProvisioningConfig request. * * Generated from protobuf field string id = 2; */ - private $id = ''; + protected $id = ''; /** * Whether snapshots should be enabled. * * Generated from protobuf field bool snapshots_enabled = 3; */ - private $snapshots_enabled = false; + protected $snapshots_enabled = false; /** * The type of this Volume. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VolumeConfig.Type type = 4; */ - private $type = 0; + protected $type = 0; /** * Volume protocol. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VolumeConfig.Protocol protocol = 5; */ - private $protocol = 0; + protected $protocol = 0; /** * The requested size of this volume, in GB. * * Generated from protobuf field int32 size_gb = 6; */ - private $size_gb = 0; + protected $size_gb = 0; /** * LUN ranges to be configured. Set only when protocol is PROTOCOL_FC. * @@ -77,21 +77,21 @@ class VolumeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string user_note = 10; */ - private $user_note = ''; + protected $user_note = ''; /** * The GCP service of the storage volume. Available gcp_service are in * https://cloud.google.com/bare-metal/docs/bms-planning. * * Generated from protobuf field string gcp_service = 11; */ - private $gcp_service = ''; + protected $gcp_service = ''; /** * Performance tier of the Volume. * Default is SHARED. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VolumePerformanceTier performance_tier = 12; */ - private $performance_tier = 0; + protected $performance_tier = 0; /** * Constructor. diff --git a/BareMetalSolution/src/V2/VolumeConfig/LunRange.php b/BareMetalSolution/src/V2/VolumeConfig/LunRange.php index a4115863303..81425d39cd1 100644 --- a/BareMetalSolution/src/V2/VolumeConfig/LunRange.php +++ b/BareMetalSolution/src/V2/VolumeConfig/LunRange.php @@ -20,13 +20,13 @@ class LunRange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 quantity = 1; */ - private $quantity = 0; + protected $quantity = 0; /** * The requested size of each LUN, in GB. * * Generated from protobuf field int32 size_gb = 2; */ - private $size_gb = 0; + protected $size_gb = 0; /** * Constructor. @@ -99,6 +99,4 @@ public function setSizeGb($var) } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(LunRange::class, \Google\Cloud\BareMetalSolution\V2\VolumeConfig_LunRange::class); diff --git a/BareMetalSolution/src/V2/VolumeConfig/NfsExport.php b/BareMetalSolution/src/V2/VolumeConfig/NfsExport.php index b723be69898..b3b03cf2caa 100644 --- a/BareMetalSolution/src/V2/VolumeConfig/NfsExport.php +++ b/BareMetalSolution/src/V2/VolumeConfig/NfsExport.php @@ -20,13 +20,13 @@ class NfsExport extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network_id = 1; */ - private $network_id = ''; + protected $network_id = ''; /** * Export permissions. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VolumeConfig.NfsExport.Permissions permissions = 4; */ - private $permissions = 0; + protected $permissions = 0; /** * Disable root squashing, which is a feature of NFS. * Root squash is a special mapping of the remote superuser (root) identity @@ -34,19 +34,19 @@ class NfsExport extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool no_root_squash = 5; */ - private $no_root_squash = false; + protected $no_root_squash = false; /** * Allow the setuid flag. * * Generated from protobuf field bool allow_suid = 6; */ - private $allow_suid = false; + protected $allow_suid = false; /** * Allow dev flag in NfsShare AllowedClientsRequest. * * Generated from protobuf field bool allow_dev = 7; */ - private $allow_dev = false; + protected $allow_dev = false; protected $client; /** @@ -287,6 +287,4 @@ public function getClient() } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(NfsExport::class, \Google\Cloud\BareMetalSolution\V2\VolumeConfig_NfsExport::class); diff --git a/BareMetalSolution/src/V2/VolumeConfig/NfsExport/Permissions.php b/BareMetalSolution/src/V2/VolumeConfig/NfsExport/Permissions.php index 3df23bfc171..2aa587ee4d0 100644 --- a/BareMetalSolution/src/V2/VolumeConfig/NfsExport/Permissions.php +++ b/BareMetalSolution/src/V2/VolumeConfig/NfsExport/Permissions.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Permissions::class, \Google\Cloud\BareMetalSolution\V2\VolumeConfig_NfsExport_Permissions::class); diff --git a/BareMetalSolution/src/V2/VolumeConfig/Protocol.php b/BareMetalSolution/src/V2/VolumeConfig/Protocol.php index 65bef81f777..7a4749dbd1d 100644 --- a/BareMetalSolution/src/V2/VolumeConfig/Protocol.php +++ b/BareMetalSolution/src/V2/VolumeConfig/Protocol.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Protocol::class, \Google\Cloud\BareMetalSolution\V2\VolumeConfig_Protocol::class); diff --git a/BareMetalSolution/src/V2/VolumeConfig/Type.php b/BareMetalSolution/src/V2/VolumeConfig/Type.php index 625c45b1595..9b091fb55c1 100644 --- a/BareMetalSolution/src/V2/VolumeConfig/Type.php +++ b/BareMetalSolution/src/V2/VolumeConfig/Type.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(Type::class, \Google\Cloud\BareMetalSolution\V2\VolumeConfig_Type::class); diff --git a/BareMetalSolution/src/V2/VolumeSnapshot.php b/BareMetalSolution/src/V2/VolumeSnapshot.php index 9434bacc370..0f373073648 100644 --- a/BareMetalSolution/src/V2/VolumeSnapshot.php +++ b/BareMetalSolution/src/V2/VolumeSnapshot.php @@ -20,38 +20,38 @@ class VolumeSnapshot extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. An identifier for the snapshot, generated by the backend. * * Generated from protobuf field string id = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $id = ''; + protected $id = ''; /** * The description of the snapshot. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * Output only. The creation time of the snapshot. * * 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 name of the volume which this snapshot belongs to. * * Generated from protobuf field string storage_volume = 5 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $storage_volume = ''; + protected $storage_volume = ''; /** * Output only. The type of the snapshot which indicates whether it was * scheduled or manual/ad-hoc. * * Generated from protobuf field .google.cloud.baremetalsolution.v2.VolumeSnapshot.SnapshotType type = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $type = 0; + protected $type = 0; /** * Constructor. diff --git a/BareMetalSolution/src/V2/VolumeSnapshot/SnapshotType.php b/BareMetalSolution/src/V2/VolumeSnapshot/SnapshotType.php index cb33991c9af..93c4ed3372e 100644 --- a/BareMetalSolution/src/V2/VolumeSnapshot/SnapshotType.php +++ b/BareMetalSolution/src/V2/VolumeSnapshot/SnapshotType.php @@ -59,6 +59,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(SnapshotType::class, \Google\Cloud\BareMetalSolution\V2\VolumeSnapshot_SnapshotType::class); diff --git a/BareMetalSolution/tests/Unit/V2/BareMetalSolutionClientTest.php b/BareMetalSolution/tests/Unit/V2/BareMetalSolutionClientTest.php deleted file mode 100644 index bbadc702e2a..00000000000 --- a/BareMetalSolution/tests/Unit/V2/BareMetalSolutionClientTest.php +++ /dev/null @@ -1,4228 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return BareMetalSolutionClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new BareMetalSolutionClient($options); - } - - /** @test */ - public function createNfsShareTest() - { - $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/createNfsShareTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $nfsShareId = 'nfsShareId931294079'; - $id = 'id3355'; - $volume = 'volume-810883302'; - $requestedSizeGib = 525454387; - $expectedResponse = new NfsShare(); - $expectedResponse->setName($name); - $expectedResponse->setNfsShareId($nfsShareId); - $expectedResponse->setId($id); - $expectedResponse->setVolume($volume); - $expectedResponse->setRequestedSizeGib($requestedSizeGib); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createNfsShareTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $nfsShare = new NfsShare(); - $response = $gapicClient->createNfsShare($formattedParent, $nfsShare); - $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.baremetalsolution.v2.BareMetalSolution/CreateNfsShare', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getNfsShare(); - $this->assertProtobufEquals($nfsShare, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createNfsShareTest'); - $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 createNfsShareExceptionTest() - { - $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/createNfsShareTest'); - $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]'); - $nfsShare = new NfsShare(); - $response = $gapicClient->createNfsShare($formattedParent, $nfsShare); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createNfsShareTest'); - 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 createProvisioningConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $ticketId = 'ticketId-71132370'; - $handoverServiceAccount = 'handoverServiceAccount747638823'; - $email2 = 'email2-1638014897'; - $location = 'location1901043637'; - $cloudConsoleUri = 'cloudConsoleUri529066874'; - $vpcScEnabled = true; - $statusMessage = 'statusMessage-239442758'; - $customId = 'customId1611556009'; - $expectedResponse = new ProvisioningConfig(); - $expectedResponse->setName($name); - $expectedResponse->setTicketId($ticketId); - $expectedResponse->setHandoverServiceAccount($handoverServiceAccount); - $expectedResponse->setEmail($email2); - $expectedResponse->setLocation($location); - $expectedResponse->setCloudConsoleUri($cloudConsoleUri); - $expectedResponse->setVpcScEnabled($vpcScEnabled); - $expectedResponse->setStatusMessage($statusMessage); - $expectedResponse->setCustomId($customId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $provisioningConfig = new ProvisioningConfig(); - $response = $gapicClient->createProvisioningConfig($formattedParent, $provisioningConfig); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateProvisioningConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getProvisioningConfig(); - $this->assertProtobufEquals($provisioningConfig, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createProvisioningConfigExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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]'); - $provisioningConfig = new ProvisioningConfig(); - try { - $gapicClient->createProvisioningConfig($formattedParent, $provisioningConfig); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createSSHKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $publicKey = 'publicKey1904812937'; - $expectedResponse = new SSHKey(); - $expectedResponse->setName($name); - $expectedResponse->setPublicKey($publicKey); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $sshKey = new SSHKey(); - $sshKeyId = 'sshKeyId-385603310'; - $response = $gapicClient->createSSHKey($formattedParent, $sshKey, $sshKeyId); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateSSHKey', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getSshKey(); - $this->assertProtobufEquals($sshKey, $actualValue); - $actualValue = $actualRequestObject->getSshKeyId(); - $this->assertProtobufEquals($sshKeyId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createSSHKeyExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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]'); - $sshKey = new SSHKey(); - $sshKeyId = 'sshKeyId-385603310'; - try { - $gapicClient->createSSHKey($formattedParent, $sshKey, $sshKeyId); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createVolumeSnapshotTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $id = 'id3355'; - $description = 'description-1724546052'; - $storageVolume = 'storageVolume-768806562'; - $expectedResponse = new VolumeSnapshot(); - $expectedResponse->setName($name); - $expectedResponse->setId($id); - $expectedResponse->setDescription($description); - $expectedResponse->setStorageVolume($storageVolume); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $volumeSnapshot = new VolumeSnapshot(); - $response = $gapicClient->createVolumeSnapshot($formattedParent, $volumeSnapshot); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateVolumeSnapshot', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getVolumeSnapshot(); - $this->assertProtobufEquals($volumeSnapshot, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createVolumeSnapshotExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $volumeSnapshot = new VolumeSnapshot(); - try { - $gapicClient->createVolumeSnapshot($formattedParent, $volumeSnapshot); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteNfsShareTest() - { - $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/deleteNfsShareTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteNfsShareTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $response = $gapicClient->deleteNfsShare($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.baremetalsolution.v2.BareMetalSolution/DeleteNfsShare', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteNfsShareTest'); - $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 deleteNfsShareExceptionTest() - { - $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/deleteNfsShareTest'); - $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->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $response = $gapicClient->deleteNfsShare($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteNfsShareTest'); - 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 deleteSSHKeyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->sshKeyName('[PROJECT]', '[LOCATION]', '[SSH_KEY]'); - $gapicClient->deleteSSHKey($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/DeleteSSHKey', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteSSHKeyExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->sshKeyName('[PROJECT]', '[LOCATION]', '[SSH_KEY]'); - try { - $gapicClient->deleteSSHKey($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 deleteVolumeSnapshotTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $gapicClient->deleteVolumeSnapshot($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/DeleteVolumeSnapshot', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteVolumeSnapshotExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - try { - $gapicClient->deleteVolumeSnapshot($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 detachLunTest() - { - $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/detachLunTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $id = 'id3355'; - $machineType = 'machineType1838323762'; - $hyperthreadingEnabled = true; - $interactiveSerialConsoleEnabled = false; - $osImage = 'osImage1982209856'; - $pod = 'pod111173'; - $networkTemplate = 'networkTemplate215365483'; - $loginInfo = 'loginInfo-1747949628'; - $firmwareVersion = 'firmwareVersion-987819436'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name); - $expectedResponse->setId($id); - $expectedResponse->setMachineType($machineType); - $expectedResponse->setHyperthreadingEnabled($hyperthreadingEnabled); - $expectedResponse->setInteractiveSerialConsoleEnabled($interactiveSerialConsoleEnabled); - $expectedResponse->setOsImage($osImage); - $expectedResponse->setPod($pod); - $expectedResponse->setNetworkTemplate($networkTemplate); - $expectedResponse->setLoginInfo($loginInfo); - $expectedResponse->setFirmwareVersion($firmwareVersion); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/detachLunTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedInstance = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $formattedLun = $gapicClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $response = $gapicClient->detachLun($formattedInstance, $formattedLun); - $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.baremetalsolution.v2.BareMetalSolution/DetachLun', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getInstance(); - $this->assertProtobufEquals($formattedInstance, $actualValue); - $actualValue = $actualApiRequestObject->getLun(); - $this->assertProtobufEquals($formattedLun, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/detachLunTest'); - $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 detachLunExceptionTest() - { - $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/detachLunTest'); - $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 - $formattedInstance = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $formattedLun = $gapicClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $response = $gapicClient->detachLun($formattedInstance, $formattedLun); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/detachLunTest'); - 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 disableInteractiveSerialConsoleTest() - { - $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/disableInteractiveSerialConsoleTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new DisableInteractiveSerialConsoleResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/disableInteractiveSerialConsoleTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->disableInteractiveSerialConsole($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.baremetalsolution.v2.BareMetalSolution/DisableInteractiveSerialConsole', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/disableInteractiveSerialConsoleTest'); - $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 disableInteractiveSerialConsoleExceptionTest() - { - $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/disableInteractiveSerialConsoleTest'); - $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->disableInteractiveSerialConsole($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/disableInteractiveSerialConsoleTest'); - 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 enableInteractiveSerialConsoleTest() - { - $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/enableInteractiveSerialConsoleTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new EnableInteractiveSerialConsoleResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/enableInteractiveSerialConsoleTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->enableInteractiveSerialConsole($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.baremetalsolution.v2.BareMetalSolution/EnableInteractiveSerialConsole', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/enableInteractiveSerialConsoleTest'); - $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 enableInteractiveSerialConsoleExceptionTest() - { - $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/enableInteractiveSerialConsoleTest'); - $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->enableInteractiveSerialConsole($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/enableInteractiveSerialConsoleTest'); - 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 evictLunTest() - { - $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/evictLunTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/evictLunTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $response = $gapicClient->evictLun($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.baremetalsolution.v2.BareMetalSolution/EvictLun', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/evictLunTest'); - $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 evictLunExceptionTest() - { - $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/evictLunTest'); - $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->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $response = $gapicClient->evictLun($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/evictLunTest'); - 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 evictVolumeTest() - { - $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/evictVolumeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/evictVolumeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $response = $gapicClient->evictVolume($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.baremetalsolution.v2.BareMetalSolution/EvictVolume', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/evictVolumeTest'); - $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 evictVolumeExceptionTest() - { - $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/evictVolumeTest'); - $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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $response = $gapicClient->evictVolume($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/evictVolumeTest'); - 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 getInstanceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $machineType = 'machineType1838323762'; - $hyperthreadingEnabled = true; - $interactiveSerialConsoleEnabled = false; - $osImage = 'osImage1982209856'; - $pod = 'pod111173'; - $networkTemplate = 'networkTemplate215365483'; - $loginInfo = 'loginInfo-1747949628'; - $firmwareVersion = 'firmwareVersion-987819436'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setMachineType($machineType); - $expectedResponse->setHyperthreadingEnabled($hyperthreadingEnabled); - $expectedResponse->setInteractiveSerialConsoleEnabled($interactiveSerialConsoleEnabled); - $expectedResponse->setOsImage($osImage); - $expectedResponse->setPod($pod); - $expectedResponse->setNetworkTemplate($networkTemplate); - $expectedResponse->setLoginInfo($loginInfo); - $expectedResponse->setFirmwareVersion($firmwareVersion); - $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.baremetalsolution.v2.BareMetalSolution/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 getLunTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $sizeGb = 2105542105; - $storageVolume = 'storageVolume-768806562'; - $shareable = false; - $bootLun = true; - $wwid = 'wwid3662843'; - $expectedResponse = new Lun(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setSizeGb($sizeGb); - $expectedResponse->setStorageVolume($storageVolume); - $expectedResponse->setShareable($shareable); - $expectedResponse->setBootLun($bootLun); - $expectedResponse->setWwid($wwid); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $response = $gapicClient->getLun($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.baremetalsolution.v2.BareMetalSolution/GetLun', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLunExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - try { - $gapicClient->getLun($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 getNetworkTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $ipAddress = 'ipAddress1480014044'; - $vlanId = 'vlanId536153463'; - $cidr = 'cidr3053428'; - $servicesCidr = 'servicesCidr-1169831243'; - $pod = 'pod111173'; - $jumboFramesEnabled = true; - $gatewayIp = 'gatewayIp955798786'; - $expectedResponse = new Network(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setIpAddress($ipAddress); - $expectedResponse->setVlanId($vlanId); - $expectedResponse->setCidr($cidr); - $expectedResponse->setServicesCidr($servicesCidr); - $expectedResponse->setPod($pod); - $expectedResponse->setJumboFramesEnabled($jumboFramesEnabled); - $expectedResponse->setGatewayIp($gatewayIp); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); - $response = $gapicClient->getNetwork($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.baremetalsolution.v2.BareMetalSolution/GetNetwork', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getNetworkExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); - try { - $gapicClient->getNetwork($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 getNfsShareTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $nfsShareId = 'nfsShareId931294079'; - $id = 'id3355'; - $volume = 'volume-810883302'; - $requestedSizeGib = 525454387; - $expectedResponse = new NfsShare(); - $expectedResponse->setName($name2); - $expectedResponse->setNfsShareId($nfsShareId); - $expectedResponse->setId($id); - $expectedResponse->setVolume($volume); - $expectedResponse->setRequestedSizeGib($requestedSizeGib); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $response = $gapicClient->getNfsShare($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.baremetalsolution.v2.BareMetalSolution/GetNfsShare', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getNfsShareExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - try { - $gapicClient->getNfsShare($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 getProvisioningConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $ticketId = 'ticketId-71132370'; - $handoverServiceAccount = 'handoverServiceAccount747638823'; - $email = 'email96619420'; - $location = 'location1901043637'; - $cloudConsoleUri = 'cloudConsoleUri529066874'; - $vpcScEnabled = true; - $statusMessage = 'statusMessage-239442758'; - $customId = 'customId1611556009'; - $expectedResponse = new ProvisioningConfig(); - $expectedResponse->setName($name2); - $expectedResponse->setTicketId($ticketId); - $expectedResponse->setHandoverServiceAccount($handoverServiceAccount); - $expectedResponse->setEmail($email); - $expectedResponse->setLocation($location); - $expectedResponse->setCloudConsoleUri($cloudConsoleUri); - $expectedResponse->setVpcScEnabled($vpcScEnabled); - $expectedResponse->setStatusMessage($statusMessage); - $expectedResponse->setCustomId($customId); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->provisioningConfigName('[PROJECT]', '[LOCATION]', '[PROVISIONING_CONFIG]'); - $response = $gapicClient->getProvisioningConfig($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.baremetalsolution.v2.BareMetalSolution/GetProvisioningConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getProvisioningConfigExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->provisioningConfigName('[PROJECT]', '[LOCATION]', '[PROVISIONING_CONFIG]'); - try { - $gapicClient->getProvisioningConfig($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 getVolumeTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $requestedSizeGib = 525454387; - $originallyRequestedSizeGib = 44854004; - $currentSizeGib = 72696456; - $emergencySizeGib = 1936971120; - $maxSizeGib = 1805521661; - $autoGrownSizeGib = 1245638678; - $remainingSpaceGib = 1423108606; - $snapshotEnabled = true; - $pod = 'pod111173'; - $bootVolume = false; - $notes = 'notes105008833'; - $attached = true; - $expectedResponse = new Volume(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setRequestedSizeGib($requestedSizeGib); - $expectedResponse->setOriginallyRequestedSizeGib($originallyRequestedSizeGib); - $expectedResponse->setCurrentSizeGib($currentSizeGib); - $expectedResponse->setEmergencySizeGib($emergencySizeGib); - $expectedResponse->setMaxSizeGib($maxSizeGib); - $expectedResponse->setAutoGrownSizeGib($autoGrownSizeGib); - $expectedResponse->setRemainingSpaceGib($remainingSpaceGib); - $expectedResponse->setSnapshotEnabled($snapshotEnabled); - $expectedResponse->setPod($pod); - $expectedResponse->setBootVolume($bootVolume); - $expectedResponse->setNotes($notes); - $expectedResponse->setAttached($attached); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $response = $gapicClient->getVolume($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.baremetalsolution.v2.BareMetalSolution/GetVolume', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getVolumeExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - try { - $gapicClient->getVolume($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 getVolumeSnapshotTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $description = 'description-1724546052'; - $storageVolume = 'storageVolume-768806562'; - $expectedResponse = new VolumeSnapshot(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setDescription($description); - $expectedResponse->setStorageVolume($storageVolume); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $response = $gapicClient->getVolumeSnapshot($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.baremetalsolution.v2.BareMetalSolution/GetVolumeSnapshot', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getVolumeSnapshotExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - try { - $gapicClient->getVolumeSnapshot($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 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.baremetalsolution.v2.BareMetalSolution/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 listLunsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $lunsElement = new Lun(); - $luns = [ - $lunsElement, - ]; - $expectedResponse = new ListLunsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLuns($luns); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $response = $gapicClient->listLuns($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLuns()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListLuns', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLunsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - try { - $gapicClient->listLuns($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 listNetworkUsageTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ListNetworkUsageResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedLocation = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listNetworkUsage($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.baremetalsolution.v2.BareMetalSolution/ListNetworkUsage', $actualFuncCall); - $actualValue = $actualRequestObject->getLocation(); - $this->assertProtobufEquals($formattedLocation, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listNetworkUsageExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listNetworkUsage($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 listNetworksTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $networksElement = new Network(); - $networks = [ - $networksElement, - ]; - $expectedResponse = new ListNetworksResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setNetworks($networks); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listNetworks($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getNetworks()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNetworks', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listNetworksExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listNetworks($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 listNfsSharesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $nfsSharesElement = new NfsShare(); - $nfsShares = [ - $nfsSharesElement, - ]; - $expectedResponse = new ListNfsSharesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setNfsShares($nfsShares); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listNfsShares($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getNfsShares()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNfsShares', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listNfsSharesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listNfsShares($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 listOSImagesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $osImagesElement = new OSImage(); - $osImages = [ - $osImagesElement, - ]; - $expectedResponse = new ListOSImagesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setOsImages($osImages); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listOSImages($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getOsImages()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListOSImages', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listOSImagesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listOSImages($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 listProvisioningQuotasTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $provisioningQuotasElement = new ProvisioningQuota(); - $provisioningQuotas = [ - $provisioningQuotasElement, - ]; - $expectedResponse = new ListProvisioningQuotasResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setProvisioningQuotas($provisioningQuotas); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listProvisioningQuotas($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getProvisioningQuotas()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListProvisioningQuotas', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listProvisioningQuotasExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listProvisioningQuotas($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 listSSHKeysTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $sshKeysElement = new SSHKey(); - $sshKeys = [ - $sshKeysElement, - ]; - $expectedResponse = new ListSSHKeysResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSshKeys($sshKeys); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listSSHKeys($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSshKeys()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListSSHKeys', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listSSHKeysExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listSSHKeys($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 listVolumeSnapshotsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $volumeSnapshotsElement = new VolumeSnapshot(); - $volumeSnapshots = [ - $volumeSnapshotsElement, - ]; - $expectedResponse = new ListVolumeSnapshotsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setVolumeSnapshots($volumeSnapshots); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $response = $gapicClient->listVolumeSnapshots($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getVolumeSnapshots()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListVolumeSnapshots', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listVolumeSnapshotsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - try { - $gapicClient->listVolumeSnapshots($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 listVolumesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $volumesElement = new Volume(); - $volumes = [ - $volumesElement, - ]; - $expectedResponse = new ListVolumesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setVolumes($volumes); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listVolumes($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getVolumes()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListVolumes', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listVolumesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listVolumes($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 renameInstanceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $machineType = 'machineType1838323762'; - $hyperthreadingEnabled = true; - $interactiveSerialConsoleEnabled = false; - $osImage = 'osImage1982209856'; - $pod = 'pod111173'; - $networkTemplate = 'networkTemplate215365483'; - $loginInfo = 'loginInfo-1747949628'; - $firmwareVersion = 'firmwareVersion-987819436'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setMachineType($machineType); - $expectedResponse->setHyperthreadingEnabled($hyperthreadingEnabled); - $expectedResponse->setInteractiveSerialConsoleEnabled($interactiveSerialConsoleEnabled); - $expectedResponse->setOsImage($osImage); - $expectedResponse->setPod($pod); - $expectedResponse->setNetworkTemplate($networkTemplate); - $expectedResponse->setLoginInfo($loginInfo); - $expectedResponse->setFirmwareVersion($firmwareVersion); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $newInstanceId = 'newInstanceId-179130138'; - $response = $gapicClient->renameInstance($formattedName, $newInstanceId); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameInstance', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getNewInstanceId(); - $this->assertProtobufEquals($newInstanceId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameInstanceExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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]'); - $newInstanceId = 'newInstanceId-179130138'; - try { - $gapicClient->renameInstance($formattedName, $newInstanceId); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameNetworkTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $ipAddress = 'ipAddress1480014044'; - $vlanId = 'vlanId536153463'; - $cidr = 'cidr3053428'; - $servicesCidr = 'servicesCidr-1169831243'; - $pod = 'pod111173'; - $jumboFramesEnabled = true; - $gatewayIp = 'gatewayIp955798786'; - $expectedResponse = new Network(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setIpAddress($ipAddress); - $expectedResponse->setVlanId($vlanId); - $expectedResponse->setCidr($cidr); - $expectedResponse->setServicesCidr($servicesCidr); - $expectedResponse->setPod($pod); - $expectedResponse->setJumboFramesEnabled($jumboFramesEnabled); - $expectedResponse->setGatewayIp($gatewayIp); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); - $newNetworkId = 'newNetworkId-554751797'; - $response = $gapicClient->renameNetwork($formattedName, $newNetworkId); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameNetwork', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getNewNetworkId(); - $this->assertProtobufEquals($newNetworkId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameNetworkExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); - $newNetworkId = 'newNetworkId-554751797'; - try { - $gapicClient->renameNetwork($formattedName, $newNetworkId); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameNfsShareTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $nfsShareId = 'nfsShareId931294079'; - $id = 'id3355'; - $volume = 'volume-810883302'; - $requestedSizeGib = 525454387; - $expectedResponse = new NfsShare(); - $expectedResponse->setName($name2); - $expectedResponse->setNfsShareId($nfsShareId); - $expectedResponse->setId($id); - $expectedResponse->setVolume($volume); - $expectedResponse->setRequestedSizeGib($requestedSizeGib); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $newNfsshareId = 'newNfsshareId814577687'; - $response = $gapicClient->renameNfsShare($formattedName, $newNfsshareId); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameNfsShare', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getNewNfsshareId(); - $this->assertProtobufEquals($newNfsshareId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameNfsShareExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $newNfsshareId = 'newNfsshareId814577687'; - try { - $gapicClient->renameNfsShare($formattedName, $newNfsshareId); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameVolumeTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $requestedSizeGib = 525454387; - $originallyRequestedSizeGib = 44854004; - $currentSizeGib = 72696456; - $emergencySizeGib = 1936971120; - $maxSizeGib = 1805521661; - $autoGrownSizeGib = 1245638678; - $remainingSpaceGib = 1423108606; - $snapshotEnabled = true; - $pod = 'pod111173'; - $bootVolume = false; - $notes = 'notes105008833'; - $attached = true; - $expectedResponse = new Volume(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setRequestedSizeGib($requestedSizeGib); - $expectedResponse->setOriginallyRequestedSizeGib($originallyRequestedSizeGib); - $expectedResponse->setCurrentSizeGib($currentSizeGib); - $expectedResponse->setEmergencySizeGib($emergencySizeGib); - $expectedResponse->setMaxSizeGib($maxSizeGib); - $expectedResponse->setAutoGrownSizeGib($autoGrownSizeGib); - $expectedResponse->setRemainingSpaceGib($remainingSpaceGib); - $expectedResponse->setSnapshotEnabled($snapshotEnabled); - $expectedResponse->setPod($pod); - $expectedResponse->setBootVolume($bootVolume); - $expectedResponse->setNotes($notes); - $expectedResponse->setAttached($attached); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $newVolumeId = 'newVolumeId-468182911'; - $response = $gapicClient->renameVolume($formattedName, $newVolumeId); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameVolume', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getNewVolumeId(); - $this->assertProtobufEquals($newVolumeId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function renameVolumeExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $newVolumeId = 'newVolumeId-468182911'; - try { - $gapicClient->renameVolume($formattedName, $newVolumeId); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function resetInstanceTest() - { - $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/resetInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new ResetInstanceResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/resetInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->resetInstance($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.baremetalsolution.v2.BareMetalSolution/ResetInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/resetInstanceTest'); - $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 resetInstanceExceptionTest() - { - $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/resetInstanceTest'); - $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->resetInstance($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/resetInstanceTest'); - 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 resizeVolumeTest() - { - $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/resizeVolumeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $id = 'id3355'; - $requestedSizeGib = 525454387; - $originallyRequestedSizeGib = 44854004; - $currentSizeGib = 72696456; - $emergencySizeGib = 1936971120; - $maxSizeGib = 1805521661; - $autoGrownSizeGib = 1245638678; - $remainingSpaceGib = 1423108606; - $snapshotEnabled = true; - $pod = 'pod111173'; - $bootVolume = false; - $notes = 'notes105008833'; - $attached = true; - $expectedResponse = new Volume(); - $expectedResponse->setName($name); - $expectedResponse->setId($id); - $expectedResponse->setRequestedSizeGib($requestedSizeGib); - $expectedResponse->setOriginallyRequestedSizeGib($originallyRequestedSizeGib); - $expectedResponse->setCurrentSizeGib($currentSizeGib); - $expectedResponse->setEmergencySizeGib($emergencySizeGib); - $expectedResponse->setMaxSizeGib($maxSizeGib); - $expectedResponse->setAutoGrownSizeGib($autoGrownSizeGib); - $expectedResponse->setRemainingSpaceGib($remainingSpaceGib); - $expectedResponse->setSnapshotEnabled($snapshotEnabled); - $expectedResponse->setPod($pod); - $expectedResponse->setBootVolume($bootVolume); - $expectedResponse->setNotes($notes); - $expectedResponse->setAttached($attached); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/resizeVolumeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedVolume = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $response = $gapicClient->resizeVolume($formattedVolume); - $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.baremetalsolution.v2.BareMetalSolution/ResizeVolume', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getVolume(); - $this->assertProtobufEquals($formattedVolume, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/resizeVolumeTest'); - $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 resizeVolumeExceptionTest() - { - $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/resizeVolumeTest'); - $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 - $formattedVolume = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $response = $gapicClient->resizeVolume($formattedVolume); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/resizeVolumeTest'); - 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 restoreVolumeSnapshotTest() - { - $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/restoreVolumeSnapshotTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $id = 'id3355'; - $description = 'description-1724546052'; - $storageVolume = 'storageVolume-768806562'; - $expectedResponse = new VolumeSnapshot(); - $expectedResponse->setName($name); - $expectedResponse->setId($id); - $expectedResponse->setDescription($description); - $expectedResponse->setStorageVolume($storageVolume); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/restoreVolumeSnapshotTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedVolumeSnapshot = $gapicClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $response = $gapicClient->restoreVolumeSnapshot($formattedVolumeSnapshot); - $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.baremetalsolution.v2.BareMetalSolution/RestoreVolumeSnapshot', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getVolumeSnapshot(); - $this->assertProtobufEquals($formattedVolumeSnapshot, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/restoreVolumeSnapshotTest'); - $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 restoreVolumeSnapshotExceptionTest() - { - $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/restoreVolumeSnapshotTest'); - $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 - $formattedVolumeSnapshot = $gapicClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $response = $gapicClient->restoreVolumeSnapshot($formattedVolumeSnapshot); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/restoreVolumeSnapshotTest'); - 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 startInstanceTest() - { - $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/startInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new StartInstanceResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/startInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->startInstance($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.baremetalsolution.v2.BareMetalSolution/StartInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/startInstanceTest'); - $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 startInstanceExceptionTest() - { - $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/startInstanceTest'); - $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->startInstance($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/startInstanceTest'); - 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 stopInstanceTest() - { - $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/stopInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new StopInstanceResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/stopInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $response = $gapicClient->stopInstance($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.baremetalsolution.v2.BareMetalSolution/StopInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/stopInstanceTest'); - $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 stopInstanceExceptionTest() - { - $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/stopInstanceTest'); - $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->stopInstance($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/stopInstanceTest'); - 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 submitProvisioningConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new SubmitProvisioningConfigResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $provisioningConfig = new ProvisioningConfig(); - $response = $gapicClient->submitProvisioningConfig($formattedParent, $provisioningConfig); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/SubmitProvisioningConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getProvisioningConfig(); - $this->assertProtobufEquals($provisioningConfig, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function submitProvisioningConfigExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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]'); - $provisioningConfig = new ProvisioningConfig(); - try { - $gapicClient->submitProvisioningConfig($formattedParent, $provisioningConfig); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->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'; - $id = 'id3355'; - $machineType = 'machineType1838323762'; - $hyperthreadingEnabled = true; - $interactiveSerialConsoleEnabled = false; - $osImage = 'osImage1982209856'; - $pod = 'pod111173'; - $networkTemplate = 'networkTemplate215365483'; - $loginInfo = 'loginInfo-1747949628'; - $firmwareVersion = 'firmwareVersion-987819436'; - $expectedResponse = new Instance(); - $expectedResponse->setName($name); - $expectedResponse->setId($id); - $expectedResponse->setMachineType($machineType); - $expectedResponse->setHyperthreadingEnabled($hyperthreadingEnabled); - $expectedResponse->setInteractiveSerialConsoleEnabled($interactiveSerialConsoleEnabled); - $expectedResponse->setOsImage($osImage); - $expectedResponse->setPod($pod); - $expectedResponse->setNetworkTemplate($networkTemplate); - $expectedResponse->setLoginInfo($loginInfo); - $expectedResponse->setFirmwareVersion($firmwareVersion); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $instance = new Instance(); - $response = $gapicClient->updateInstance($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.baremetalsolution.v2.BareMetalSolution/UpdateInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getInstance(); - $this->assertProtobufEquals($instance, $actualValue); - $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); - // Mock request - $instance = new Instance(); - $response = $gapicClient->updateInstance($instance); - $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 updateNetworkTest() - { - $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/updateNetworkTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $id = 'id3355'; - $ipAddress = 'ipAddress1480014044'; - $vlanId = 'vlanId536153463'; - $cidr = 'cidr3053428'; - $servicesCidr = 'servicesCidr-1169831243'; - $pod = 'pod111173'; - $jumboFramesEnabled = true; - $gatewayIp = 'gatewayIp955798786'; - $expectedResponse = new Network(); - $expectedResponse->setName($name); - $expectedResponse->setId($id); - $expectedResponse->setIpAddress($ipAddress); - $expectedResponse->setVlanId($vlanId); - $expectedResponse->setCidr($cidr); - $expectedResponse->setServicesCidr($servicesCidr); - $expectedResponse->setPod($pod); - $expectedResponse->setJumboFramesEnabled($jumboFramesEnabled); - $expectedResponse->setGatewayIp($gatewayIp); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateNetworkTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $network = new Network(); - $response = $gapicClient->updateNetwork($network); - $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.baremetalsolution.v2.BareMetalSolution/UpdateNetwork', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getNetwork(); - $this->assertProtobufEquals($network, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateNetworkTest'); - $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 updateNetworkExceptionTest() - { - $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/updateNetworkTest'); - $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 - $network = new Network(); - $response = $gapicClient->updateNetwork($network); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateNetworkTest'); - 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 updateNfsShareTest() - { - $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/updateNfsShareTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $nfsShareId = 'nfsShareId931294079'; - $id = 'id3355'; - $volume = 'volume-810883302'; - $requestedSizeGib = 525454387; - $expectedResponse = new NfsShare(); - $expectedResponse->setName($name); - $expectedResponse->setNfsShareId($nfsShareId); - $expectedResponse->setId($id); - $expectedResponse->setVolume($volume); - $expectedResponse->setRequestedSizeGib($requestedSizeGib); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateNfsShareTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $nfsShare = new NfsShare(); - $response = $gapicClient->updateNfsShare($nfsShare); - $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.baremetalsolution.v2.BareMetalSolution/UpdateNfsShare', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getNfsShare(); - $this->assertProtobufEquals($nfsShare, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateNfsShareTest'); - $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 updateNfsShareExceptionTest() - { - $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/updateNfsShareTest'); - $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 - $nfsShare = new NfsShare(); - $response = $gapicClient->updateNfsShare($nfsShare); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateNfsShareTest'); - 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 updateProvisioningConfigTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $ticketId = 'ticketId-71132370'; - $handoverServiceAccount = 'handoverServiceAccount747638823'; - $email2 = 'email2-1638014897'; - $location = 'location1901043637'; - $cloudConsoleUri = 'cloudConsoleUri529066874'; - $vpcScEnabled = true; - $statusMessage = 'statusMessage-239442758'; - $customId = 'customId1611556009'; - $expectedResponse = new ProvisioningConfig(); - $expectedResponse->setName($name); - $expectedResponse->setTicketId($ticketId); - $expectedResponse->setHandoverServiceAccount($handoverServiceAccount); - $expectedResponse->setEmail($email2); - $expectedResponse->setLocation($location); - $expectedResponse->setCloudConsoleUri($cloudConsoleUri); - $expectedResponse->setVpcScEnabled($vpcScEnabled); - $expectedResponse->setStatusMessage($statusMessage); - $expectedResponse->setCustomId($customId); - $transport->addResponse($expectedResponse); - // Mock request - $provisioningConfig = new ProvisioningConfig(); - $updateMask = new FieldMask(); - $response = $gapicClient->updateProvisioningConfig($provisioningConfig, $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.baremetalsolution.v2.BareMetalSolution/UpdateProvisioningConfig', $actualFuncCall); - $actualValue = $actualRequestObject->getProvisioningConfig(); - $this->assertProtobufEquals($provisioningConfig, $actualValue); - $actualValue = $actualRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateProvisioningConfigExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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 - $provisioningConfig = new ProvisioningConfig(); - $updateMask = new FieldMask(); - try { - $gapicClient->updateProvisioningConfig($provisioningConfig, $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 updateVolumeTest() - { - $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/updateVolumeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $id = 'id3355'; - $requestedSizeGib = 525454387; - $originallyRequestedSizeGib = 44854004; - $currentSizeGib = 72696456; - $emergencySizeGib = 1936971120; - $maxSizeGib = 1805521661; - $autoGrownSizeGib = 1245638678; - $remainingSpaceGib = 1423108606; - $snapshotEnabled = true; - $pod = 'pod111173'; - $bootVolume = false; - $notes = 'notes105008833'; - $attached = true; - $expectedResponse = new Volume(); - $expectedResponse->setName($name); - $expectedResponse->setId($id); - $expectedResponse->setRequestedSizeGib($requestedSizeGib); - $expectedResponse->setOriginallyRequestedSizeGib($originallyRequestedSizeGib); - $expectedResponse->setCurrentSizeGib($currentSizeGib); - $expectedResponse->setEmergencySizeGib($emergencySizeGib); - $expectedResponse->setMaxSizeGib($maxSizeGib); - $expectedResponse->setAutoGrownSizeGib($autoGrownSizeGib); - $expectedResponse->setRemainingSpaceGib($remainingSpaceGib); - $expectedResponse->setSnapshotEnabled($snapshotEnabled); - $expectedResponse->setPod($pod); - $expectedResponse->setBootVolume($bootVolume); - $expectedResponse->setNotes($notes); - $expectedResponse->setAttached($attached); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateVolumeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $volume = new Volume(); - $response = $gapicClient->updateVolume($volume); - $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.baremetalsolution.v2.BareMetalSolution/UpdateVolume', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getVolume(); - $this->assertProtobufEquals($volume, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateVolumeTest'); - $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 updateVolumeExceptionTest() - { - $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/updateVolumeTest'); - $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 - $volume = new Volume(); - $response = $gapicClient->updateVolume($volume); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateVolumeTest'); - 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()); - } -} diff --git a/BareMetalSolution/tests/Unit/V2/Client/BareMetalSolutionClientTest.php b/BareMetalSolution/tests/Unit/V2/Client/BareMetalSolutionClientTest.php index 48c769c307b..59fe87610a8 100644 --- a/BareMetalSolution/tests/Unit/V2/Client/BareMetalSolutionClientTest.php +++ b/BareMetalSolution/tests/Unit/V2/Client/BareMetalSolutionClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return BareMetalSolutionClient */ @@ -180,9 +182,7 @@ public function createNfsShareTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $nfsShare = new NfsShare(); - $request = (new CreateNfsShareRequest()) - ->setParent($formattedParent) - ->setNfsShare($nfsShare); + $request = (new CreateNfsShareRequest())->setParent($formattedParent)->setNfsShare($nfsShare); $response = $gapicClient->createNfsShare($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -240,19 +240,20 @@ public function createNfsShareExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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]'); $nfsShare = new NfsShare(); - $request = (new CreateNfsShareRequest()) - ->setParent($formattedParent) - ->setNfsShare($nfsShare); + $request = (new CreateNfsShareRequest())->setParent($formattedParent)->setNfsShare($nfsShare); $response = $gapicClient->createNfsShare($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -316,7 +317,10 @@ public function createProvisioningConfigTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateProvisioningConfig', $actualFuncCall); + $this->assertSame( + '/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateProvisioningConfig', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getProvisioningConfig(); @@ -335,12 +339,15 @@ public function createProvisioningConfigExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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]'); @@ -411,12 +418,15 @@ public function createSSHKeyExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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]'); @@ -461,9 +471,7 @@ public function createVolumeSnapshotTest() // Mock request $formattedParent = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); $volumeSnapshot = new VolumeSnapshot(); - $request = (new CreateVolumeSnapshotRequest()) - ->setParent($formattedParent) - ->setVolumeSnapshot($volumeSnapshot); + $request = (new CreateVolumeSnapshotRequest())->setParent($formattedParent)->setVolumeSnapshot($volumeSnapshot); $response = $gapicClient->createVolumeSnapshot($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -489,19 +497,20 @@ public function createVolumeSnapshotExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); $volumeSnapshot = new VolumeSnapshot(); - $request = (new CreateVolumeSnapshotRequest()) - ->setParent($formattedParent) - ->setVolumeSnapshot($volumeSnapshot); + $request = (new CreateVolumeSnapshotRequest())->setParent($formattedParent)->setVolumeSnapshot($volumeSnapshot); try { $gapicClient->createVolumeSnapshot($request); // If the $gapicClient method call did not throw, fail the test @@ -546,8 +555,7 @@ public function deleteNfsShareTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $request = (new DeleteNfsShareRequest()) - ->setName($formattedName); + $request = (new DeleteNfsShareRequest())->setName($formattedName); $response = $gapicClient->deleteNfsShare($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -603,17 +611,19 @@ public function deleteNfsShareExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $request = (new DeleteNfsShareRequest()) - ->setName($formattedName); + $request = (new DeleteNfsShareRequest())->setName($formattedName); $response = $gapicClient->deleteNfsShare($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -649,8 +659,7 @@ public function deleteSSHKeyTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->sshKeyName('[PROJECT]', '[LOCATION]', '[SSH_KEY]'); - $request = (new DeleteSSHKeyRequest()) - ->setName($formattedName); + $request = (new DeleteSSHKeyRequest())->setName($formattedName); $gapicClient->deleteSSHKey($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -673,17 +682,19 @@ public function deleteSSHKeyExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->sshKeyName('[PROJECT]', '[LOCATION]', '[SSH_KEY]'); - $request = (new DeleteSSHKeyRequest()) - ->setName($formattedName); + $request = (new DeleteSSHKeyRequest())->setName($formattedName); try { $gapicClient->deleteSSHKey($request); // If the $gapicClient method call did not throw, fail the test @@ -710,8 +721,7 @@ public function deleteVolumeSnapshotTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $request = (new DeleteVolumeSnapshotRequest()) - ->setName($formattedName); + $request = (new DeleteVolumeSnapshotRequest())->setName($formattedName); $gapicClient->deleteVolumeSnapshot($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -734,17 +744,19 @@ public function deleteVolumeSnapshotExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $request = (new DeleteVolumeSnapshotRequest()) - ->setName($formattedName); + $request = (new DeleteVolumeSnapshotRequest())->setName($formattedName); try { $gapicClient->deleteVolumeSnapshot($request); // If the $gapicClient method call did not throw, fail the test @@ -810,9 +822,7 @@ public function detachLunTest() // Mock request $formattedInstance = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); $formattedLun = $gapicClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $request = (new DetachLunRequest()) - ->setInstance($formattedInstance) - ->setLun($formattedLun); + $request = (new DetachLunRequest())->setInstance($formattedInstance)->setLun($formattedLun); $response = $gapicClient->detachLun($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -870,19 +880,20 @@ public function detachLunExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $formattedInstance = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); $formattedLun = $gapicClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $request = (new DetachLunRequest()) - ->setInstance($formattedInstance) - ->setLun($formattedLun); + $request = (new DetachLunRequest())->setInstance($formattedInstance)->setLun($formattedLun); $response = $gapicClient->detachLun($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -936,8 +947,7 @@ public function disableInteractiveSerialConsoleTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new DisableInteractiveSerialConsoleRequest()) - ->setName($formattedName); + $request = (new DisableInteractiveSerialConsoleRequest())->setName($formattedName); $response = $gapicClient->disableInteractiveSerialConsole($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -947,7 +957,10 @@ public function disableInteractiveSerialConsoleTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/DisableInteractiveSerialConsole', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.baremetalsolution.v2.BareMetalSolution/DisableInteractiveSerialConsole', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -993,17 +1006,19 @@ public function disableInteractiveSerialConsoleExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 DisableInteractiveSerialConsoleRequest()) - ->setName($formattedName); + $request = (new DisableInteractiveSerialConsoleRequest())->setName($formattedName); $response = $gapicClient->disableInteractiveSerialConsole($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1057,8 +1072,7 @@ public function enableInteractiveSerialConsoleTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new EnableInteractiveSerialConsoleRequest()) - ->setName($formattedName); + $request = (new EnableInteractiveSerialConsoleRequest())->setName($formattedName); $response = $gapicClient->enableInteractiveSerialConsole($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1068,7 +1082,10 @@ public function enableInteractiveSerialConsoleTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/EnableInteractiveSerialConsole', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.baremetalsolution.v2.BareMetalSolution/EnableInteractiveSerialConsole', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -1114,17 +1131,19 @@ public function enableInteractiveSerialConsoleExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 EnableInteractiveSerialConsoleRequest()) - ->setName($formattedName); + $request = (new EnableInteractiveSerialConsoleRequest())->setName($formattedName); $response = $gapicClient->enableInteractiveSerialConsole($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1178,8 +1197,7 @@ public function evictLunTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $request = (new EvictLunRequest()) - ->setName($formattedName); + $request = (new EvictLunRequest())->setName($formattedName); $response = $gapicClient->evictLun($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1235,17 +1253,19 @@ public function evictLunExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $request = (new EvictLunRequest()) - ->setName($formattedName); + $request = (new EvictLunRequest())->setName($formattedName); $response = $gapicClient->evictLun($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1299,8 +1319,7 @@ public function evictVolumeTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new EvictVolumeRequest()) - ->setName($formattedName); + $request = (new EvictVolumeRequest())->setName($formattedName); $response = $gapicClient->evictVolume($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1356,17 +1375,19 @@ public function evictVolumeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new EvictVolumeRequest()) - ->setName($formattedName); + $request = (new EvictVolumeRequest())->setName($formattedName); $response = $gapicClient->evictVolume($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1422,8 +1443,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(); @@ -1447,17 +1467,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 @@ -1498,8 +1520,7 @@ public function getLunTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $request = (new GetLunRequest()) - ->setName($formattedName); + $request = (new GetLunRequest())->setName($formattedName); $response = $gapicClient->getLun($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1523,17 +1544,19 @@ public function getLunExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->lunName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[LUN]'); - $request = (new GetLunRequest()) - ->setName($formattedName); + $request = (new GetLunRequest())->setName($formattedName); try { $gapicClient->getLun($request); // If the $gapicClient method call did not throw, fail the test @@ -1578,8 +1601,7 @@ public function getNetworkTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); - $request = (new GetNetworkRequest()) - ->setName($formattedName); + $request = (new GetNetworkRequest())->setName($formattedName); $response = $gapicClient->getNetwork($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1603,17 +1625,19 @@ public function getNetworkExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); - $request = (new GetNetworkRequest()) - ->setName($formattedName); + $request = (new GetNetworkRequest())->setName($formattedName); try { $gapicClient->getNetwork($request); // If the $gapicClient method call did not throw, fail the test @@ -1650,8 +1674,7 @@ public function getNfsShareTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $request = (new GetNfsShareRequest()) - ->setName($formattedName); + $request = (new GetNfsShareRequest())->setName($formattedName); $response = $gapicClient->getNfsShare($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1675,17 +1698,19 @@ public function getNfsShareExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); - $request = (new GetNfsShareRequest()) - ->setName($formattedName); + $request = (new GetNfsShareRequest())->setName($formattedName); try { $gapicClient->getNfsShare($request); // If the $gapicClient method call did not throw, fail the test @@ -1730,15 +1755,17 @@ public function getProvisioningConfigTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->provisioningConfigName('[PROJECT]', '[LOCATION]', '[PROVISIONING_CONFIG]'); - $request = (new GetProvisioningConfigRequest()) - ->setName($formattedName); + $request = (new GetProvisioningConfigRequest())->setName($formattedName); $response = $gapicClient->getProvisioningConfig($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.baremetalsolution.v2.BareMetalSolution/GetProvisioningConfig', $actualFuncCall); + $this->assertSame( + '/google.cloud.baremetalsolution.v2.BareMetalSolution/GetProvisioningConfig', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1755,17 +1782,19 @@ public function getProvisioningConfigExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->provisioningConfigName('[PROJECT]', '[LOCATION]', '[PROVISIONING_CONFIG]'); - $request = (new GetProvisioningConfigRequest()) - ->setName($formattedName); + $request = (new GetProvisioningConfigRequest())->setName($formattedName); try { $gapicClient->getProvisioningConfig($request); // If the $gapicClient method call did not throw, fail the test @@ -1820,8 +1849,7 @@ public function getVolumeTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new GetVolumeRequest()) - ->setName($formattedName); + $request = (new GetVolumeRequest())->setName($formattedName); $response = $gapicClient->getVolume($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1845,17 +1873,19 @@ public function getVolumeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new GetVolumeRequest()) - ->setName($formattedName); + $request = (new GetVolumeRequest())->setName($formattedName); try { $gapicClient->getVolume($request); // If the $gapicClient method call did not throw, fail the test @@ -1890,8 +1920,7 @@ public function getVolumeSnapshotTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $request = (new GetVolumeSnapshotRequest()) - ->setName($formattedName); + $request = (new GetVolumeSnapshotRequest())->setName($formattedName); $response = $gapicClient->getVolumeSnapshot($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1915,17 +1944,19 @@ public function getVolumeSnapshotExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $request = (new GetVolumeSnapshotRequest()) - ->setName($formattedName); + $request = (new GetVolumeSnapshotRequest())->setName($formattedName); try { $gapicClient->getVolumeSnapshot($request); // If the $gapicClient method call did not throw, fail the test @@ -1950,17 +1981,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()); @@ -1987,17 +2015,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 @@ -2022,17 +2052,14 @@ public function listLunsTest() // Mock response $nextPageToken = ''; $lunsElement = new Lun(); - $luns = [ - $lunsElement, - ]; + $luns = [$lunsElement]; $expectedResponse = new ListLunsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLuns($luns); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new ListLunsRequest()) - ->setParent($formattedParent); + $request = (new ListLunsRequest())->setParent($formattedParent); $response = $gapicClient->listLuns($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2059,17 +2086,19 @@ public function listLunsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new ListLunsRequest()) - ->setParent($formattedParent); + $request = (new ListLunsRequest())->setParent($formattedParent); try { $gapicClient->listLuns($request); // If the $gapicClient method call did not throw, fail the test @@ -2096,8 +2125,7 @@ public function listNetworkUsageTest() $transport->addResponse($expectedResponse); // Mock request $formattedLocation = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListNetworkUsageRequest()) - ->setLocation($formattedLocation); + $request = (new ListNetworkUsageRequest())->setLocation($formattedLocation); $response = $gapicClient->listNetworkUsage($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2121,17 +2149,19 @@ public function listNetworkUsageExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListNetworkUsageRequest()) - ->setLocation($formattedLocation); + $request = (new ListNetworkUsageRequest())->setLocation($formattedLocation); try { $gapicClient->listNetworkUsage($request); // If the $gapicClient method call did not throw, fail the test @@ -2156,17 +2186,14 @@ public function listNetworksTest() // Mock response $nextPageToken = ''; $networksElement = new Network(); - $networks = [ - $networksElement, - ]; + $networks = [$networksElement]; $expectedResponse = new ListNetworksResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setNetworks($networks); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListNetworksRequest()) - ->setParent($formattedParent); + $request = (new ListNetworksRequest())->setParent($formattedParent); $response = $gapicClient->listNetworks($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2193,17 +2220,19 @@ public function listNetworksExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListNetworksRequest()) - ->setParent($formattedParent); + $request = (new ListNetworksRequest())->setParent($formattedParent); try { $gapicClient->listNetworks($request); // If the $gapicClient method call did not throw, fail the test @@ -2228,17 +2257,14 @@ public function listNfsSharesTest() // Mock response $nextPageToken = ''; $nfsSharesElement = new NfsShare(); - $nfsShares = [ - $nfsSharesElement, - ]; + $nfsShares = [$nfsSharesElement]; $expectedResponse = new ListNfsSharesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setNfsShares($nfsShares); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListNfsSharesRequest()) - ->setParent($formattedParent); + $request = (new ListNfsSharesRequest())->setParent($formattedParent); $response = $gapicClient->listNfsShares($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2265,17 +2291,19 @@ public function listNfsSharesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListNfsSharesRequest()) - ->setParent($formattedParent); + $request = (new ListNfsSharesRequest())->setParent($formattedParent); try { $gapicClient->listNfsShares($request); // If the $gapicClient method call did not throw, fail the test @@ -2300,17 +2328,14 @@ public function listOSImagesTest() // Mock response $nextPageToken = ''; $osImagesElement = new OSImage(); - $osImages = [ - $osImagesElement, - ]; + $osImages = [$osImagesElement]; $expectedResponse = new ListOSImagesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setOsImages($osImages); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListOSImagesRequest()) - ->setParent($formattedParent); + $request = (new ListOSImagesRequest())->setParent($formattedParent); $response = $gapicClient->listOSImages($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2337,17 +2362,19 @@ public function listOSImagesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListOSImagesRequest()) - ->setParent($formattedParent); + $request = (new ListOSImagesRequest())->setParent($formattedParent); try { $gapicClient->listOSImages($request); // If the $gapicClient method call did not throw, fail the test @@ -2372,17 +2399,14 @@ public function listProvisioningQuotasTest() // Mock response $nextPageToken = ''; $provisioningQuotasElement = new ProvisioningQuota(); - $provisioningQuotas = [ - $provisioningQuotasElement, - ]; + $provisioningQuotas = [$provisioningQuotasElement]; $expectedResponse = new ListProvisioningQuotasResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setProvisioningQuotas($provisioningQuotas); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListProvisioningQuotasRequest()) - ->setParent($formattedParent); + $request = (new ListProvisioningQuotasRequest())->setParent($formattedParent); $response = $gapicClient->listProvisioningQuotas($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2392,7 +2416,10 @@ public function listProvisioningQuotasTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/ListProvisioningQuotas', $actualFuncCall); + $this->assertSame( + '/google.cloud.baremetalsolution.v2.BareMetalSolution/ListProvisioningQuotas', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -2409,17 +2436,19 @@ public function listProvisioningQuotasExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListProvisioningQuotasRequest()) - ->setParent($formattedParent); + $request = (new ListProvisioningQuotasRequest())->setParent($formattedParent); try { $gapicClient->listProvisioningQuotas($request); // If the $gapicClient method call did not throw, fail the test @@ -2444,17 +2473,14 @@ public function listSSHKeysTest() // Mock response $nextPageToken = ''; $sshKeysElement = new SSHKey(); - $sshKeys = [ - $sshKeysElement, - ]; + $sshKeys = [$sshKeysElement]; $expectedResponse = new ListSSHKeysResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSshKeys($sshKeys); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListSSHKeysRequest()) - ->setParent($formattedParent); + $request = (new ListSSHKeysRequest())->setParent($formattedParent); $response = $gapicClient->listSSHKeys($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2481,17 +2507,19 @@ public function listSSHKeysExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListSSHKeysRequest()) - ->setParent($formattedParent); + $request = (new ListSSHKeysRequest())->setParent($formattedParent); try { $gapicClient->listSSHKeys($request); // If the $gapicClient method call did not throw, fail the test @@ -2516,17 +2544,14 @@ public function listVolumeSnapshotsTest() // Mock response $nextPageToken = ''; $volumeSnapshotsElement = new VolumeSnapshot(); - $volumeSnapshots = [ - $volumeSnapshotsElement, - ]; + $volumeSnapshots = [$volumeSnapshotsElement]; $expectedResponse = new ListVolumeSnapshotsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setVolumeSnapshots($volumeSnapshots); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new ListVolumeSnapshotsRequest()) - ->setParent($formattedParent); + $request = (new ListVolumeSnapshotsRequest())->setParent($formattedParent); $response = $gapicClient->listVolumeSnapshots($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2553,17 +2578,19 @@ public function listVolumeSnapshotsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new ListVolumeSnapshotsRequest()) - ->setParent($formattedParent); + $request = (new ListVolumeSnapshotsRequest())->setParent($formattedParent); try { $gapicClient->listVolumeSnapshots($request); // If the $gapicClient method call did not throw, fail the test @@ -2588,17 +2615,14 @@ public function listVolumesTest() // Mock response $nextPageToken = ''; $volumesElement = new Volume(); - $volumes = [ - $volumesElement, - ]; + $volumes = [$volumesElement]; $expectedResponse = new ListVolumesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setVolumes($volumes); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListVolumesRequest()) - ->setParent($formattedParent); + $request = (new ListVolumesRequest())->setParent($formattedParent); $response = $gapicClient->listVolumes($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -2625,17 +2649,19 @@ public function listVolumesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListVolumesRequest()) - ->setParent($formattedParent); + $request = (new ListVolumesRequest())->setParent($formattedParent); try { $gapicClient->listVolumes($request); // If the $gapicClient method call did not throw, fail the test @@ -2683,9 +2709,7 @@ public function renameInstanceTest() // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); $newInstanceId = 'newInstanceId-179130138'; - $request = (new RenameInstanceRequest()) - ->setName($formattedName) - ->setNewInstanceId($newInstanceId); + $request = (new RenameInstanceRequest())->setName($formattedName)->setNewInstanceId($newInstanceId); $response = $gapicClient->renameInstance($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2711,19 +2735,20 @@ public function renameInstanceExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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]'); $newInstanceId = 'newInstanceId-179130138'; - $request = (new RenameInstanceRequest()) - ->setName($formattedName) - ->setNewInstanceId($newInstanceId); + $request = (new RenameInstanceRequest())->setName($formattedName)->setNewInstanceId($newInstanceId); try { $gapicClient->renameInstance($request); // If the $gapicClient method call did not throw, fail the test @@ -2769,9 +2794,7 @@ public function renameNetworkTest() // Mock request $formattedName = $gapicClient->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); $newNetworkId = 'newNetworkId-554751797'; - $request = (new RenameNetworkRequest()) - ->setName($formattedName) - ->setNewNetworkId($newNetworkId); + $request = (new RenameNetworkRequest())->setName($formattedName)->setNewNetworkId($newNetworkId); $response = $gapicClient->renameNetwork($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2797,19 +2820,20 @@ public function renameNetworkExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->networkName('[PROJECT]', '[LOCATION]', '[NETWORK]'); $newNetworkId = 'newNetworkId-554751797'; - $request = (new RenameNetworkRequest()) - ->setName($formattedName) - ->setNewNetworkId($newNetworkId); + $request = (new RenameNetworkRequest())->setName($formattedName)->setNewNetworkId($newNetworkId); try { $gapicClient->renameNetwork($request); // If the $gapicClient method call did not throw, fail the test @@ -2847,9 +2871,7 @@ public function renameNfsShareTest() // Mock request $formattedName = $gapicClient->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); $newNfsshareId = 'newNfsshareId814577687'; - $request = (new RenameNfsShareRequest()) - ->setName($formattedName) - ->setNewNfsshareId($newNfsshareId); + $request = (new RenameNfsShareRequest())->setName($formattedName)->setNewNfsshareId($newNfsshareId); $response = $gapicClient->renameNfsShare($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2875,19 +2897,20 @@ public function renameNfsShareExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->nFSShareName('[PROJECT]', '[LOCATION]', '[NFS_SHARE]'); $newNfsshareId = 'newNfsshareId814577687'; - $request = (new RenameNfsShareRequest()) - ->setName($formattedName) - ->setNewNfsshareId($newNfsshareId); + $request = (new RenameNfsShareRequest())->setName($formattedName)->setNewNfsshareId($newNfsshareId); try { $gapicClient->renameNfsShare($request); // If the $gapicClient method call did not throw, fail the test @@ -2943,9 +2966,7 @@ public function renameVolumeTest() // Mock request $formattedName = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); $newVolumeId = 'newVolumeId-468182911'; - $request = (new RenameVolumeRequest()) - ->setName($formattedName) - ->setNewVolumeId($newVolumeId); + $request = (new RenameVolumeRequest())->setName($formattedName)->setNewVolumeId($newVolumeId); $response = $gapicClient->renameVolume($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -2971,19 +2992,20 @@ public function renameVolumeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); $newVolumeId = 'newVolumeId-468182911'; - $request = (new RenameVolumeRequest()) - ->setName($formattedName) - ->setNewVolumeId($newVolumeId); + $request = (new RenameVolumeRequest())->setName($formattedName)->setNewVolumeId($newVolumeId); try { $gapicClient->renameVolume($request); // If the $gapicClient method call did not throw, fail the test @@ -3028,8 +3050,7 @@ public function resetInstanceTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new ResetInstanceRequest()) - ->setName($formattedName); + $request = (new ResetInstanceRequest())->setName($formattedName); $response = $gapicClient->resetInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3085,17 +3106,19 @@ public function resetInstanceExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ResetInstanceRequest()) - ->setName($formattedName); + $request = (new ResetInstanceRequest())->setName($formattedName); $response = $gapicClient->resetInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3177,8 +3200,7 @@ public function resizeVolumeTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedVolume = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new ResizeVolumeRequest()) - ->setVolume($formattedVolume); + $request = (new ResizeVolumeRequest())->setVolume($formattedVolume); $response = $gapicClient->resizeVolume($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3234,17 +3256,19 @@ public function resizeVolumeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $formattedVolume = $gapicClient->volumeName('[PROJECT]', '[LOCATION]', '[VOLUME]'); - $request = (new ResizeVolumeRequest()) - ->setVolume($formattedVolume); + $request = (new ResizeVolumeRequest())->setVolume($formattedVolume); $response = $gapicClient->resizeVolume($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3305,9 +3329,13 @@ public function restoreVolumeSnapshotTest() $completeOperation->setResponse($anyResponse); $operationsTransport->addResponse($completeOperation); // Mock request - $formattedVolumeSnapshot = $gapicClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $request = (new RestoreVolumeSnapshotRequest()) - ->setVolumeSnapshot($formattedVolumeSnapshot); + $formattedVolumeSnapshot = $gapicClient->volumeSnapshotName( + '[PROJECT]', + '[LOCATION]', + '[VOLUME]', + '[SNAPSHOT]' + ); + $request = (new RestoreVolumeSnapshotRequest())->setVolumeSnapshot($formattedVolumeSnapshot); $response = $gapicClient->restoreVolumeSnapshot($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3317,7 +3345,10 @@ public function restoreVolumeSnapshotTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/RestoreVolumeSnapshot', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.baremetalsolution.v2.BareMetalSolution/RestoreVolumeSnapshot', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getVolumeSnapshot(); $this->assertProtobufEquals($formattedVolumeSnapshot, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -3363,17 +3394,24 @@ public function restoreVolumeSnapshotExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 - $formattedVolumeSnapshot = $gapicClient->volumeSnapshotName('[PROJECT]', '[LOCATION]', '[VOLUME]', '[SNAPSHOT]'); - $request = (new RestoreVolumeSnapshotRequest()) - ->setVolumeSnapshot($formattedVolumeSnapshot); + $formattedVolumeSnapshot = $gapicClient->volumeSnapshotName( + '[PROJECT]', + '[LOCATION]', + '[VOLUME]', + '[SNAPSHOT]' + ); + $request = (new RestoreVolumeSnapshotRequest())->setVolumeSnapshot($formattedVolumeSnapshot); $response = $gapicClient->restoreVolumeSnapshot($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3427,8 +3465,7 @@ public function startInstanceTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new StartInstanceRequest()) - ->setName($formattedName); + $request = (new StartInstanceRequest())->setName($formattedName); $response = $gapicClient->startInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3484,17 +3521,19 @@ public function startInstanceExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 StartInstanceRequest()) - ->setName($formattedName); + $request = (new StartInstanceRequest())->setName($formattedName); $response = $gapicClient->startInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3548,8 +3587,7 @@ public function stopInstanceTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); - $request = (new StopInstanceRequest()) - ->setName($formattedName); + $request = (new StopInstanceRequest())->setName($formattedName); $response = $gapicClient->stopInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3605,17 +3643,19 @@ public function stopInstanceExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 StopInstanceRequest()) - ->setName($formattedName); + $request = (new StopInstanceRequest())->setName($formattedName); $response = $gapicClient->stopInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3661,7 +3701,10 @@ public function submitProvisioningConfigTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/SubmitProvisioningConfig', $actualFuncCall); + $this->assertSame( + '/google.cloud.baremetalsolution.v2.BareMetalSolution/SubmitProvisioningConfig', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getProvisioningConfig(); @@ -3680,12 +3723,15 @@ public function submitProvisioningConfigExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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]'); @@ -3757,8 +3803,7 @@ public function updateInstanceTest() $operationsTransport->addResponse($completeOperation); // Mock request $instance = new Instance(); - $request = (new UpdateInstanceRequest()) - ->setInstance($instance); + $request = (new UpdateInstanceRequest())->setInstance($instance); $response = $gapicClient->updateInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3814,17 +3859,19 @@ 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); // Mock request $instance = new Instance(); - $request = (new UpdateInstanceRequest()) - ->setInstance($instance); + $request = (new UpdateInstanceRequest())->setInstance($instance); $response = $gapicClient->updateInstance($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3896,8 +3943,7 @@ public function updateNetworkTest() $operationsTransport->addResponse($completeOperation); // Mock request $network = new Network(); - $request = (new UpdateNetworkRequest()) - ->setNetwork($network); + $request = (new UpdateNetworkRequest())->setNetwork($network); $response = $gapicClient->updateNetwork($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -3953,17 +3999,19 @@ public function updateNetworkExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $network = new Network(); - $request = (new UpdateNetworkRequest()) - ->setNetwork($network); + $request = (new UpdateNetworkRequest())->setNetwork($network); $response = $gapicClient->updateNetwork($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -4027,8 +4075,7 @@ public function updateNfsShareTest() $operationsTransport->addResponse($completeOperation); // Mock request $nfsShare = new NfsShare(); - $request = (new UpdateNfsShareRequest()) - ->setNfsShare($nfsShare); + $request = (new UpdateNfsShareRequest())->setNfsShare($nfsShare); $response = $gapicClient->updateNfsShare($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -4084,17 +4131,19 @@ public function updateNfsShareExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $nfsShare = new NfsShare(); - $request = (new UpdateNfsShareRequest()) - ->setNfsShare($nfsShare); + $request = (new UpdateNfsShareRequest())->setNfsShare($nfsShare); $response = $gapicClient->updateNfsShare($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -4158,7 +4207,10 @@ public function updateProvisioningConfigTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateProvisioningConfig', $actualFuncCall); + $this->assertSame( + '/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateProvisioningConfig', + $actualFuncCall + ); $actualValue = $actualRequestObject->getProvisioningConfig(); $this->assertProtobufEquals($provisioningConfig, $actualValue); $actualValue = $actualRequestObject->getUpdateMask(); @@ -4177,12 +4229,15 @@ public function updateProvisioningConfigExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $provisioningConfig = new ProvisioningConfig(); @@ -4262,8 +4317,7 @@ public function updateVolumeTest() $operationsTransport->addResponse($completeOperation); // Mock request $volume = new Volume(); - $request = (new UpdateVolumeRequest()) - ->setVolume($volume); + $request = (new UpdateVolumeRequest())->setVolume($volume); $response = $gapicClient->updateVolume($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -4319,17 +4373,19 @@ public function updateVolumeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $volume = new Volume(); - $request = (new UpdateVolumeRequest()) - ->setVolume($volume); + $request = (new UpdateVolumeRequest())->setVolume($volume); $response = $gapicClient->updateVolume($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -4391,12 +4447,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 { @@ -4423,9 +4482,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -4455,12 +4512,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 { @@ -4518,9 +4578,7 @@ public function createNfsShareAsyncTest() // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); $nfsShare = new NfsShare(); - $request = (new CreateNfsShareRequest()) - ->setParent($formattedParent) - ->setNfsShare($nfsShare); + $request = (new CreateNfsShareRequest())->setParent($formattedParent)->setNfsShare($nfsShare); $response = $gapicClient->createNfsShareAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); diff --git a/BigQueryAnalyticsHub/.OwlBot.yaml b/BigQueryAnalyticsHub/.OwlBot.yaml index e53f558202b..8e3dcb0a920 100644 --- a/BigQueryAnalyticsHub/.OwlBot.yaml +++ b/BigQueryAnalyticsHub/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/bigquery/analyticshub/v1/.*-php/(.*) - dest: /owl-bot-staging/BigQueryAnalyticsHub/v1/$1 + - source: /google/cloud/bigquery/analyticshub/(v1)/.*-php/(.*) + dest: /owl-bot-staging/BigQueryAnalyticsHub/$1/$2 api-name: BigQueryAnalyticsHub diff --git a/BigQueryAnalyticsHub/owlbot.py b/BigQueryAnalyticsHub/owlbot.py index 2d91fedc994..b07dd11f359 100644 --- a/BigQueryAnalyticsHub/owlbot.py +++ b/BigQueryAnalyticsHub/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2022 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/BigQueryAnalyticsHub/src/V1/AnalyticsHubServiceClient.php b/BigQueryAnalyticsHub/src/V1/AnalyticsHubServiceClient.php deleted file mode 100644 index f2a4942be7d..00000000000 --- a/BigQueryAnalyticsHub/src/V1/AnalyticsHubServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -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 * data_exchange resource. @@ -708,8 +729,10 @@ public function listListings(ListListingsRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function listOrgDataExchanges(ListOrgDataExchangesRequest $request, array $callOptions = []): PagedListResponse - { + public function listOrgDataExchanges( + ListOrgDataExchangesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListOrgDataExchanges', $request, $callOptions); } @@ -735,8 +758,10 @@ public function listOrgDataExchanges(ListOrgDataExchangesRequest $request, array * * @throws ApiException Thrown if the API call fails. */ - public function listSharedResourceSubscriptions(ListSharedResourceSubscriptionsRequest $request, array $callOptions = []): PagedListResponse - { + public function listSharedResourceSubscriptions( + ListSharedResourceSubscriptionsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListSharedResourceSubscriptions', $request, $callOptions); } @@ -818,8 +843,10 @@ public function refreshSubscription(RefreshSubscriptionRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function revokeSubscription(RevokeSubscriptionRequest $request, array $callOptions = []): RevokeSubscriptionResponse - { + public function revokeSubscription( + RevokeSubscriptionRequest $request, + array $callOptions = [] + ): RevokeSubscriptionResponse { return $this->startApiCall('RevokeSubscription', $request, $callOptions)->wait(); } @@ -872,8 +899,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function subscribeDataExchange(SubscribeDataExchangeRequest $request, array $callOptions = []): OperationResponse - { + public function subscribeDataExchange( + SubscribeDataExchangeRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('SubscribeDataExchange', $request, $callOptions)->wait(); } @@ -903,8 +932,10 @@ public function subscribeDataExchange(SubscribeDataExchangeRequest $request, arr * * @throws ApiException Thrown if the API call fails. */ - public function subscribeListing(SubscribeListingRequest $request, array $callOptions = []): SubscribeListingResponse - { + public function subscribeListing( + SubscribeListingRequest $request, + array $callOptions = [] + ): SubscribeListingResponse { return $this->startApiCall('SubscribeListing', $request, $callOptions)->wait(); } @@ -930,8 +961,10 @@ public function subscribeListing(SubscribeListingRequest $request, array $callOp * * @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/BigQueryAnalyticsHub/src/V1/CreateDataExchangeRequest.php b/BigQueryAnalyticsHub/src/V1/CreateDataExchangeRequest.php index 38bf7881984..b5c50a9432c 100644 --- a/BigQueryAnalyticsHub/src/V1/CreateDataExchangeRequest.php +++ b/BigQueryAnalyticsHub/src/V1/CreateDataExchangeRequest.php @@ -21,7 +21,7 @@ class CreateDataExchangeRequest 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 data exchange. * Must contain only Unicode letters, numbers (0-9), underscores (_). @@ -31,13 +31,13 @@ class CreateDataExchangeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string data_exchange_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $data_exchange_id = ''; + protected $data_exchange_id = ''; /** * Required. The data exchange to create. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.DataExchange data_exchange = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $data_exchange = null; + protected $data_exchange = null; /** * @param string $parent Required. The parent resource path of the data exchange. diff --git a/BigQueryAnalyticsHub/src/V1/CreateListingRequest.php b/BigQueryAnalyticsHub/src/V1/CreateListingRequest.php index cc31064d34d..e7fe7aa5bd6 100644 --- a/BigQueryAnalyticsHub/src/V1/CreateListingRequest.php +++ b/BigQueryAnalyticsHub/src/V1/CreateListingRequest.php @@ -21,7 +21,7 @@ class CreateListingRequest 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 listing to create. * Must contain only Unicode letters, numbers (0-9), underscores (_). @@ -31,13 +31,13 @@ class CreateListingRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string listing_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $listing_id = ''; + protected $listing_id = ''; /** * Required. The listing to create. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Listing listing = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $listing = null; + protected $listing = null; /** * @param string $parent Required. The parent resource path of the listing. diff --git a/BigQueryAnalyticsHub/src/V1/DataExchange.php b/BigQueryAnalyticsHub/src/V1/DataExchange.php index 19e16c6c2b3..08234c5823c 100644 --- a/BigQueryAnalyticsHub/src/V1/DataExchange.php +++ b/BigQueryAnalyticsHub/src/V1/DataExchange.php @@ -23,7 +23,7 @@ class DataExchange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Required. Human-readable display name of the data exchange. The display * name must contain only Unicode letters, numbers (0-9), underscores (_), @@ -32,7 +32,7 @@ class DataExchange 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 the data exchange. The description must not * contain Unicode non-characters as well as C0 and C1 control codes except @@ -42,26 +42,26 @@ class DataExchange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $description = ''; + protected $description = ''; /** * Optional. Email or URL of the primary point of contact of the data * exchange. Max Length: 1000 bytes. * * Generated from protobuf field string primary_contact = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $primary_contact = ''; + protected $primary_contact = ''; /** * Optional. Documentation describing the data exchange. * * Generated from protobuf field string documentation = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $documentation = ''; + protected $documentation = ''; /** * Output only. Number of listings contained in the data exchange. * * Generated from protobuf field int32 listing_count = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $listing_count = 0; + protected $listing_count = 0; /** * Optional. Base64 encoded image representing the data exchange. Max * Size: 3.0MiB Expected image dimensions are 512x512 pixels, however the API @@ -71,13 +71,13 @@ class DataExchange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes icon = 7 [(.google.api.field_behavior) = OPTIONAL]; */ - private $icon = ''; + protected $icon = ''; /** * Optional. Configurable data sharing environment option for a data exchange. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.SharingEnvironmentConfig sharing_environment_config = 8 [(.google.api.field_behavior) = OPTIONAL]; */ - private $sharing_environment_config = null; + protected $sharing_environment_config = null; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/DataProvider.php b/BigQueryAnalyticsHub/src/V1/DataProvider.php index c64522c9c9b..ae0efbfc4a0 100644 --- a/BigQueryAnalyticsHub/src/V1/DataProvider.php +++ b/BigQueryAnalyticsHub/src/V1/DataProvider.php @@ -20,14 +20,14 @@ class DataProvider extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $name = ''; + protected $name = ''; /** * Optional. Email or URL of the data provider. * Max Length: 1000 bytes. * * Generated from protobuf field string primary_contact = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $primary_contact = ''; + protected $primary_contact = ''; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/DeleteDataExchangeRequest.php b/BigQueryAnalyticsHub/src/V1/DeleteDataExchangeRequest.php index 7f4938644da..714ba25e08f 100644 --- a/BigQueryAnalyticsHub/src/V1/DeleteDataExchangeRequest.php +++ b/BigQueryAnalyticsHub/src/V1/DeleteDataExchangeRequest.php @@ -21,7 +21,7 @@ class DeleteDataExchangeRequest 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 full name of the data exchange resource that you want to diff --git a/BigQueryAnalyticsHub/src/V1/DeleteListingRequest.php b/BigQueryAnalyticsHub/src/V1/DeleteListingRequest.php index 007377c6cba..630e70a33f4 100644 --- a/BigQueryAnalyticsHub/src/V1/DeleteListingRequest.php +++ b/BigQueryAnalyticsHub/src/V1/DeleteListingRequest.php @@ -21,7 +21,7 @@ class DeleteListingRequest 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 listing to delete. diff --git a/BigQueryAnalyticsHub/src/V1/DeleteSubscriptionRequest.php b/BigQueryAnalyticsHub/src/V1/DeleteSubscriptionRequest.php index 9c9dfc05174..7bfd5a0f13f 100644 --- a/BigQueryAnalyticsHub/src/V1/DeleteSubscriptionRequest.php +++ b/BigQueryAnalyticsHub/src/V1/DeleteSubscriptionRequest.php @@ -21,7 +21,7 @@ class DeleteSubscriptionRequest 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 subscription to delete. diff --git a/BigQueryAnalyticsHub/src/V1/DestinationDataset.php b/BigQueryAnalyticsHub/src/V1/DestinationDataset.php index ec995578712..05c16ab5c7e 100644 --- a/BigQueryAnalyticsHub/src/V1/DestinationDataset.php +++ b/BigQueryAnalyticsHub/src/V1/DestinationDataset.php @@ -20,19 +20,19 @@ class DestinationDataset extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.DestinationDatasetReference dataset_reference = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $dataset_reference = null; + protected $dataset_reference = null; /** * Optional. A descriptive name for the dataset. * * Generated from protobuf field .google.protobuf.StringValue friendly_name = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $friendly_name = null; + protected $friendly_name = null; /** * Optional. A user-friendly description of the dataset. * * Generated from protobuf field .google.protobuf.StringValue description = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $description = null; + protected $description = null; /** * Optional. The labels associated with this dataset. You can use these * to organize and group your datasets. @@ -50,7 +50,7 @@ class DestinationDataset extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string location = 5 [(.google.api.field_behavior) = REQUIRED]; */ - private $location = ''; + protected $location = ''; /** * Constructor. @@ -146,7 +146,7 @@ public function clearFriendlyName() * Generated from protobuf field .google.protobuf.StringValue friendly_name = 2 [(.google.api.field_behavior) = OPTIONAL]; * @return string|null */ - public function getFriendlyNameValue() + public function getFriendlyNameUnwrapped() { return $this->readWrapperValue("friendly_name"); } @@ -175,7 +175,7 @@ public function setFriendlyName($var) * @param string|null $var * @return $this */ - public function setFriendlyNameValue($var) + public function setFriendlyNameUnwrapped($var) { $this->writeWrapperValue("friendly_name", $var); return $this;} @@ -209,7 +209,7 @@ public function clearDescription() * Generated from protobuf field .google.protobuf.StringValue description = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return string|null */ - public function getDescriptionValue() + public function getDescriptionUnwrapped() { return $this->readWrapperValue("description"); } @@ -238,7 +238,7 @@ public function setDescription($var) * @param string|null $var * @return $this */ - public function setDescriptionValue($var) + public function setDescriptionUnwrapped($var) { $this->writeWrapperValue("description", $var); return $this;} diff --git a/BigQueryAnalyticsHub/src/V1/DestinationDatasetReference.php b/BigQueryAnalyticsHub/src/V1/DestinationDatasetReference.php index d7620a788ab..0158d1b6c93 100644 --- a/BigQueryAnalyticsHub/src/V1/DestinationDatasetReference.php +++ b/BigQueryAnalyticsHub/src/V1/DestinationDatasetReference.php @@ -22,13 +22,13 @@ class DestinationDatasetReference extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string dataset_id = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $dataset_id = ''; + protected $dataset_id = ''; /** * Required. The ID of the project containing this dataset. * * Generated from protobuf field string project_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $project_id = ''; + protected $project_id = ''; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/Gapic/AnalyticsHubServiceGapicClient.php b/BigQueryAnalyticsHub/src/V1/Gapic/AnalyticsHubServiceGapicClient.php deleted file mode 100644 index f7904bcb9bb..00000000000 --- a/BigQueryAnalyticsHub/src/V1/Gapic/AnalyticsHubServiceGapicClient.php +++ /dev/null @@ -1,1946 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $dataExchangeId = 'data_exchange_id'; - * $dataExchange = new DataExchange(); - * $response = $analyticsHubServiceClient->createDataExchange($formattedParent, $dataExchangeId, $dataExchange); - * } finally { - * $analyticsHubServiceClient->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\AnalyticsHub\V1\Client\AnalyticsHubServiceClient}. - */ -class AnalyticsHubServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.bigquery.analyticshub.v1.AnalyticsHubService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'analyticshub.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'analyticshub.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 $dataExchangeNameTemplate; - - private static $datasetNameTemplate; - - private static $listingNameTemplate; - - private static $locationNameTemplate; - - private static $subscriptionNameTemplate; - - private static $tableNameTemplate; - - 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/analytics_hub_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/analytics_hub_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../resources/analytics_hub_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/analytics_hub_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getDataExchangeNameTemplate() - { - if (self::$dataExchangeNameTemplate == null) { - self::$dataExchangeNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/dataExchanges/{data_exchange}' - ); - } - - return self::$dataExchangeNameTemplate; - } - - private static function getDatasetNameTemplate() - { - if (self::$datasetNameTemplate == null) { - self::$datasetNameTemplate = new PathTemplate( - 'projects/{project}/datasets/{dataset}' - ); - } - - return self::$datasetNameTemplate; - } - - private static function getListingNameTemplate() - { - if (self::$listingNameTemplate == null) { - self::$listingNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}' - ); - } - - return self::$listingNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getSubscriptionNameTemplate() - { - if (self::$subscriptionNameTemplate == null) { - self::$subscriptionNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/subscriptions/{subscription}' - ); - } - - return self::$subscriptionNameTemplate; - } - - private static function getTableNameTemplate() - { - if (self::$tableNameTemplate == null) { - self::$tableNameTemplate = new PathTemplate( - 'projects/{project}/datasets/{dataset}/tables/{table}' - ); - } - - return self::$tableNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'dataExchange' => self::getDataExchangeNameTemplate(), - 'dataset' => self::getDatasetNameTemplate(), - 'listing' => self::getListingNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'subscription' => self::getSubscriptionNameTemplate(), - 'table' => self::getTableNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_exchange resource. - * - * @param string $project - * @param string $location - * @param string $dataExchange - * - * @return string The formatted data_exchange resource. - */ - public static function dataExchangeName($project, $location, $dataExchange) - { - return self::getDataExchangeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'data_exchange' => $dataExchange, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dataset - * resource. - * - * @param string $project - * @param string $dataset - * - * @return string The formatted dataset resource. - */ - public static function datasetName($project, $dataset) - { - return self::getDatasetNameTemplate()->render([ - 'project' => $project, - 'dataset' => $dataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a listing - * resource. - * - * @param string $project - * @param string $location - * @param string $dataExchange - * @param string $listing - * - * @return string The formatted listing resource. - */ - public static function listingName( - $project, - $location, - $dataExchange, - $listing - ) { - return self::getListingNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'data_exchange' => $dataExchange, - 'listing' => $listing, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName($project, $location) - { - return self::getLocationNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a subscription - * resource. - * - * @param string $project - * @param string $location - * @param string $subscription - * - * @return string The formatted subscription resource. - */ - public static function subscriptionName($project, $location, $subscription) - { - return self::getSubscriptionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'subscription' => $subscription, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a table - * resource. - * - * @param string $project - * @param string $dataset - * @param string $table - * - * @return string The formatted table resource. - */ - public static function tableName($project, $dataset, $table) - { - return self::getTableNameTemplate()->render([ - 'project' => $project, - 'dataset' => $dataset, - 'table' => $table, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataExchange: projects/{project}/locations/{location}/dataExchanges/{data_exchange} - * - dataset: projects/{project}/datasets/{dataset} - * - listing: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing} - * - location: projects/{project}/locations/{location} - * - subscription: projects/{project}/locations/{location}/subscriptions/{subscription} - * - table: projects/{project}/datasets/{dataset}/tables/{table} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($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 'analyticshub.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Creates a new data exchange. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedParent = $analyticsHubServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $dataExchangeId = 'data_exchange_id'; - * $dataExchange = new DataExchange(); - * $response = $analyticsHubServiceClient->createDataExchange($formattedParent, $dataExchangeId, $dataExchange); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource path of the data exchange. - * e.g. `projects/myproject/locations/US`. - * @param string $dataExchangeId Required. The ID of the data exchange. - * Must contain only Unicode letters, numbers (0-9), underscores (_). - * Should not use characters that require URL-escaping, or characters - * outside of ASCII, spaces. - * Max length: 100 bytes. - * @param DataExchange $dataExchange Required. The data exchange 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\BigQuery\AnalyticsHub\V1\DataExchange - * - * @throws ApiException if the remote call fails - */ - public function createDataExchange( - $parent, - $dataExchangeId, - $dataExchange, - array $optionalArgs = [] - ) { - $request = new CreateDataExchangeRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setDataExchangeId($dataExchangeId); - $request->setDataExchange($dataExchange); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateDataExchange', - DataExchange::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Creates a new listing. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedParent = $analyticsHubServiceClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - * $listingId = 'listing_id'; - * $listing = new Listing(); - * $response = $analyticsHubServiceClient->createListing($formattedParent, $listingId, $listing); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource path of the listing. - * e.g. `projects/myproject/locations/US/dataExchanges/123`. - * @param string $listingId Required. The ID of the listing to create. - * Must contain only Unicode letters, numbers (0-9), underscores (_). - * Should not use characters that require URL-escaping, or characters - * outside of ASCII, spaces. - * Max length: 100 bytes. - * @param Listing $listing Required. The listing 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\BigQuery\AnalyticsHub\V1\Listing - * - * @throws ApiException if the remote call fails - */ - public function createListing( - $parent, - $listingId, - $listing, - array $optionalArgs = [] - ) { - $request = new CreateListingRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setListingId($listingId); - $request->setListing($listing); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateListing', - Listing::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes an existing data exchange. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - * $analyticsHubServiceClient->deleteDataExchange($formattedName); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The full name of the data exchange resource that you want to - * delete. For example, `projects/myproject/locations/US/dataExchanges/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 deleteDataExchange($name, array $optionalArgs = []) - { - $request = new DeleteDataExchangeRequest(); - $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( - 'DeleteDataExchange', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a listing. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - * $analyticsHubServiceClient->deleteListing($formattedName); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the listing to delete. - * e.g. `projects/myproject/locations/US/dataExchanges/123/listings/456`. - * @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 deleteListing($name, array $optionalArgs = []) - { - $request = new DeleteListingRequest(); - $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( - 'DeleteListing', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a subscription. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - * $operationResponse = $analyticsHubServiceClient->deleteSubscription($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 = $analyticsHubServiceClient->deleteSubscription($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $analyticsHubServiceClient->resumeOperation($operationName, 'deleteSubscription'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the subscription to delete. - * e.g. projects/123/locations/US/subscriptions/456 - * @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 deleteSubscription($name, array $optionalArgs = []) - { - $request = new DeleteSubscriptionRequest(); - $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( - 'DeleteSubscription', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets the details of a data exchange. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - * $response = $analyticsHubServiceClient->getDataExchange($formattedName); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the data exchange. - * e.g. `projects/myproject/locations/US/dataExchanges/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\AnalyticsHub\V1\DataExchange - * - * @throws ApiException if the remote call fails - */ - public function getDataExchange($name, array $optionalArgs = []) - { - $request = new GetDataExchangeRequest(); - $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( - 'GetDataExchange', - DataExchange::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets the IAM policy. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $resource = 'resource'; - * $response = $analyticsHubServiceClient->getIamPolicy($resource); - * } finally { - * $analyticsHubServiceClient->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 the details of a listing. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - * $response = $analyticsHubServiceClient->getListing($formattedName); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The resource name of the listing. - * e.g. `projects/myproject/locations/US/dataExchanges/123/listings/456`. - * @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\AnalyticsHub\V1\Listing - * - * @throws ApiException if the remote call fails - */ - public function getListing($name, array $optionalArgs = []) - { - $request = new GetListingRequest(); - $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( - 'GetListing', - Listing::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets the details of a Subscription. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - * $response = $analyticsHubServiceClient->getSubscription($formattedName); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the subscription. - * e.g. projects/123/locations/US/subscriptions/456 - * @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\AnalyticsHub\V1\Subscription - * - * @throws ApiException if the remote call fails - */ - public function getSubscription($name, array $optionalArgs = []) - { - $request = new GetSubscriptionRequest(); - $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( - 'GetSubscription', - Subscription::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists all data exchanges in a given project and location. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedParent = $analyticsHubServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $analyticsHubServiceClient->listDataExchanges($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $analyticsHubServiceClient->listDataExchanges($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource path of the data exchanges. - * 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 listDataExchanges($parent, array $optionalArgs = []) - { - $request = new ListDataExchangesRequest(); - $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( - 'ListDataExchanges', - $optionalArgs, - ListDataExchangesResponse::class, - $request - ); - } - - /** - * Lists all listings in a given project and location. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedParent = $analyticsHubServiceClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - * // Iterate over pages of elements - * $pagedResponse = $analyticsHubServiceClient->listListings($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $analyticsHubServiceClient->listListings($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource path of the listing. - * e.g. `projects/myproject/locations/US/dataExchanges/123`. - * @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 listListings($parent, array $optionalArgs = []) - { - $request = new ListListingsRequest(); - $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( - 'ListListings', - $optionalArgs, - ListListingsResponse::class, - $request - ); - } - - /** - * Lists all data exchanges from projects in a given organization and - * location. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $organization = 'organization'; - * // Iterate over pages of elements - * $pagedResponse = $analyticsHubServiceClient->listOrgDataExchanges($organization); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $analyticsHubServiceClient->listOrgDataExchanges($organization); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $organization Required. The organization resource path of the projects containing - * DataExchanges. e.g. `organizations/myorg/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 listOrgDataExchanges( - $organization, - array $optionalArgs = [] - ) { - $request = new ListOrgDataExchangesRequest(); - $requestParamHeaders = []; - $request->setOrganization($organization); - $requestParamHeaders['organization'] = $organization; - 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( - 'ListOrgDataExchanges', - $optionalArgs, - ListOrgDataExchangesResponse::class, - $request - ); - } - - /** - * Lists all subscriptions on a given Data Exchange or Listing. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $resource = 'resource'; - * // Iterate over pages of elements - * $pagedResponse = $analyticsHubServiceClient->listSharedResourceSubscriptions($resource); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $analyticsHubServiceClient->listSharedResourceSubscriptions($resource); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $resource Required. Resource name of the requested target. This resource may be - * either a Listing or a DataExchange. e.g. - * projects/123/locations/US/dataExchanges/456 OR e.g. - * projects/123/locations/US/dataExchanges/456/listings/789 - * @param array $optionalArgs { - * Optional. - * - * @type bool $includeDeletedSubscriptions - * If selected, includes deleted subscriptions in the response - * (up to 63 days after deletion). - * @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 listSharedResourceSubscriptions( - $resource, - array $optionalArgs = [] - ) { - $request = new ListSharedResourceSubscriptionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['includeDeletedSubscriptions'])) { - $request->setIncludeDeletedSubscriptions( - $optionalArgs['includeDeletedSubscriptions'] - ); - } - - 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( - 'ListSharedResourceSubscriptions', - $optionalArgs, - ListSharedResourceSubscriptionsResponse::class, - $request - ); - } - - /** - * Lists all subscriptions in a given project and location. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedParent = $analyticsHubServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $analyticsHubServiceClient->listSubscriptions($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $analyticsHubServiceClient->listSubscriptions($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent resource path of the subscription. - * e.g. projects/myproject/locations/US - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * The filter expression may be used to filter by Data Exchange or Listing. - * @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 listSubscriptions($parent, array $optionalArgs = []) - { - $request = new ListSubscriptionsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListSubscriptions', - $optionalArgs, - ListSubscriptionsResponse::class, - $request - ); - } - - /** - * Refreshes a Subscription to a Data Exchange. A Data Exchange can become - * stale when a publisher adds or removes data. This is a long-running - * operation as it may create many linked datasets. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - * $operationResponse = $analyticsHubServiceClient->refreshSubscription($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 = $analyticsHubServiceClient->refreshSubscription($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $analyticsHubServiceClient->resumeOperation($operationName, 'refreshSubscription'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the Subscription to refresh. - * e.g. `projects/subscriberproject/locations/US/subscriptions/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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function refreshSubscription($name, array $optionalArgs = []) - { - $request = new RefreshSubscriptionRequest(); - $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( - 'RefreshSubscription', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Revokes a given subscription. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - * $response = $analyticsHubServiceClient->revokeSubscription($formattedName); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the subscription to revoke. - * e.g. projects/123/locations/US/subscriptions/456 - * @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\AnalyticsHub\V1\RevokeSubscriptionResponse - * - * @throws ApiException if the remote call fails - */ - public function revokeSubscription($name, array $optionalArgs = []) - { - $request = new RevokeSubscriptionRequest(); - $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( - 'RevokeSubscription', - RevokeSubscriptionResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Sets the IAM policy. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $analyticsHubServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $analyticsHubServiceClient->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(); - } - - /** - * Creates a Subscription to a Data Exchange. This is a long-running operation - * as it will create one or more linked datasets. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - * $formattedDestination = $analyticsHubServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $subscription = 'subscription'; - * $operationResponse = $analyticsHubServiceClient->subscribeDataExchange($formattedName, $formattedDestination, $subscription); - * $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 = $analyticsHubServiceClient->subscribeDataExchange($formattedName, $formattedDestination, $subscription); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $analyticsHubServiceClient->resumeOperation($operationName, 'subscribeDataExchange'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the Data Exchange. - * e.g. `projects/publisherproject/locations/US/dataExchanges/123` - * @param string $destination Required. The parent resource path of the Subscription. - * e.g. `projects/subscriberproject/locations/US` - * @param string $subscription Required. Name of the subscription to create. - * e.g. `subscription1` - * @param array $optionalArgs { - * Optional. - * - * @type string $subscriberContact - * Email of the subscriber. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 subscribeDataExchange( - $name, - $destination, - $subscription, - array $optionalArgs = [] - ) { - $request = new SubscribeDataExchangeRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setDestination($destination); - $request->setSubscription($subscription); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['subscriberContact'])) { - $request->setSubscriberContact($optionalArgs['subscriberContact']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'SubscribeDataExchange', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Subscribes to a listing. - * - * Currently, with Analytics Hub, you can create listings that - * reference only BigQuery datasets. - * Upon subscription to a listing for a BigQuery dataset, Analytics Hub - * creates a linked dataset in the subscriber's project. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $formattedName = $analyticsHubServiceClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - * $response = $analyticsHubServiceClient->subscribeListing($formattedName); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the listing that you want to subscribe to. - * e.g. `projects/myproject/locations/US/dataExchanges/123/listings/456`. - * @param array $optionalArgs { - * Optional. - * - * @type DestinationDataset $destinationDataset - * BigQuery destination dataset to create for the subscriber. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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\AnalyticsHub\V1\SubscribeListingResponse - * - * @throws ApiException if the remote call fails - */ - public function subscribeListing($name, array $optionalArgs = []) - { - $request = new SubscribeListingRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['destinationDataset'])) { - $request->setDestinationDataset( - $optionalArgs['destinationDataset'] - ); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'SubscribeListing', - SubscribeListingResponse::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Returns the permissions that a caller has. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $analyticsHubServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $analyticsHubServiceClient->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 an existing data exchange. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $dataExchange = new DataExchange(); - * $response = $analyticsHubServiceClient->updateDataExchange($updateMask, $dataExchange); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Field mask specifies the fields to update in the data exchange - * resource. The fields specified in the - * `updateMask` are relative to the resource and are not a full request. - * @param DataExchange $dataExchange Required. The data exchange to update. - * @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\AnalyticsHub\V1\DataExchange - * - * @throws ApiException if the remote call fails - */ - public function updateDataExchange( - $updateMask, - $dataExchange, - array $optionalArgs = [] - ) { - $request = new UpdateDataExchangeRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setDataExchange($dataExchange); - $requestParamHeaders['data_exchange.name'] = $dataExchange->getName(); - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'UpdateDataExchange', - DataExchange::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Updates an existing listing. - * - * Sample code: - * ``` - * $analyticsHubServiceClient = new AnalyticsHubServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $listing = new Listing(); - * $response = $analyticsHubServiceClient->updateListing($updateMask, $listing); - * } finally { - * $analyticsHubServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Field mask specifies the fields to update in the listing - * resource. The fields specified in the `updateMask` are relative to the - * resource and are not a full request. - * @param Listing $listing Required. The listing to update. - * @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\AnalyticsHub\V1\Listing - * - * @throws ApiException if the remote call fails - */ - public function updateListing( - $updateMask, - $listing, - array $optionalArgs = [] - ) { - $request = new UpdateListingRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setListing($listing); - $requestParamHeaders['listing.name'] = $listing->getName(); - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'UpdateListing', - Listing::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/BigQueryAnalyticsHub/src/V1/GetDataExchangeRequest.php b/BigQueryAnalyticsHub/src/V1/GetDataExchangeRequest.php index 4214a434e4a..ac579385d21 100644 --- a/BigQueryAnalyticsHub/src/V1/GetDataExchangeRequest.php +++ b/BigQueryAnalyticsHub/src/V1/GetDataExchangeRequest.php @@ -21,7 +21,7 @@ class GetDataExchangeRequest 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 data exchange. diff --git a/BigQueryAnalyticsHub/src/V1/GetListingRequest.php b/BigQueryAnalyticsHub/src/V1/GetListingRequest.php index f98730bac8c..a8e2c252396 100644 --- a/BigQueryAnalyticsHub/src/V1/GetListingRequest.php +++ b/BigQueryAnalyticsHub/src/V1/GetListingRequest.php @@ -21,7 +21,7 @@ class GetListingRequest 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 listing. diff --git a/BigQueryAnalyticsHub/src/V1/GetSubscriptionRequest.php b/BigQueryAnalyticsHub/src/V1/GetSubscriptionRequest.php index c466e33a868..8978d37ca8e 100644 --- a/BigQueryAnalyticsHub/src/V1/GetSubscriptionRequest.php +++ b/BigQueryAnalyticsHub/src/V1/GetSubscriptionRequest.php @@ -21,7 +21,7 @@ class GetSubscriptionRequest 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 subscription. diff --git a/BigQueryAnalyticsHub/src/V1/ListDataExchangesRequest.php b/BigQueryAnalyticsHub/src/V1/ListDataExchangesRequest.php index 7d079cef61e..fe9ae5f2f82 100644 --- a/BigQueryAnalyticsHub/src/V1/ListDataExchangesRequest.php +++ b/BigQueryAnalyticsHub/src/V1/ListDataExchangesRequest.php @@ -21,21 +21,21 @@ class ListDataExchangesRequest 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 in a single response page. Leverage * the page tokens to iterate through the entire collection. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Page token, returned by a previous call, to request the next page of * results. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The parent resource path of the data exchanges. diff --git a/BigQueryAnalyticsHub/src/V1/ListDataExchangesResponse.php b/BigQueryAnalyticsHub/src/V1/ListDataExchangesResponse.php index 0ddddeb9ace..fb8bbdccd26 100644 --- a/BigQueryAnalyticsHub/src/V1/ListDataExchangesResponse.php +++ b/BigQueryAnalyticsHub/src/V1/ListDataExchangesResponse.php @@ -26,7 +26,7 @@ class ListDataExchangesResponse 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/BigQueryAnalyticsHub/src/V1/ListListingsRequest.php b/BigQueryAnalyticsHub/src/V1/ListListingsRequest.php index 9cb0235be00..acff0532079 100644 --- a/BigQueryAnalyticsHub/src/V1/ListListingsRequest.php +++ b/BigQueryAnalyticsHub/src/V1/ListListingsRequest.php @@ -21,21 +21,21 @@ class ListListingsRequest 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 in a single response page. Leverage * the page tokens to iterate through the entire collection. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Page token, returned by a previous call, to request the next page of * results. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The parent resource path of the listing. diff --git a/BigQueryAnalyticsHub/src/V1/ListListingsResponse.php b/BigQueryAnalyticsHub/src/V1/ListListingsResponse.php index 4f110ab8a05..2a35739b95e 100644 --- a/BigQueryAnalyticsHub/src/V1/ListListingsResponse.php +++ b/BigQueryAnalyticsHub/src/V1/ListListingsResponse.php @@ -26,7 +26,7 @@ class ListListingsResponse 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/BigQueryAnalyticsHub/src/V1/ListOrgDataExchangesRequest.php b/BigQueryAnalyticsHub/src/V1/ListOrgDataExchangesRequest.php index 20bc13283dd..71eca67a2bd 100644 --- a/BigQueryAnalyticsHub/src/V1/ListOrgDataExchangesRequest.php +++ b/BigQueryAnalyticsHub/src/V1/ListOrgDataExchangesRequest.php @@ -22,21 +22,21 @@ class ListOrgDataExchangesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string organization = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $organization = ''; + protected $organization = ''; /** * The maximum number of results to return in a single response page. Leverage * the page tokens to iterate through the entire collection. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * Page token, returned by a previous call, to request the next page of * results. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $organization Required. The organization resource path of the projects containing diff --git a/BigQueryAnalyticsHub/src/V1/ListOrgDataExchangesResponse.php b/BigQueryAnalyticsHub/src/V1/ListOrgDataExchangesResponse.php index 48a2dd41a1b..d3378278669 100644 --- a/BigQueryAnalyticsHub/src/V1/ListOrgDataExchangesResponse.php +++ b/BigQueryAnalyticsHub/src/V1/ListOrgDataExchangesResponse.php @@ -27,7 +27,7 @@ class ListOrgDataExchangesResponse 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/BigQueryAnalyticsHub/src/V1/ListSharedResourceSubscriptionsRequest.php b/BigQueryAnalyticsHub/src/V1/ListSharedResourceSubscriptionsRequest.php index ff6b1ad1326..7868a7a4922 100644 --- a/BigQueryAnalyticsHub/src/V1/ListSharedResourceSubscriptionsRequest.php +++ b/BigQueryAnalyticsHub/src/V1/ListSharedResourceSubscriptionsRequest.php @@ -23,26 +23,26 @@ class ListSharedResourceSubscriptionsRequest extends \Google\Protobuf\Internal\M * * Generated from protobuf field string resource = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $resource = ''; + protected $resource = ''; /** * If selected, includes deleted subscriptions in the response * (up to 63 days after deletion). * * Generated from protobuf field bool include_deleted_subscriptions = 2; */ - private $include_deleted_subscriptions = false; + protected $include_deleted_subscriptions = false; /** * The maximum number of results to return in a single response page. * * Generated from protobuf field int32 page_size = 3; */ - private $page_size = 0; + protected $page_size = 0; /** * Page token, returned by a previous call. * * Generated from protobuf field string page_token = 4; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $resource Required. Resource name of the requested target. This resource may be diff --git a/BigQueryAnalyticsHub/src/V1/ListSharedResourceSubscriptionsResponse.php b/BigQueryAnalyticsHub/src/V1/ListSharedResourceSubscriptionsResponse.php index 17915a67d00..6dd58edfff9 100644 --- a/BigQueryAnalyticsHub/src/V1/ListSharedResourceSubscriptionsResponse.php +++ b/BigQueryAnalyticsHub/src/V1/ListSharedResourceSubscriptionsResponse.php @@ -26,7 +26,7 @@ class ListSharedResourceSubscriptionsResponse extends \Google\Protobuf\Internal\ * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/ListSubscriptionsRequest.php b/BigQueryAnalyticsHub/src/V1/ListSubscriptionsRequest.php index 6258d2337e2..bc3abe39037 100644 --- a/BigQueryAnalyticsHub/src/V1/ListSubscriptionsRequest.php +++ b/BigQueryAnalyticsHub/src/V1/ListSubscriptionsRequest.php @@ -21,25 +21,25 @@ class ListSubscriptionsRequest 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 filter expression may be used to filter by Data Exchange or Listing. * * Generated from protobuf field string filter = 2; */ - private $filter = ''; + protected $filter = ''; /** * The maximum number of results to return in a single response page. * * Generated from protobuf field int32 page_size = 3; */ - private $page_size = 0; + protected $page_size = 0; /** * Page token, returned by a previous call. * * Generated from protobuf field string page_token = 4; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The parent resource path of the subscription. diff --git a/BigQueryAnalyticsHub/src/V1/ListSubscriptionsResponse.php b/BigQueryAnalyticsHub/src/V1/ListSubscriptionsResponse.php index ac326a4dc5a..6e5f3062d8a 100644 --- a/BigQueryAnalyticsHub/src/V1/ListSubscriptionsResponse.php +++ b/BigQueryAnalyticsHub/src/V1/ListSubscriptionsResponse.php @@ -26,7 +26,7 @@ class ListSubscriptionsResponse 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/BigQueryAnalyticsHub/src/V1/Listing.php b/BigQueryAnalyticsHub/src/V1/Listing.php index 1cfc28cde92..17cc89b6c1f 100644 --- a/BigQueryAnalyticsHub/src/V1/Listing.php +++ b/BigQueryAnalyticsHub/src/V1/Listing.php @@ -24,7 +24,7 @@ class Listing extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Required. Human-readable display name of the listing. The display name must * contain only Unicode letters, numbers (0-9), underscores (_), dashes (-), @@ -33,7 +33,7 @@ class Listing 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. Short description of the listing. The description must not * contain Unicode non-characters and C0 and C1 control codes except tabs @@ -42,26 +42,26 @@ class Listing extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $description = ''; + protected $description = ''; /** * Optional. Email or URL of the primary point of contact of the listing. * Max Length: 1000 bytes. * * Generated from protobuf field string primary_contact = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $primary_contact = ''; + protected $primary_contact = ''; /** * Optional. Documentation describing the listing. * * Generated from protobuf field string documentation = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $documentation = ''; + protected $documentation = ''; /** * Output only. Current state of the listing. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Listing.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Optional. Base64 encoded image representing the listing. Max Size: 3.0MiB * Expected image dimensions are 512x512 pixels, however the API only @@ -71,13 +71,13 @@ class Listing extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes icon = 8 [(.google.api.field_behavior) = OPTIONAL]; */ - private $icon = ''; + protected $icon = ''; /** * Optional. Details of the data provider who owns the source data. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.DataProvider data_provider = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - private $data_provider = null; + protected $data_provider = null; /** * Optional. Categories of the listing. Up to two categories are allowed. * @@ -90,7 +90,7 @@ class Listing extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Publisher publisher = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $publisher = null; + protected $publisher = null; /** * Optional. Email or URL of the request access of the listing. * Subscribers can use this reference to request access. @@ -98,14 +98,14 @@ class Listing extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_access = 12 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_access = ''; + protected $request_access = ''; /** * Optional. If set, restricted export configuration will be propagated and * enforced on the linked dataset. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Listing.RestrictedExportConfig restricted_export_config = 13 [(.google.api.field_behavior) = OPTIONAL]; */ - private $restricted_export_config = null; + protected $restricted_export_config = null; protected $source; /** diff --git a/BigQueryAnalyticsHub/src/V1/Listing/BigQueryDatasetSource.php b/BigQueryAnalyticsHub/src/V1/Listing/BigQueryDatasetSource.php index 1c4e6715554..935ff334f2a 100644 --- a/BigQueryAnalyticsHub/src/V1/Listing/BigQueryDatasetSource.php +++ b/BigQueryAnalyticsHub/src/V1/Listing/BigQueryDatasetSource.php @@ -27,7 +27,7 @@ class BigQueryDatasetSource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string dataset = 1 [(.google.api.resource_reference) = { */ - private $dataset = ''; + protected $dataset = ''; /** * Optional. Resources in this dataset that are selectively shared. * If this field is empty, then the entire dataset (all resources) are diff --git a/BigQueryAnalyticsHub/src/V1/Listing/RestrictedExportConfig.php b/BigQueryAnalyticsHub/src/V1/Listing/RestrictedExportConfig.php index be4f407f77d..00efaf63589 100644 --- a/BigQueryAnalyticsHub/src/V1/Listing/RestrictedExportConfig.php +++ b/BigQueryAnalyticsHub/src/V1/Listing/RestrictedExportConfig.php @@ -21,21 +21,21 @@ class RestrictedExportConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enabled = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $enabled = false; + protected $enabled = false; /** * Output only. If true, restrict direct table access(read * api/tabledata.list) on linked table. * * Generated from protobuf field bool restrict_direct_table_access = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $restrict_direct_table_access = false; + protected $restrict_direct_table_access = false; /** * Optional. If true, restrict export of query result derived from * restricted linked dataset table. * * Generated from protobuf field bool restrict_query_result = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $restrict_query_result = false; + protected $restrict_query_result = false; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/OperationMetadata.php b/BigQueryAnalyticsHub/src/V1/OperationMetadata.php index 2210b1d5218..8f1689b049e 100644 --- a/BigQueryAnalyticsHub/src/V1/OperationMetadata.php +++ b/BigQueryAnalyticsHub/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/BigQueryAnalyticsHub/src/V1/Publisher.php b/BigQueryAnalyticsHub/src/V1/Publisher.php index ed9c333f237..7ee643e5a79 100644 --- a/BigQueryAnalyticsHub/src/V1/Publisher.php +++ b/BigQueryAnalyticsHub/src/V1/Publisher.php @@ -20,14 +20,14 @@ class Publisher extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $name = ''; + protected $name = ''; /** * Optional. Email or URL of the listing publisher. * Max Length: 1000 bytes. * * Generated from protobuf field string primary_contact = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $primary_contact = ''; + protected $primary_contact = ''; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/RefreshSubscriptionRequest.php b/BigQueryAnalyticsHub/src/V1/RefreshSubscriptionRequest.php index 0f029f1d596..f9822739ea3 100644 --- a/BigQueryAnalyticsHub/src/V1/RefreshSubscriptionRequest.php +++ b/BigQueryAnalyticsHub/src/V1/RefreshSubscriptionRequest.php @@ -21,7 +21,7 @@ class RefreshSubscriptionRequest 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 Subscription to refresh. diff --git a/BigQueryAnalyticsHub/src/V1/RefreshSubscriptionResponse.php b/BigQueryAnalyticsHub/src/V1/RefreshSubscriptionResponse.php index a33a6fe55f5..baa3de8019f 100644 --- a/BigQueryAnalyticsHub/src/V1/RefreshSubscriptionResponse.php +++ b/BigQueryAnalyticsHub/src/V1/RefreshSubscriptionResponse.php @@ -20,7 +20,7 @@ class RefreshSubscriptionResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Subscription subscription = 1; */ - private $subscription = null; + protected $subscription = null; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/RevokeSubscriptionRequest.php b/BigQueryAnalyticsHub/src/V1/RevokeSubscriptionRequest.php index ba98b2fc13d..1cc4e2365c1 100644 --- a/BigQueryAnalyticsHub/src/V1/RevokeSubscriptionRequest.php +++ b/BigQueryAnalyticsHub/src/V1/RevokeSubscriptionRequest.php @@ -21,7 +21,7 @@ class RevokeSubscriptionRequest 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 subscription to revoke. diff --git a/BigQueryAnalyticsHub/src/V1/SharingEnvironmentConfig/DcrExchangeConfig.php b/BigQueryAnalyticsHub/src/V1/SharingEnvironmentConfig/DcrExchangeConfig.php index 423b698969f..9ec7bfaf5f5 100644 --- a/BigQueryAnalyticsHub/src/V1/SharingEnvironmentConfig/DcrExchangeConfig.php +++ b/BigQueryAnalyticsHub/src/V1/SharingEnvironmentConfig/DcrExchangeConfig.php @@ -25,7 +25,7 @@ class DcrExchangeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool single_selected_resource_sharing_restriction = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $single_selected_resource_sharing_restriction = null; + protected $single_selected_resource_sharing_restriction = null; /** * Output only. If True, when subscribing to this DCR, it will create only * one linked dataset containing all resources shared within the @@ -35,7 +35,7 @@ class DcrExchangeConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool single_linked_dataset_per_cleanroom = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $single_linked_dataset_per_cleanroom = null; + protected $single_linked_dataset_per_cleanroom = null; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/SubscribeDataExchangeRequest.php b/BigQueryAnalyticsHub/src/V1/SubscribeDataExchangeRequest.php index 892b6fb69f3..3647f2fefce 100644 --- a/BigQueryAnalyticsHub/src/V1/SubscribeDataExchangeRequest.php +++ b/BigQueryAnalyticsHub/src/V1/SubscribeDataExchangeRequest.php @@ -21,27 +21,27 @@ class SubscribeDataExchangeRequest 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 parent resource path of the Subscription. * e.g. `projects/subscriberproject/locations/US` * * Generated from protobuf field string destination = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $destination = ''; + protected $destination = ''; /** * Required. Name of the subscription to create. * e.g. `subscription1` * * Generated from protobuf field string subscription = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $subscription = ''; + protected $subscription = ''; /** * Email of the subscriber. * * Generated from protobuf field string subscriber_contact = 3; */ - private $subscriber_contact = ''; + protected $subscriber_contact = ''; /** * @param string $name Required. Resource name of the Data Exchange. diff --git a/BigQueryAnalyticsHub/src/V1/SubscribeDataExchangeResponse.php b/BigQueryAnalyticsHub/src/V1/SubscribeDataExchangeResponse.php index 402a69841db..f9c149b1158 100644 --- a/BigQueryAnalyticsHub/src/V1/SubscribeDataExchangeResponse.php +++ b/BigQueryAnalyticsHub/src/V1/SubscribeDataExchangeResponse.php @@ -20,7 +20,7 @@ class SubscribeDataExchangeResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Subscription subscription = 1; */ - private $subscription = null; + protected $subscription = null; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/SubscribeListingRequest.php b/BigQueryAnalyticsHub/src/V1/SubscribeListingRequest.php index 7fd3af2309c..c6041fe7665 100644 --- a/BigQueryAnalyticsHub/src/V1/SubscribeListingRequest.php +++ b/BigQueryAnalyticsHub/src/V1/SubscribeListingRequest.php @@ -21,7 +21,7 @@ class SubscribeListingRequest 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 = ''; protected $destination; /** diff --git a/BigQueryAnalyticsHub/src/V1/SubscribeListingResponse.php b/BigQueryAnalyticsHub/src/V1/SubscribeListingResponse.php index 0f501a40d9f..25398a642d6 100644 --- a/BigQueryAnalyticsHub/src/V1/SubscribeListingResponse.php +++ b/BigQueryAnalyticsHub/src/V1/SubscribeListingResponse.php @@ -20,7 +20,7 @@ class SubscribeListingResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Subscription subscription = 1; */ - private $subscription = null; + protected $subscription = null; /** * Constructor. diff --git a/BigQueryAnalyticsHub/src/V1/Subscription.php b/BigQueryAnalyticsHub/src/V1/Subscription.php index 063eb9db78e..773d68ea160 100644 --- a/BigQueryAnalyticsHub/src/V1/Subscription.php +++ b/BigQueryAnalyticsHub/src/V1/Subscription.php @@ -23,37 +23,37 @@ class Subscription extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $name = ''; + protected $name = ''; /** * Output only. Timestamp when the subscription was created. * * Generated from protobuf field .google.protobuf.Timestamp creation_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $creation_time = null; + protected $creation_time = null; /** * Output only. Timestamp when the subscription was last modified. * * Generated from protobuf field .google.protobuf.Timestamp last_modify_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $last_modify_time = null; + protected $last_modify_time = null; /** * Output only. Organization of the project this subscription belongs to. * * Generated from protobuf field string organization_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $organization_id = ''; + protected $organization_id = ''; /** * Output only. Display name of the project of this subscription. * * Generated from protobuf field string organization_display_name = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $organization_display_name = ''; + protected $organization_display_name = ''; /** * Output only. Current state of the subscription. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Subscription.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. Map of listing resource names to associated linked resource, * e.g. projects/123/locations/US/dataExchanges/456/listings/789 @@ -70,7 +70,7 @@ class Subscription extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string subscriber_contact = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $subscriber_contact = ''; + protected $subscriber_contact = ''; protected $resource_name; /** diff --git a/BigQueryAnalyticsHub/src/V1/UpdateDataExchangeRequest.php b/BigQueryAnalyticsHub/src/V1/UpdateDataExchangeRequest.php index 59db9872013..a39b0308867 100644 --- a/BigQueryAnalyticsHub/src/V1/UpdateDataExchangeRequest.php +++ b/BigQueryAnalyticsHub/src/V1/UpdateDataExchangeRequest.php @@ -22,13 +22,13 @@ class UpdateDataExchangeRequest 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 data exchange to update. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.DataExchange data_exchange = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $data_exchange = null; + protected $data_exchange = null; /** * @param \Google\Cloud\BigQuery\AnalyticsHub\V1\DataExchange $dataExchange Required. The data exchange to update. diff --git a/BigQueryAnalyticsHub/src/V1/UpdateListingRequest.php b/BigQueryAnalyticsHub/src/V1/UpdateListingRequest.php index dc2e1eb3c51..d890cb88deb 100644 --- a/BigQueryAnalyticsHub/src/V1/UpdateListingRequest.php +++ b/BigQueryAnalyticsHub/src/V1/UpdateListingRequest.php @@ -22,13 +22,13 @@ class UpdateListingRequest 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 listing to update. * * Generated from protobuf field .google.cloud.bigquery.analyticshub.v1.Listing listing = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $listing = null; + protected $listing = null; /** * @param \Google\Cloud\BigQuery\AnalyticsHub\V1\Listing $listing Required. The listing to update. diff --git a/BigQueryAnalyticsHub/tests/Unit/V1/AnalyticsHubServiceClientTest.php b/BigQueryAnalyticsHub/tests/Unit/V1/AnalyticsHubServiceClientTest.php deleted file mode 100644 index fd109d0e4a1..00000000000 --- a/BigQueryAnalyticsHub/tests/Unit/V1/AnalyticsHubServiceClientTest.php +++ /dev/null @@ -1,1748 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return AnalyticsHubServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new AnalyticsHubServiceClient($options); - } - - /** @test */ - public function createDataExchangeTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $primaryContact = 'primaryContact203339491'; - $documentation = 'documentation1587405498'; - $listingCount = 1101038700; - $icon = '121'; - $expectedResponse = new DataExchange(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPrimaryContact($primaryContact); - $expectedResponse->setDocumentation($documentation); - $expectedResponse->setListingCount($listingCount); - $expectedResponse->setIcon($icon); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $dataExchangeId = 'dataExchangeId1402219426'; - $dataExchange = new DataExchange(); - $dataExchangeDisplayName = 'dataExchangeDisplayName-1195270080'; - $dataExchange->setDisplayName($dataExchangeDisplayName); - $response = $gapicClient->createDataExchange($formattedParent, $dataExchangeId, $dataExchange); - $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.analyticshub.v1.AnalyticsHubService/CreateDataExchange', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getDataExchangeId(); - $this->assertProtobufEquals($dataExchangeId, $actualValue); - $actualValue = $actualRequestObject->getDataExchange(); - $this->assertProtobufEquals($dataExchange, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createDataExchangeExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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]'); - $dataExchangeId = 'dataExchangeId1402219426'; - $dataExchange = new DataExchange(); - $dataExchangeDisplayName = 'dataExchangeDisplayName-1195270080'; - $dataExchange->setDisplayName($dataExchangeDisplayName); - try { - $gapicClient->createDataExchange($formattedParent, $dataExchangeId, $dataExchange); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createListingTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $primaryContact = 'primaryContact203339491'; - $documentation = 'documentation1587405498'; - $icon = '121'; - $requestAccess = 'requestAccess2059178260'; - $expectedResponse = new Listing(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPrimaryContact($primaryContact); - $expectedResponse->setDocumentation($documentation); - $expectedResponse->setIcon($icon); - $expectedResponse->setRequestAccess($requestAccess); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $listingId = 'listingId988969142'; - $listing = new Listing(); - $listingDisplayName = 'listingDisplayName293456201'; - $listing->setDisplayName($listingDisplayName); - $listingBigqueryDataset = new BigQueryDatasetSource(); - $listing->setBigqueryDataset($listingBigqueryDataset); - $response = $gapicClient->createListing($formattedParent, $listingId, $listing); - $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.analyticshub.v1.AnalyticsHubService/CreateListing', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getListingId(); - $this->assertProtobufEquals($listingId, $actualValue); - $actualValue = $actualRequestObject->getListing(); - $this->assertProtobufEquals($listing, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createListingExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $listingId = 'listingId988969142'; - $listing = new Listing(); - $listingDisplayName = 'listingDisplayName293456201'; - $listing->setDisplayName($listingDisplayName); - $listingBigqueryDataset = new BigQueryDatasetSource(); - $listing->setBigqueryDataset($listingBigqueryDataset); - try { - $gapicClient->createListing($formattedParent, $listingId, $listing); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteDataExchangeTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $gapicClient->deleteDataExchange($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteDataExchange', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteDataExchangeExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - try { - $gapicClient->deleteDataExchange($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 deleteListingTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $gapicClient->deleteListing($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteListing', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteListingExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - try { - $gapicClient->deleteListing($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 deleteSubscriptionTest() - { - $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/deleteSubscriptionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteSubscriptionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $response = $gapicClient->deleteSubscription($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.bigquery.analyticshub.v1.AnalyticsHubService/DeleteSubscription', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteSubscriptionTest'); - $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 deleteSubscriptionExceptionTest() - { - $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/deleteSubscriptionTest'); - $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->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $response = $gapicClient->deleteSubscription($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteSubscriptionTest'); - 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 getDataExchangeTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $primaryContact = 'primaryContact203339491'; - $documentation = 'documentation1587405498'; - $listingCount = 1101038700; - $icon = '121'; - $expectedResponse = new DataExchange(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPrimaryContact($primaryContact); - $expectedResponse->setDocumentation($documentation); - $expectedResponse->setListingCount($listingCount); - $expectedResponse->setIcon($icon); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $response = $gapicClient->getDataExchange($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.analyticshub.v1.AnalyticsHubService/GetDataExchange', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getDataExchangeExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - try { - $gapicClient->getDataExchange($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.bigquery.analyticshub.v1.AnalyticsHubService/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 getListingTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $primaryContact = 'primaryContact203339491'; - $documentation = 'documentation1587405498'; - $icon = '121'; - $requestAccess = 'requestAccess2059178260'; - $expectedResponse = new Listing(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPrimaryContact($primaryContact); - $expectedResponse->setDocumentation($documentation); - $expectedResponse->setIcon($icon); - $expectedResponse->setRequestAccess($requestAccess); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $response = $gapicClient->getListing($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.analyticshub.v1.AnalyticsHubService/GetListing', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getListingExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - try { - $gapicClient->getListing($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 getSubscriptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $listing = 'listing181975684'; - $name2 = 'name2-1052831874'; - $organizationId = 'organizationId1326486439'; - $organizationDisplayName = 'organizationDisplayName1039600500'; - $subscriberContact = 'subscriberContact-975982775'; - $expectedResponse = new Subscription(); - $expectedResponse->setListing($listing); - $expectedResponse->setName($name2); - $expectedResponse->setOrganizationId($organizationId); - $expectedResponse->setOrganizationDisplayName($organizationDisplayName); - $expectedResponse->setSubscriberContact($subscriberContact); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $response = $gapicClient->getSubscription($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.analyticshub.v1.AnalyticsHubService/GetSubscription', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getSubscriptionExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - try { - $gapicClient->getSubscription($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 listDataExchangesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $dataExchangesElement = new DataExchange(); - $dataExchanges = [ - $dataExchangesElement, - ]; - $expectedResponse = new ListDataExchangesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setDataExchanges($dataExchanges); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listDataExchanges($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getDataExchanges()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListDataExchanges', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listDataExchangesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listDataExchanges($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 listListingsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $listingsElement = new Listing(); - $listings = [ - $listingsElement, - ]; - $expectedResponse = new ListListingsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setListings($listings); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $response = $gapicClient->listListings($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getListings()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListListings', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listListingsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - try { - $gapicClient->listListings($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 listOrgDataExchangesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $dataExchangesElement = new DataExchange(); - $dataExchanges = [ - $dataExchangesElement, - ]; - $expectedResponse = new ListOrgDataExchangesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setDataExchanges($dataExchanges); - $transport->addResponse($expectedResponse); - // Mock request - $organization = 'organization1178922291'; - $response = $gapicClient->listOrgDataExchanges($organization); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getDataExchanges()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListOrgDataExchanges', $actualFuncCall); - $actualValue = $actualRequestObject->getOrganization(); - $this->assertProtobufEquals($organization, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listOrgDataExchangesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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 - $organization = 'organization1178922291'; - try { - $gapicClient->listOrgDataExchanges($organization); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listSharedResourceSubscriptionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $sharedResourceSubscriptionsElement = new Subscription(); - $sharedResourceSubscriptions = [ - $sharedResourceSubscriptionsElement, - ]; - $expectedResponse = new ListSharedResourceSubscriptionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSharedResourceSubscriptions($sharedResourceSubscriptions); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->listSharedResourceSubscriptions($resource); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSharedResourceSubscriptions()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSharedResourceSubscriptions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listSharedResourceSubscriptionsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listSharedResourceSubscriptions($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 listSubscriptionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $subscriptionsElement = new Subscription(); - $subscriptions = [ - $subscriptionsElement, - ]; - $expectedResponse = new ListSubscriptionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSubscriptions($subscriptions); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listSubscriptions($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSubscriptions()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSubscriptions', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listSubscriptionsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listSubscriptions($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 refreshSubscriptionTest() - { - $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/refreshSubscriptionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new RefreshSubscriptionResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/refreshSubscriptionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $response = $gapicClient->refreshSubscription($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.bigquery.analyticshub.v1.AnalyticsHubService/RefreshSubscription', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/refreshSubscriptionTest'); - $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 refreshSubscriptionExceptionTest() - { - $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/refreshSubscriptionTest'); - $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->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $response = $gapicClient->refreshSubscription($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/refreshSubscriptionTest'); - 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 revokeSubscriptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new RevokeSubscriptionResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $response = $gapicClient->revokeSubscription($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.analyticshub.v1.AnalyticsHubService/RevokeSubscription', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function revokeSubscriptionExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - try { - $gapicClient->revokeSubscription($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 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.bigquery.analyticshub.v1.AnalyticsHubService/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 subscribeDataExchangeTest() - { - $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/subscribeDataExchangeTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new SubscribeDataExchangeResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/subscribeDataExchangeTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $formattedDestination = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $subscription = 'subscription341203229'; - $response = $gapicClient->subscribeDataExchange($formattedName, $formattedDestination, $subscription); - $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.bigquery.analyticshub.v1.AnalyticsHubService/SubscribeDataExchange', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getDestination(); - $this->assertProtobufEquals($formattedDestination, $actualValue); - $actualValue = $actualApiRequestObject->getSubscription(); - $this->assertProtobufEquals($subscription, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/subscribeDataExchangeTest'); - $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 subscribeDataExchangeExceptionTest() - { - $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/subscribeDataExchangeTest'); - $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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $formattedDestination = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $subscription = 'subscription341203229'; - $response = $gapicClient->subscribeDataExchange($formattedName, $formattedDestination, $subscription); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/subscribeDataExchangeTest'); - 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 subscribeListingTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new SubscribeListingResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $response = $gapicClient->subscribeListing($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.analyticshub.v1.AnalyticsHubService/SubscribeListing', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function subscribeListingExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - try { - $gapicClient->subscribeListing($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.bigquery.analyticshub.v1.AnalyticsHubService/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 updateDataExchangeTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $primaryContact = 'primaryContact203339491'; - $documentation = 'documentation1587405498'; - $listingCount = 1101038700; - $icon = '121'; - $expectedResponse = new DataExchange(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPrimaryContact($primaryContact); - $expectedResponse->setDocumentation($documentation); - $expectedResponse->setListingCount($listingCount); - $expectedResponse->setIcon($icon); - $transport->addResponse($expectedResponse); - // Mock request - $updateMask = new FieldMask(); - $dataExchange = new DataExchange(); - $dataExchangeDisplayName = 'dataExchangeDisplayName-1195270080'; - $dataExchange->setDisplayName($dataExchangeDisplayName); - $response = $gapicClient->updateDataExchange($updateMask, $dataExchange); - $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.analyticshub.v1.AnalyticsHubService/UpdateDataExchange', $actualFuncCall); - $actualValue = $actualRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualRequestObject->getDataExchange(); - $this->assertProtobufEquals($dataExchange, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateDataExchangeExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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 - $updateMask = new FieldMask(); - $dataExchange = new DataExchange(); - $dataExchangeDisplayName = 'dataExchangeDisplayName-1195270080'; - $dataExchange->setDisplayName($dataExchangeDisplayName); - try { - $gapicClient->updateDataExchange($updateMask, $dataExchange); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateListingTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $primaryContact = 'primaryContact203339491'; - $documentation = 'documentation1587405498'; - $icon = '121'; - $requestAccess = 'requestAccess2059178260'; - $expectedResponse = new Listing(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); - $expectedResponse->setPrimaryContact($primaryContact); - $expectedResponse->setDocumentation($documentation); - $expectedResponse->setIcon($icon); - $expectedResponse->setRequestAccess($requestAccess); - $transport->addResponse($expectedResponse); - // Mock request - $updateMask = new FieldMask(); - $listing = new Listing(); - $listingDisplayName = 'listingDisplayName293456201'; - $listing->setDisplayName($listingDisplayName); - $listingBigqueryDataset = new BigQueryDatasetSource(); - $listing->setBigqueryDataset($listingBigqueryDataset); - $response = $gapicClient->updateListing($updateMask, $listing); - $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.analyticshub.v1.AnalyticsHubService/UpdateListing', $actualFuncCall); - $actualValue = $actualRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualRequestObject->getListing(); - $this->assertProtobufEquals($listing, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateListingExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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 - $updateMask = new FieldMask(); - $listing = new Listing(); - $listingDisplayName = 'listingDisplayName293456201'; - $listing->setDisplayName($listingDisplayName); - $listingBigqueryDataset = new BigQueryDatasetSource(); - $listing->setBigqueryDataset($listingBigqueryDataset); - try { - $gapicClient->updateListing($updateMask, $listing); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->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/BigQueryAnalyticsHub/tests/Unit/V1/Client/AnalyticsHubServiceClientTest.php b/BigQueryAnalyticsHub/tests/Unit/V1/Client/AnalyticsHubServiceClientTest.php index 98900822cd8..79bff9443fd 100644 --- a/BigQueryAnalyticsHub/tests/Unit/V1/Client/AnalyticsHubServiceClientTest.php +++ b/BigQueryAnalyticsHub/tests/Unit/V1/Client/AnalyticsHubServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return AnalyticsHubServiceClient */ @@ -142,7 +144,10 @@ public function createDataExchangeTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/CreateDataExchange', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/CreateDataExchange', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getDataExchangeId(); @@ -163,12 +168,15 @@ public function createDataExchangeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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]'); @@ -257,12 +265,15 @@ public function createListingExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); @@ -302,14 +313,16 @@ public function deleteDataExchangeTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $request = (new DeleteDataExchangeRequest()) - ->setName($formattedName); + $request = (new DeleteDataExchangeRequest())->setName($formattedName); $gapicClient->deleteDataExchange($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteDataExchange', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteDataExchange', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -326,17 +339,19 @@ public function deleteDataExchangeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $request = (new DeleteDataExchangeRequest()) - ->setName($formattedName); + $request = (new DeleteDataExchangeRequest())->setName($formattedName); try { $gapicClient->deleteDataExchange($request); // If the $gapicClient method call did not throw, fail the test @@ -363,8 +378,7 @@ public function deleteListingTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $request = (new DeleteListingRequest()) - ->setName($formattedName); + $request = (new DeleteListingRequest())->setName($formattedName); $gapicClient->deleteListing($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -387,17 +401,19 @@ public function deleteListingExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $request = (new DeleteListingRequest()) - ->setName($formattedName); + $request = (new DeleteListingRequest())->setName($formattedName); try { $gapicClient->deleteListing($request); // If the $gapicClient method call did not throw, fail the test @@ -442,8 +458,7 @@ public function deleteSubscriptionTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $request = (new DeleteSubscriptionRequest()) - ->setName($formattedName); + $request = (new DeleteSubscriptionRequest())->setName($formattedName); $response = $gapicClient->deleteSubscription($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -453,7 +468,10 @@ public function deleteSubscriptionTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteSubscription', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteSubscription', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -499,17 +517,19 @@ public function deleteSubscriptionExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $request = (new DeleteSubscriptionRequest()) - ->setName($formattedName); + $request = (new DeleteSubscriptionRequest())->setName($formattedName); $response = $gapicClient->deleteSubscription($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -559,15 +579,17 @@ public function getDataExchangeTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $request = (new GetDataExchangeRequest()) - ->setName($formattedName); + $request = (new GetDataExchangeRequest())->setName($formattedName); $response = $gapicClient->getDataExchange($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.analyticshub.v1.AnalyticsHubService/GetDataExchange', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetDataExchange', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -584,17 +606,19 @@ public function getDataExchangeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $request = (new GetDataExchangeRequest()) - ->setName($formattedName); + $request = (new GetDataExchangeRequest())->setName($formattedName); try { $gapicClient->getDataExchange($request); // If the $gapicClient method call did not throw, fail the test @@ -625,8 +649,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(); @@ -650,17 +673,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 @@ -701,8 +726,7 @@ public function getListingTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $request = (new GetListingRequest()) - ->setName($formattedName); + $request = (new GetListingRequest())->setName($formattedName); $response = $gapicClient->getListing($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -726,17 +750,19 @@ public function getListingExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $request = (new GetListingRequest()) - ->setName($formattedName); + $request = (new GetListingRequest())->setName($formattedName); try { $gapicClient->getListing($request); // If the $gapicClient method call did not throw, fail the test @@ -773,15 +799,17 @@ public function getSubscriptionTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $request = (new GetSubscriptionRequest()) - ->setName($formattedName); + $request = (new GetSubscriptionRequest())->setName($formattedName); $response = $gapicClient->getSubscription($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.analyticshub.v1.AnalyticsHubService/GetSubscription', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetSubscription', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -798,17 +826,19 @@ public function getSubscriptionExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $request = (new GetSubscriptionRequest()) - ->setName($formattedName); + $request = (new GetSubscriptionRequest())->setName($formattedName); try { $gapicClient->getSubscription($request); // If the $gapicClient method call did not throw, fail the test @@ -833,17 +863,14 @@ public function listDataExchangesTest() // Mock response $nextPageToken = ''; $dataExchangesElement = new DataExchange(); - $dataExchanges = [ - $dataExchangesElement, - ]; + $dataExchanges = [$dataExchangesElement]; $expectedResponse = new ListDataExchangesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setDataExchanges($dataExchanges); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListDataExchangesRequest()) - ->setParent($formattedParent); + $request = (new ListDataExchangesRequest())->setParent($formattedParent); $response = $gapicClient->listDataExchanges($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -853,7 +880,10 @@ public function listDataExchangesTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListDataExchanges', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListDataExchanges', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -870,17 +900,19 @@ public function listDataExchangesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListDataExchangesRequest()) - ->setParent($formattedParent); + $request = (new ListDataExchangesRequest())->setParent($formattedParent); try { $gapicClient->listDataExchanges($request); // If the $gapicClient method call did not throw, fail the test @@ -905,17 +937,14 @@ public function listListingsTest() // Mock response $nextPageToken = ''; $listingsElement = new Listing(); - $listings = [ - $listingsElement, - ]; + $listings = [$listingsElement]; $expectedResponse = new ListListingsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setListings($listings); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $request = (new ListListingsRequest()) - ->setParent($formattedParent); + $request = (new ListListingsRequest())->setParent($formattedParent); $response = $gapicClient->listListings($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -942,17 +971,19 @@ public function listListingsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); - $request = (new ListListingsRequest()) - ->setParent($formattedParent); + $request = (new ListListingsRequest())->setParent($formattedParent); try { $gapicClient->listListings($request); // If the $gapicClient method call did not throw, fail the test @@ -977,17 +1008,14 @@ public function listOrgDataExchangesTest() // Mock response $nextPageToken = ''; $dataExchangesElement = new DataExchange(); - $dataExchanges = [ - $dataExchangesElement, - ]; + $dataExchanges = [$dataExchangesElement]; $expectedResponse = new ListOrgDataExchangesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setDataExchanges($dataExchanges); $transport->addResponse($expectedResponse); // Mock request $organization = 'organization1178922291'; - $request = (new ListOrgDataExchangesRequest()) - ->setOrganization($organization); + $request = (new ListOrgDataExchangesRequest())->setOrganization($organization); $response = $gapicClient->listOrgDataExchanges($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -997,7 +1025,10 @@ public function listOrgDataExchangesTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListOrgDataExchanges', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListOrgDataExchanges', + $actualFuncCall + ); $actualValue = $actualRequestObject->getOrganization(); $this->assertProtobufEquals($organization, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1014,17 +1045,19 @@ public function listOrgDataExchangesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $organization = 'organization1178922291'; - $request = (new ListOrgDataExchangesRequest()) - ->setOrganization($organization); + $request = (new ListOrgDataExchangesRequest())->setOrganization($organization); try { $gapicClient->listOrgDataExchanges($request); // If the $gapicClient method call did not throw, fail the test @@ -1049,17 +1082,14 @@ public function listSharedResourceSubscriptionsTest() // Mock response $nextPageToken = ''; $sharedResourceSubscriptionsElement = new Subscription(); - $sharedResourceSubscriptions = [ - $sharedResourceSubscriptionsElement, - ]; + $sharedResourceSubscriptions = [$sharedResourceSubscriptionsElement]; $expectedResponse = new ListSharedResourceSubscriptionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSharedResourceSubscriptions($sharedResourceSubscriptions); $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new ListSharedResourceSubscriptionsRequest()) - ->setResource($resource); + $request = (new ListSharedResourceSubscriptionsRequest())->setResource($resource); $response = $gapicClient->listSharedResourceSubscriptions($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1069,7 +1099,10 @@ public function listSharedResourceSubscriptionsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSharedResourceSubscriptions', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSharedResourceSubscriptions', + $actualFuncCall + ); $actualValue = $actualRequestObject->getResource(); $this->assertProtobufEquals($resource, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1086,17 +1119,19 @@ public function listSharedResourceSubscriptionsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListSharedResourceSubscriptionsRequest()) - ->setResource($resource); + $request = (new ListSharedResourceSubscriptionsRequest())->setResource($resource); try { $gapicClient->listSharedResourceSubscriptions($request); // If the $gapicClient method call did not throw, fail the test @@ -1121,17 +1156,14 @@ public function listSubscriptionsTest() // Mock response $nextPageToken = ''; $subscriptionsElement = new Subscription(); - $subscriptions = [ - $subscriptionsElement, - ]; + $subscriptions = [$subscriptionsElement]; $expectedResponse = new ListSubscriptionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSubscriptions($subscriptions); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListSubscriptionsRequest()) - ->setParent($formattedParent); + $request = (new ListSubscriptionsRequest())->setParent($formattedParent); $response = $gapicClient->listSubscriptions($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -1141,7 +1173,10 @@ public function listSubscriptionsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSubscriptions', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSubscriptions', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1158,17 +1193,19 @@ public function listSubscriptionsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListSubscriptionsRequest()) - ->setParent($formattedParent); + $request = (new ListSubscriptionsRequest())->setParent($formattedParent); try { $gapicClient->listSubscriptions($request); // If the $gapicClient method call did not throw, fail the test @@ -1213,8 +1250,7 @@ public function refreshSubscriptionTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $request = (new RefreshSubscriptionRequest()) - ->setName($formattedName); + $request = (new RefreshSubscriptionRequest())->setName($formattedName); $response = $gapicClient->refreshSubscription($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1224,7 +1260,10 @@ public function refreshSubscriptionTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/RefreshSubscription', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/RefreshSubscription', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -1270,17 +1309,19 @@ public function refreshSubscriptionExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $request = (new RefreshSubscriptionRequest()) - ->setName($formattedName); + $request = (new RefreshSubscriptionRequest())->setName($formattedName); $response = $gapicClient->refreshSubscription($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1316,15 +1357,17 @@ public function revokeSubscriptionTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $request = (new RevokeSubscriptionRequest()) - ->setName($formattedName); + $request = (new RevokeSubscriptionRequest())->setName($formattedName); $response = $gapicClient->revokeSubscription($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.analyticshub.v1.AnalyticsHubService/RevokeSubscription', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/RevokeSubscription', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1341,17 +1384,19 @@ public function revokeSubscriptionExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->subscriptionName('[PROJECT]', '[LOCATION]', '[SUBSCRIPTION]'); - $request = (new RevokeSubscriptionRequest()) - ->setName($formattedName); + $request = (new RevokeSubscriptionRequest())->setName($formattedName); try { $gapicClient->revokeSubscription($request); // If the $gapicClient method call did not throw, fail the test @@ -1383,9 +1428,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(); @@ -1411,19 +1454,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 @@ -1483,7 +1527,10 @@ public function subscribeDataExchangeTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SubscribeDataExchange', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SubscribeDataExchange', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $actualValue = $actualApiRequestObject->getDestination(); @@ -1533,12 +1580,15 @@ public function subscribeDataExchangeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->dataExchangeName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]'); @@ -1583,15 +1633,17 @@ public function subscribeListingTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $request = (new SubscribeListingRequest()) - ->setName($formattedName); + $request = (new SubscribeListingRequest())->setName($formattedName); $response = $gapicClient->subscribeListing($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.analyticshub.v1.AnalyticsHubService/SubscribeListing', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SubscribeListing', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -1608,17 +1660,19 @@ public function subscribeListingExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->listingName('[PROJECT]', '[LOCATION]', '[DATA_EXCHANGE]', '[LISTING]'); - $request = (new SubscribeListingRequest()) - ->setName($formattedName); + $request = (new SubscribeListingRequest())->setName($formattedName); try { $gapicClient->subscribeListing($request); // If the $gapicClient method call did not throw, fail the test @@ -1646,16 +1700,17 @@ 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(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/TestIamPermissions', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/TestIamPermissions', + $actualFuncCall + ); $actualValue = $actualRequestObject->getResource(); $this->assertProtobufEquals($resource, $actualValue); $actualValue = $actualRequestObject->getPermissions(); @@ -1674,19 +1729,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 @@ -1730,16 +1786,17 @@ public function updateDataExchangeTest() $dataExchange = new DataExchange(); $dataExchangeDisplayName = 'dataExchangeDisplayName-1195270080'; $dataExchange->setDisplayName($dataExchangeDisplayName); - $request = (new UpdateDataExchangeRequest()) - ->setUpdateMask($updateMask) - ->setDataExchange($dataExchange); + $request = (new UpdateDataExchangeRequest())->setUpdateMask($updateMask)->setDataExchange($dataExchange); $response = $gapicClient->updateDataExchange($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.analyticshub.v1.AnalyticsHubService/UpdateDataExchange', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/UpdateDataExchange', + $actualFuncCall + ); $actualValue = $actualRequestObject->getUpdateMask(); $this->assertProtobufEquals($updateMask, $actualValue); $actualValue = $actualRequestObject->getDataExchange(); @@ -1758,21 +1815,22 @@ public function updateDataExchangeExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $updateMask = new FieldMask(); $dataExchange = new DataExchange(); $dataExchangeDisplayName = 'dataExchangeDisplayName-1195270080'; $dataExchange->setDisplayName($dataExchangeDisplayName); - $request = (new UpdateDataExchangeRequest()) - ->setUpdateMask($updateMask) - ->setDataExchange($dataExchange); + $request = (new UpdateDataExchangeRequest())->setUpdateMask($updateMask)->setDataExchange($dataExchange); try { $gapicClient->updateDataExchange($request); // If the $gapicClient method call did not throw, fail the test @@ -1818,9 +1876,7 @@ public function updateListingTest() $listing->setDisplayName($listingDisplayName); $listingBigqueryDataset = new BigQueryDatasetSource(); $listing->setBigqueryDataset($listingBigqueryDataset); - $request = (new UpdateListingRequest()) - ->setUpdateMask($updateMask) - ->setListing($listing); + $request = (new UpdateListingRequest())->setUpdateMask($updateMask)->setListing($listing); $response = $gapicClient->updateListing($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1846,12 +1902,15 @@ public function updateListingExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 $updateMask = new FieldMask(); @@ -1860,9 +1919,7 @@ public function updateListingExceptionTest() $listing->setDisplayName($listingDisplayName); $listingBigqueryDataset = new BigQueryDatasetSource(); $listing->setBigqueryDataset($listingBigqueryDataset); - $request = (new UpdateListingRequest()) - ->setUpdateMask($updateMask) - ->setListing($listing); + $request = (new UpdateListingRequest())->setUpdateMask($updateMask)->setListing($listing); try { $gapicClient->updateListing($request); // If the $gapicClient method call did not throw, fail the test @@ -1917,7 +1974,10 @@ public function createDataExchangeAsyncTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/CreateDataExchange', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/CreateDataExchange', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getDataExchangeId(); diff --git a/BigQueryMigration/.OwlBot.yaml b/BigQueryMigration/.OwlBot.yaml index b43489331a4..4ca0cd5bfe2 100644 --- a/BigQueryMigration/.OwlBot.yaml +++ b/BigQueryMigration/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/bigquery/migration/v2/.*-php/(.*) - dest: /owl-bot-staging/BigQueryMigration/v2/$1 + - source: /google/cloud/bigquery/migration/(v2)/.*-php/(.*) + dest: /owl-bot-staging/BigQueryMigration/$1/$2 api-name: BigQueryMigration diff --git a/BigQueryMigration/owlbot.py b/BigQueryMigration/owlbot.py index bb460e5eea3..de35c2f7cea 100644 --- a/BigQueryMigration/owlbot.py +++ b/BigQueryMigration/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2022 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/BigQueryMigration/src/V2/Client/MigrationServiceClient.php b/BigQueryMigration/src/V2/Client/MigrationServiceClient.php index ccdf7100d5e..73ea0940ca7 100644 --- a/BigQueryMigration/src/V2/Client/MigrationServiceClient.php +++ b/BigQueryMigration/src/V2/Client/MigrationServiceClient.php @@ -1,6 +1,6 @@ render([ 'project' => $project, 'location' => $location, @@ -287,8 +289,10 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createMigrationWorkflow(CreateMigrationWorkflowRequest $request, array $callOptions = []): MigrationWorkflow - { + public function createMigrationWorkflow( + CreateMigrationWorkflowRequest $request, + array $callOptions = [] + ): MigrationWorkflow { return $this->startApiCall('CreateMigrationWorkflow', $request, $callOptions)->wait(); } @@ -365,8 +369,10 @@ public function getMigrationSubtask(GetMigrationSubtaskRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function getMigrationWorkflow(GetMigrationWorkflowRequest $request, array $callOptions = []): MigrationWorkflow - { + public function getMigrationWorkflow( + GetMigrationWorkflowRequest $request, + array $callOptions = [] + ): MigrationWorkflow { return $this->startApiCall('GetMigrationWorkflow', $request, $callOptions)->wait(); } @@ -392,8 +398,10 @@ public function getMigrationWorkflow(GetMigrationWorkflowRequest $request, array * * @throws ApiException Thrown if the API call fails. */ - public function listMigrationSubtasks(ListMigrationSubtasksRequest $request, array $callOptions = []): PagedListResponse - { + public function listMigrationSubtasks( + ListMigrationSubtasksRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListMigrationSubtasks', $request, $callOptions); } @@ -419,8 +427,10 @@ public function listMigrationSubtasks(ListMigrationSubtasksRequest $request, arr * * @throws ApiException Thrown if the API call fails. */ - public function listMigrationWorkflows(ListMigrationWorkflowsRequest $request, array $callOptions = []): PagedListResponse - { + public function listMigrationWorkflows( + ListMigrationWorkflowsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListMigrationWorkflows', $request, $callOptions); } diff --git a/BigQueryMigration/src/V2/CreateMigrationWorkflowRequest.php b/BigQueryMigration/src/V2/CreateMigrationWorkflowRequest.php index d673a137d99..cf86b9f22bb 100644 --- a/BigQueryMigration/src/V2/CreateMigrationWorkflowRequest.php +++ b/BigQueryMigration/src/V2/CreateMigrationWorkflowRequest.php @@ -21,13 +21,13 @@ class CreateMigrationWorkflowRequest 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 migration workflow to create. * * Generated from protobuf field .google.cloud.bigquery.migration.v2.MigrationWorkflow migration_workflow = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $migration_workflow = null; + protected $migration_workflow = null; /** * @param string $parent Required. The name of the project to which this migration workflow belongs. diff --git a/BigQueryMigration/src/V2/DeleteMigrationWorkflowRequest.php b/BigQueryMigration/src/V2/DeleteMigrationWorkflowRequest.php index ef69dd87435..8d1a839efb8 100644 --- a/BigQueryMigration/src/V2/DeleteMigrationWorkflowRequest.php +++ b/BigQueryMigration/src/V2/DeleteMigrationWorkflowRequest.php @@ -21,7 +21,7 @@ class DeleteMigrationWorkflowRequest 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 unique identifier for the migration workflow. diff --git a/BigQueryMigration/src/V2/ErrorDetail.php b/BigQueryMigration/src/V2/ErrorDetail.php index f69f764e18a..b12388d8d92 100644 --- a/BigQueryMigration/src/V2/ErrorDetail.php +++ b/BigQueryMigration/src/V2/ErrorDetail.php @@ -21,13 +21,13 @@ class ErrorDetail extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.migration.v2.ErrorLocation location = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $location = null; + protected $location = null; /** * Required. Describes the cause of the error with structured detail. * * Generated from protobuf field .google.rpc.ErrorInfo error_info = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $error_info = null; + protected $error_info = null; /** * Constructor. diff --git a/BigQueryMigration/src/V2/ErrorLocation.php b/BigQueryMigration/src/V2/ErrorLocation.php index 259a9a2069d..b2d7144c0b5 100644 --- a/BigQueryMigration/src/V2/ErrorLocation.php +++ b/BigQueryMigration/src/V2/ErrorLocation.php @@ -21,14 +21,14 @@ class ErrorLocation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 line = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $line = 0; + protected $line = 0; /** * Optional. If applicable, denotes the column where the error occurred. A * zero value means that there is no columns information. * * Generated from protobuf field int32 column = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $column = 0; + protected $column = 0; /** * Constructor. diff --git a/BigQueryMigration/src/V2/Gapic/MigrationServiceGapicClient.php b/BigQueryMigration/src/V2/Gapic/MigrationServiceGapicClient.php deleted file mode 100644 index 859b0d99b30..00000000000 --- a/BigQueryMigration/src/V2/Gapic/MigrationServiceGapicClient.php +++ /dev/null @@ -1,787 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $migrationWorkflow = new MigrationWorkflow(); - * $response = $migrationServiceClient->createMigrationWorkflow($formattedParent, $migrationWorkflow); - * } finally { - * $migrationServiceClient->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\Migration\V2\Client\MigrationServiceClient}. - */ -class MigrationServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.bigquery.migration.v2.MigrationService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'bigquerymigration.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'bigquerymigration.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 $migrationSubtaskNameTemplate; - - private static $migrationWorkflowNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../resources/migration_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/migration_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../resources/migration_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/migration_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}' - ); - } - - return self::$locationNameTemplate; - } - - private static function getMigrationSubtaskNameTemplate() - { - if (self::$migrationSubtaskNameTemplate == null) { - self::$migrationSubtaskNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}/subtasks/{subtask}' - ); - } - - return self::$migrationSubtaskNameTemplate; - } - - private static function getMigrationWorkflowNameTemplate() - { - if (self::$migrationWorkflowNameTemplate == null) { - self::$migrationWorkflowNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}' - ); - } - - return self::$migrationWorkflowNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'location' => self::getLocationNameTemplate(), - 'migrationSubtask' => self::getMigrationSubtaskNameTemplate(), - 'migrationWorkflow' => self::getMigrationWorkflowNameTemplate(), - ]; - } - - 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 - * migration_subtask resource. - * - * @param string $project - * @param string $location - * @param string $workflow - * @param string $subtask - * - * @return string The formatted migration_subtask resource. - */ - public static function migrationSubtaskName( - $project, - $location, - $workflow, - $subtask - ) { - return self::getMigrationSubtaskNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'workflow' => $workflow, - 'subtask' => $subtask, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * migration_workflow resource. - * - * @param string $project - * @param string $location - * @param string $workflow - * - * @return string The formatted migration_workflow resource. - */ - public static function migrationWorkflowName($project, $location, $workflow) - { - return self::getMigrationWorkflowNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'workflow' => $workflow, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - migrationSubtask: projects/{project}/locations/{location}/workflows/{workflow}/subtasks/{subtask} - * - migrationWorkflow: projects/{project}/locations/{location}/workflows/{workflow} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($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 'bigquerymigration.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Creates a migration workflow. - * - * Sample code: - * ``` - * $migrationServiceClient = new MigrationServiceClient(); - * try { - * $formattedParent = $migrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $migrationWorkflow = new MigrationWorkflow(); - * $response = $migrationServiceClient->createMigrationWorkflow($formattedParent, $migrationWorkflow); - * } finally { - * $migrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the project to which this migration workflow belongs. - * Example: `projects/foo/locations/bar` - * @param MigrationWorkflow $migrationWorkflow Required. The migration workflow 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\BigQuery\Migration\V2\MigrationWorkflow - * - * @throws ApiException if the remote call fails - */ - public function createMigrationWorkflow( - $parent, - $migrationWorkflow, - array $optionalArgs = [] - ) { - $request = new CreateMigrationWorkflowRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setMigrationWorkflow($migrationWorkflow); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'CreateMigrationWorkflow', - MigrationWorkflow::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes a migration workflow by name. - * - * Sample code: - * ``` - * $migrationServiceClient = new MigrationServiceClient(); - * try { - * $formattedName = $migrationServiceClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - * $migrationServiceClient->deleteMigrationWorkflow($formattedName); - * } finally { - * $migrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The unique identifier for the migration workflow. - * Example: `projects/123/locations/us/workflows/1234` - * @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 deleteMigrationWorkflow($name, array $optionalArgs = []) - { - $request = new DeleteMigrationWorkflowRequest(); - $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( - 'DeleteMigrationWorkflow', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets a previously created migration subtask. - * - * Sample code: - * ``` - * $migrationServiceClient = new MigrationServiceClient(); - * try { - * $formattedName = $migrationServiceClient->migrationSubtaskName('[PROJECT]', '[LOCATION]', '[WORKFLOW]', '[SUBTASK]'); - * $response = $migrationServiceClient->getMigrationSubtask($formattedName); - * } finally { - * $migrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The unique identifier for the migration subtask. - * Example: `projects/123/locations/us/workflows/1234/subtasks/543` - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $readMask - * Optional. The list of fields to be retrieved. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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\Migration\V2\MigrationSubtask - * - * @throws ApiException if the remote call fails - */ - public function getMigrationSubtask($name, array $optionalArgs = []) - { - $request = new GetMigrationSubtaskRequest(); - $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( - 'GetMigrationSubtask', - MigrationSubtask::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Gets a previously created migration workflow. - * - * Sample code: - * ``` - * $migrationServiceClient = new MigrationServiceClient(); - * try { - * $formattedName = $migrationServiceClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - * $response = $migrationServiceClient->getMigrationWorkflow($formattedName); - * } finally { - * $migrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The unique identifier for the migration workflow. - * Example: `projects/123/locations/us/workflows/1234` - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $readMask - * The list of fields to be retrieved. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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\Migration\V2\MigrationWorkflow - * - * @throws ApiException if the remote call fails - */ - public function getMigrationWorkflow($name, array $optionalArgs = []) - { - $request = new GetMigrationWorkflowRequest(); - $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( - 'GetMigrationWorkflow', - MigrationWorkflow::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists previously created migration subtasks. - * - * Sample code: - * ``` - * $migrationServiceClient = new MigrationServiceClient(); - * try { - * $formattedParent = $migrationServiceClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - * // Iterate over pages of elements - * $pagedResponse = $migrationServiceClient->listMigrationSubtasks($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $migrationServiceClient->listMigrationSubtasks($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $migrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The migration task of the subtasks to list. - * Example: `projects/123/locations/us/workflows/1234` - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $readMask - * Optional. The list of fields to be retrieved. - * @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 filter to apply. This can be used to get the subtasks of a - * specific tasks in a workflow, e.g. `migration_task = "ab012"` where - * `"ab012"` is the task ID (not the name in the named map). - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can 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 listMigrationSubtasks($parent, array $optionalArgs = []) - { - $request = new ListMigrationSubtasksRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['readMask'])) { - $request->setReadMask($optionalArgs['readMask']); - } - - 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( - 'ListMigrationSubtasks', - $optionalArgs, - ListMigrationSubtasksResponse::class, - $request - ); - } - - /** - * Lists previously created migration workflow. - * - * Sample code: - * ``` - * $migrationServiceClient = new MigrationServiceClient(); - * try { - * $formattedParent = $migrationServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $migrationServiceClient->listMigrationWorkflows($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $migrationServiceClient->listMigrationWorkflows($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $migrationServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The project and location of the migration workflows to list. - * Example: `projects/123/locations/us` - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $readMask - * The list of fields to be retrieved. - * @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 listMigrationWorkflows($parent, array $optionalArgs = []) - { - $request = new ListMigrationWorkflowsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['readMask'])) { - $request->setReadMask($optionalArgs['readMask']); - } - - 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( - 'ListMigrationWorkflows', - $optionalArgs, - ListMigrationWorkflowsResponse::class, - $request - ); - } - - /** - * Starts a previously created migration workflow. I.e., the state transitions - * from DRAFT to RUNNING. This is a no-op if the state is already RUNNING. - * An error will be signaled if the state is anything other than DRAFT or - * RUNNING. - * - * Sample code: - * ``` - * $migrationServiceClient = new MigrationServiceClient(); - * try { - * $formattedName = $migrationServiceClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - * $migrationServiceClient->startMigrationWorkflow($formattedName); - * } finally { - * $migrationServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The unique identifier for the migration workflow. - * Example: `projects/123/locations/us/workflows/1234` - * @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 startMigrationWorkflow($name, array $optionalArgs = []) - { - $request = new StartMigrationWorkflowRequest(); - $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( - 'StartMigrationWorkflow', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/BigQueryMigration/src/V2/GetMigrationSubtaskRequest.php b/BigQueryMigration/src/V2/GetMigrationSubtaskRequest.php index 5627e951944..ac8f15bd9e8 100644 --- a/BigQueryMigration/src/V2/GetMigrationSubtaskRequest.php +++ b/BigQueryMigration/src/V2/GetMigrationSubtaskRequest.php @@ -21,13 +21,13 @@ class GetMigrationSubtaskRequest 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. The list of fields to be retrieved. * * Generated from protobuf field .google.protobuf.FieldMask read_mask = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $read_mask = null; + protected $read_mask = null; /** * @param string $name Required. The unique identifier for the migration subtask. diff --git a/BigQueryMigration/src/V2/GetMigrationWorkflowRequest.php b/BigQueryMigration/src/V2/GetMigrationWorkflowRequest.php index 29cd77620b7..cf20c510184 100644 --- a/BigQueryMigration/src/V2/GetMigrationWorkflowRequest.php +++ b/BigQueryMigration/src/V2/GetMigrationWorkflowRequest.php @@ -21,13 +21,13 @@ class GetMigrationWorkflowRequest 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 list of fields to be retrieved. * * Generated from protobuf field .google.protobuf.FieldMask read_mask = 2; */ - private $read_mask = null; + protected $read_mask = null; /** * @param string $name Required. The unique identifier for the migration workflow. diff --git a/BigQueryMigration/src/V2/ListMigrationSubtasksRequest.php b/BigQueryMigration/src/V2/ListMigrationSubtasksRequest.php index f70c040f150..5cdf51450e5 100644 --- a/BigQueryMigration/src/V2/ListMigrationSubtasksRequest.php +++ b/BigQueryMigration/src/V2/ListMigrationSubtasksRequest.php @@ -21,20 +21,20 @@ class ListMigrationSubtasksRequest 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 list of fields to be retrieved. * * Generated from protobuf field .google.protobuf.FieldMask read_mask = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $read_mask = null; + protected $read_mask = null; /** * Optional. The maximum number of migration tasks to return. The service may * return fewer than this number. * * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. A page token, received from previous `ListMigrationSubtasks` * call. Provide this to retrieve the subsequent page. @@ -43,7 +43,7 @@ class ListMigrationSubtasksRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. The filter to apply. This can be used to get the subtasks of a * specific tasks in a workflow, e.g. `migration_task = "ab012"` where @@ -51,7 +51,7 @@ class ListMigrationSubtasksRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * @param string $parent Required. The migration task of the subtasks to list. diff --git a/BigQueryMigration/src/V2/ListMigrationSubtasksResponse.php b/BigQueryMigration/src/V2/ListMigrationSubtasksResponse.php index dbf9413254d..5ef10e1eda9 100644 --- a/BigQueryMigration/src/V2/ListMigrationSubtasksResponse.php +++ b/BigQueryMigration/src/V2/ListMigrationSubtasksResponse.php @@ -27,7 +27,7 @@ class ListMigrationSubtasksResponse 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/BigQueryMigration/src/V2/ListMigrationWorkflowsRequest.php b/BigQueryMigration/src/V2/ListMigrationWorkflowsRequest.php index 3e4b4285a52..e3637ad33ae 100644 --- a/BigQueryMigration/src/V2/ListMigrationWorkflowsRequest.php +++ b/BigQueryMigration/src/V2/ListMigrationWorkflowsRequest.php @@ -21,20 +21,20 @@ class ListMigrationWorkflowsRequest 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 list of fields to be retrieved. * * Generated from protobuf field .google.protobuf.FieldMask read_mask = 2; */ - private $read_mask = null; + protected $read_mask = null; /** * The maximum number of migration workflows to return. The service may return * fewer than this number. * * Generated from protobuf field int32 page_size = 3; */ - private $page_size = 0; + protected $page_size = 0; /** * A page token, received from previous `ListMigrationWorkflows` call. * Provide this to retrieve the subsequent page. @@ -43,7 +43,7 @@ class ListMigrationWorkflowsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 4; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The project and location of the migration workflows to list. diff --git a/BigQueryMigration/src/V2/ListMigrationWorkflowsResponse.php b/BigQueryMigration/src/V2/ListMigrationWorkflowsResponse.php index 9d41020650d..41d31c2cfeb 100644 --- a/BigQueryMigration/src/V2/ListMigrationWorkflowsResponse.php +++ b/BigQueryMigration/src/V2/ListMigrationWorkflowsResponse.php @@ -27,7 +27,7 @@ class ListMigrationWorkflowsResponse 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/BigQueryMigration/src/V2/MigrationServiceClient.php b/BigQueryMigration/src/V2/MigrationServiceClient.php deleted file mode 100644 index c76e7fe0161..00000000000 --- a/BigQueryMigration/src/V2/MigrationServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * The unique ID of the task to which this subtask belongs. * * Generated from protobuf field string task_id = 2; */ - private $task_id = ''; + protected $task_id = ''; /** * The type of the Subtask. The migration service does not check whether this * is a known type. It is up to the task creator (i.e. orchestrator or worker) @@ -39,20 +39,20 @@ class MigrationSubtask extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string type = 3; */ - private $type = ''; + protected $type = ''; /** * Output only. The current state of the subtask. * * Generated from protobuf field .google.cloud.bigquery.migration.v2.MigrationSubtask.State state = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. An explanation that may be populated when the task is in * FAILED state. * * Generated from protobuf field .google.rpc.ErrorInfo processing_error = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $processing_error = null; + protected $processing_error = null; /** * Output only. Provides details to errors and issues encountered while * processing the subtask. Presence of error details does not mean that the @@ -69,19 +69,19 @@ class MigrationSubtask extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 resource_error_count = 13; */ - private $resource_error_count = 0; + protected $resource_error_count = 0; /** * Time when the subtask was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7; */ - private $create_time = null; + protected $create_time = null; /** * Time when the subtask was last updated. * * Generated from protobuf field .google.protobuf.Timestamp last_update_time = 8; */ - private $last_update_time = null; + protected $last_update_time = null; /** * The metrics for the subtask. * diff --git a/BigQueryMigration/src/V2/MigrationTask.php b/BigQueryMigration/src/V2/MigrationTask.php index 640914b80b7..324eb189463 100644 --- a/BigQueryMigration/src/V2/MigrationTask.php +++ b/BigQueryMigration/src/V2/MigrationTask.php @@ -22,7 +22,7 @@ class MigrationTask extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE]; */ - private $id = ''; + protected $id = ''; /** * The type of the task. This must be one of the supported task types: * Translation_Teradata2BQ, Translation_Redshift2BQ, Translation_Bteq2BQ, @@ -34,32 +34,32 @@ class MigrationTask extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string type = 2; */ - private $type = ''; + protected $type = ''; /** * Output only. The current state of the task. * * Generated from protobuf field .google.cloud.bigquery.migration.v2.MigrationTask.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. An explanation that may be populated when the task is in * FAILED state. * * Generated from protobuf field .google.rpc.ErrorInfo processing_error = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $processing_error = null; + protected $processing_error = null; /** * Time when the task was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 6; */ - private $create_time = null; + protected $create_time = null; /** * Time when the task was last updated. * * Generated from protobuf field .google.protobuf.Timestamp last_update_time = 7; */ - private $last_update_time = null; + protected $last_update_time = null; protected $task_details; /** diff --git a/BigQueryMigration/src/V2/MigrationWorkflow.php b/BigQueryMigration/src/V2/MigrationWorkflow.php index c9cf2c92b38..09e7dfcf655 100644 --- a/BigQueryMigration/src/V2/MigrationWorkflow.php +++ b/BigQueryMigration/src/V2/MigrationWorkflow.php @@ -23,14 +23,14 @@ class MigrationWorkflow extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE]; */ - private $name = ''; + protected $name = ''; /** * The display name of the workflow. This can be set to give a workflow * a descriptive name. There is no guarantee or enforcement of uniqueness. * * Generated from protobuf field string display_name = 6; */ - private $display_name = ''; + protected $display_name = ''; /** * The tasks in a workflow in a named map. The name (i.e. key) has no * meaning and is merely a convenient way to address a specific task @@ -44,19 +44,19 @@ class MigrationWorkflow extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.migration.v2.MigrationWorkflow.State state = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Time when the workflow was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 4; */ - private $create_time = null; + protected $create_time = null; /** * Time when the workflow was last updated. * * Generated from protobuf field .google.protobuf.Timestamp last_update_time = 5; */ - private $last_update_time = null; + protected $last_update_time = null; /** * Constructor. diff --git a/BigQueryMigration/src/V2/NameMappingKey.php b/BigQueryMigration/src/V2/NameMappingKey.php index 1aced910c5e..685893ad9db 100644 --- a/BigQueryMigration/src/V2/NameMappingKey.php +++ b/BigQueryMigration/src/V2/NameMappingKey.php @@ -21,34 +21,34 @@ class NameMappingKey extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.migration.v2.NameMappingKey.Type type = 1; */ - private $type = 0; + protected $type = 0; /** * The database name (BigQuery project ID equivalent in the source data * warehouse). * * Generated from protobuf field string database = 2; */ - private $database = ''; + protected $database = ''; /** * The schema name (BigQuery dataset equivalent in the source data warehouse). * * Generated from protobuf field string schema = 3; */ - private $schema = ''; + protected $schema = ''; /** * The relation name (BigQuery table or view equivalent in the source data * warehouse). * * Generated from protobuf field string relation = 4; */ - private $relation = ''; + protected $relation = ''; /** * The attribute name (BigQuery column equivalent in the source data * warehouse). * * Generated from protobuf field string attribute = 5; */ - private $attribute = ''; + protected $attribute = ''; /** * Constructor. diff --git a/BigQueryMigration/src/V2/NameMappingValue.php b/BigQueryMigration/src/V2/NameMappingValue.php index 9578d88ec80..9720101da80 100644 --- a/BigQueryMigration/src/V2/NameMappingValue.php +++ b/BigQueryMigration/src/V2/NameMappingValue.php @@ -22,27 +22,27 @@ class NameMappingValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string database = 1; */ - private $database = ''; + protected $database = ''; /** * The schema name (BigQuery dataset equivalent in the target data warehouse). * * Generated from protobuf field string schema = 2; */ - private $schema = ''; + protected $schema = ''; /** * The relation name (BigQuery table or view equivalent in the target data * warehouse). * * Generated from protobuf field string relation = 3; */ - private $relation = ''; + protected $relation = ''; /** * The attribute name (BigQuery column equivalent in the target data * warehouse). * * Generated from protobuf field string attribute = 4; */ - private $attribute = ''; + protected $attribute = ''; /** * Constructor. diff --git a/BigQueryMigration/src/V2/ObjectNameMapping.php b/BigQueryMigration/src/V2/ObjectNameMapping.php index ce8273475fa..8f6205ed468 100644 --- a/BigQueryMigration/src/V2/ObjectNameMapping.php +++ b/BigQueryMigration/src/V2/ObjectNameMapping.php @@ -21,13 +21,13 @@ class ObjectNameMapping extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.migration.v2.NameMappingKey source = 1; */ - private $source = null; + protected $source = null; /** * The desired target name of the object that is being mapped. * * Generated from protobuf field .google.cloud.bigquery.migration.v2.NameMappingValue target = 2; */ - private $target = null; + protected $target = null; /** * Constructor. diff --git a/BigQueryMigration/src/V2/Point.php b/BigQueryMigration/src/V2/Point.php index 70819b2ebb7..19294ba7a81 100644 --- a/BigQueryMigration/src/V2/Point.php +++ b/BigQueryMigration/src/V2/Point.php @@ -28,13 +28,13 @@ class Point extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.migration.v2.TimeInterval interval = 1; */ - private $interval = null; + protected $interval = null; /** * The value of the data point. * * Generated from protobuf field .google.cloud.bigquery.migration.v2.TypedValue value = 2; */ - private $value = null; + protected $value = null; /** * Constructor. diff --git a/BigQueryMigration/src/V2/ResourceErrorDetail.php b/BigQueryMigration/src/V2/ResourceErrorDetail.php index 5a05b107ff8..a28217d83d8 100644 --- a/BigQueryMigration/src/V2/ResourceErrorDetail.php +++ b/BigQueryMigration/src/V2/ResourceErrorDetail.php @@ -20,7 +20,7 @@ class ResourceErrorDetail extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.rpc.ResourceInfo resource_info = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $resource_info = null; + protected $resource_info = null; /** * Required. The error details for the resource. * @@ -34,7 +34,7 @@ class ResourceErrorDetail extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 error_count = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $error_count = 0; + protected $error_count = 0; /** * Constructor. diff --git a/BigQueryMigration/src/V2/SourceEnv.php b/BigQueryMigration/src/V2/SourceEnv.php index 3afb4a15b06..ad5d668878e 100644 --- a/BigQueryMigration/src/V2/SourceEnv.php +++ b/BigQueryMigration/src/V2/SourceEnv.php @@ -21,7 +21,7 @@ class SourceEnv extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string default_database = 1; */ - private $default_database = ''; + protected $default_database = ''; /** * The schema search path. When SQL objects are missing schema name, * translation engine will search through this list to find the value. diff --git a/BigQueryMigration/src/V2/StartMigrationWorkflowRequest.php b/BigQueryMigration/src/V2/StartMigrationWorkflowRequest.php index 87188a961f5..28129d124ac 100644 --- a/BigQueryMigration/src/V2/StartMigrationWorkflowRequest.php +++ b/BigQueryMigration/src/V2/StartMigrationWorkflowRequest.php @@ -21,7 +21,7 @@ class StartMigrationWorkflowRequest 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 unique identifier for the migration workflow. diff --git a/BigQueryMigration/src/V2/TeradataDialect.php b/BigQueryMigration/src/V2/TeradataDialect.php index f8d5fcefec5..b50e261eeb9 100644 --- a/BigQueryMigration/src/V2/TeradataDialect.php +++ b/BigQueryMigration/src/V2/TeradataDialect.php @@ -20,7 +20,7 @@ class TeradataDialect extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.migration.v2.TeradataDialect.Mode mode = 1; */ - private $mode = 0; + protected $mode = 0; /** * Constructor. diff --git a/BigQueryMigration/src/V2/TimeInterval.php b/BigQueryMigration/src/V2/TimeInterval.php index eb4c02f9754..ecb718c94a9 100644 --- a/BigQueryMigration/src/V2/TimeInterval.php +++ b/BigQueryMigration/src/V2/TimeInterval.php @@ -24,13 +24,13 @@ class TimeInterval extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp start_time = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - private $start_time = null; + protected $start_time = null; /** * Required. The end of the time interval. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $end_time = null; + protected $end_time = null; /** * Constructor. diff --git a/BigQueryMigration/src/V2/TimeSeries.php b/BigQueryMigration/src/V2/TimeSeries.php index a37ddfc1fee..2ea97494c4d 100644 --- a/BigQueryMigration/src/V2/TimeSeries.php +++ b/BigQueryMigration/src/V2/TimeSeries.php @@ -21,13 +21,13 @@ class TimeSeries extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string metric = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $metric = ''; + protected $metric = ''; /** * Required. The value type of the time series. * * Generated from protobuf field .google.api.MetricDescriptor.ValueType value_type = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $value_type = 0; + protected $value_type = 0; /** * Optional. The metric kind of the time series. * If present, it must be the same as the metric kind of the associated @@ -37,7 +37,7 @@ class TimeSeries extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.api.MetricDescriptor.MetricKind metric_kind = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $metric_kind = 0; + protected $metric_kind = 0; /** * Required. The data points of this time series. When listing time series, * points are returned in reverse time order. diff --git a/BigQueryMigration/src/V2/TranslationConfigDetails.php b/BigQueryMigration/src/V2/TranslationConfigDetails.php index 0bb1a25bb82..c91f045263c 100644 --- a/BigQueryMigration/src/V2/TranslationConfigDetails.php +++ b/BigQueryMigration/src/V2/TranslationConfigDetails.php @@ -21,25 +21,25 @@ class TranslationConfigDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.bigquery.migration.v2.Dialect source_dialect = 3; */ - private $source_dialect = null; + protected $source_dialect = null; /** * The target dialect for the engine to translate the input to. * * Generated from protobuf field .google.cloud.bigquery.migration.v2.Dialect target_dialect = 4; */ - private $target_dialect = null; + protected $target_dialect = null; /** * The default source environment values for the translation. * * Generated from protobuf field .google.cloud.bigquery.migration.v2.SourceEnv source_env = 6; */ - private $source_env = null; + protected $source_env = null; /** * The indicator to show translation request initiator. * * Generated from protobuf field string request_source = 8; */ - private $request_source = ''; + protected $request_source = ''; protected $source_location; protected $target_location; protected $output_name_mapping; diff --git a/BigQueryMigration/tests/Unit/V2/Client/MigrationServiceClientTest.php b/BigQueryMigration/tests/Unit/V2/Client/MigrationServiceClientTest.php index 4e996049a96..f0fe3991a15 100644 --- a/BigQueryMigration/tests/Unit/V2/Client/MigrationServiceClientTest.php +++ b/BigQueryMigration/tests/Unit/V2/Client/MigrationServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return MigrationServiceClient */ @@ -97,7 +99,10 @@ public function createMigrationWorkflowTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/CreateMigrationWorkflow', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.migration.v2.MigrationService/CreateMigrationWorkflow', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getMigrationWorkflow(); @@ -116,12 +121,15 @@ public function createMigrationWorkflowExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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]'); @@ -155,14 +163,16 @@ public function deleteMigrationWorkflowTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $request = (new DeleteMigrationWorkflowRequest()) - ->setName($formattedName); + $request = (new DeleteMigrationWorkflowRequest())->setName($formattedName); $gapicClient->deleteMigrationWorkflow($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/DeleteMigrationWorkflow', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.migration.v2.MigrationService/DeleteMigrationWorkflow', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -179,17 +189,19 @@ public function deleteMigrationWorkflowExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $request = (new DeleteMigrationWorkflowRequest()) - ->setName($formattedName); + $request = (new DeleteMigrationWorkflowRequest())->setName($formattedName); try { $gapicClient->deleteMigrationWorkflow($request); // If the $gapicClient method call did not throw, fail the test @@ -224,8 +236,7 @@ public function getMigrationSubtaskTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->migrationSubtaskName('[PROJECT]', '[LOCATION]', '[WORKFLOW]', '[SUBTASK]'); - $request = (new GetMigrationSubtaskRequest()) - ->setName($formattedName); + $request = (new GetMigrationSubtaskRequest())->setName($formattedName); $response = $gapicClient->getMigrationSubtask($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -249,17 +260,19 @@ public function getMigrationSubtaskExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->migrationSubtaskName('[PROJECT]', '[LOCATION]', '[WORKFLOW]', '[SUBTASK]'); - $request = (new GetMigrationSubtaskRequest()) - ->setName($formattedName); + $request = (new GetMigrationSubtaskRequest())->setName($formattedName); try { $gapicClient->getMigrationSubtask($request); // If the $gapicClient method call did not throw, fail the test @@ -290,8 +303,7 @@ public function getMigrationWorkflowTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $request = (new GetMigrationWorkflowRequest()) - ->setName($formattedName); + $request = (new GetMigrationWorkflowRequest())->setName($formattedName); $response = $gapicClient->getMigrationWorkflow($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -315,17 +327,19 @@ public function getMigrationWorkflowExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $request = (new GetMigrationWorkflowRequest()) - ->setName($formattedName); + $request = (new GetMigrationWorkflowRequest())->setName($formattedName); try { $gapicClient->getMigrationWorkflow($request); // If the $gapicClient method call did not throw, fail the test @@ -350,17 +364,14 @@ public function listMigrationSubtasksTest() // Mock response $nextPageToken = ''; $migrationSubtasksElement = new MigrationSubtask(); - $migrationSubtasks = [ - $migrationSubtasksElement, - ]; + $migrationSubtasks = [$migrationSubtasksElement]; $expectedResponse = new ListMigrationSubtasksResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setMigrationSubtasks($migrationSubtasks); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $request = (new ListMigrationSubtasksRequest()) - ->setParent($formattedParent); + $request = (new ListMigrationSubtasksRequest())->setParent($formattedParent); $response = $gapicClient->listMigrationSubtasks($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -370,7 +381,10 @@ public function listMigrationSubtasksTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationSubtasks', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationSubtasks', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -387,17 +401,19 @@ public function listMigrationSubtasksExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $request = (new ListMigrationSubtasksRequest()) - ->setParent($formattedParent); + $request = (new ListMigrationSubtasksRequest())->setParent($formattedParent); try { $gapicClient->listMigrationSubtasks($request); // If the $gapicClient method call did not throw, fail the test @@ -422,17 +438,14 @@ public function listMigrationWorkflowsTest() // Mock response $nextPageToken = ''; $migrationWorkflowsElement = new MigrationWorkflow(); - $migrationWorkflows = [ - $migrationWorkflowsElement, - ]; + $migrationWorkflows = [$migrationWorkflowsElement]; $expectedResponse = new ListMigrationWorkflowsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setMigrationWorkflows($migrationWorkflows); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListMigrationWorkflowsRequest()) - ->setParent($formattedParent); + $request = (new ListMigrationWorkflowsRequest())->setParent($formattedParent); $response = $gapicClient->listMigrationWorkflows($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -442,7 +455,10 @@ public function listMigrationWorkflowsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationWorkflows', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationWorkflows', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -459,17 +475,19 @@ public function listMigrationWorkflowsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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 ListMigrationWorkflowsRequest()) - ->setParent($formattedParent); + $request = (new ListMigrationWorkflowsRequest())->setParent($formattedParent); try { $gapicClient->listMigrationWorkflows($request); // If the $gapicClient method call did not throw, fail the test @@ -496,14 +514,16 @@ public function startMigrationWorkflowTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $request = (new StartMigrationWorkflowRequest()) - ->setName($formattedName); + $request = (new StartMigrationWorkflowRequest())->setName($formattedName); $gapicClient->startMigrationWorkflow($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/StartMigrationWorkflow', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.migration.v2.MigrationService/StartMigrationWorkflow', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -520,17 +540,19 @@ public function startMigrationWorkflowExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - '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->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $request = (new StartMigrationWorkflowRequest()) - ->setName($formattedName); + $request = (new StartMigrationWorkflowRequest())->setName($formattedName); try { $gapicClient->startMigrationWorkflow($request); // If the $gapicClient method call did not throw, fail the test @@ -571,7 +593,10 @@ public function createMigrationWorkflowAsyncTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/CreateMigrationWorkflow', $actualFuncCall); + $this->assertSame( + '/google.cloud.bigquery.migration.v2.MigrationService/CreateMigrationWorkflow', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getMigrationWorkflow(); diff --git a/BigQueryMigration/tests/Unit/V2/MigrationServiceClientTest.php b/BigQueryMigration/tests/Unit/V2/MigrationServiceClientTest.php deleted file mode 100644 index c5c90b5b266..00000000000 --- a/BigQueryMigration/tests/Unit/V2/MigrationServiceClientTest.php +++ /dev/null @@ -1,509 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return MigrationServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new MigrationServiceClient($options); - } - - /** @test */ - public function createMigrationWorkflowTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $expectedResponse = new MigrationWorkflow(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $migrationWorkflow = new MigrationWorkflow(); - $response = $gapicClient->createMigrationWorkflow($formattedParent, $migrationWorkflow); - $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.migration.v2.MigrationService/CreateMigrationWorkflow', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getMigrationWorkflow(); - $this->assertProtobufEquals($migrationWorkflow, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createMigrationWorkflowExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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]'); - $migrationWorkflow = new MigrationWorkflow(); - try { - $gapicClient->createMigrationWorkflow($formattedParent, $migrationWorkflow); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteMigrationWorkflowTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $gapicClient->deleteMigrationWorkflow($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/DeleteMigrationWorkflow', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteMigrationWorkflowExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - try { - $gapicClient->deleteMigrationWorkflow($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 getMigrationSubtaskTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $taskId = 'taskId-1537240555'; - $type = 'type3575610'; - $resourceErrorCount = 929997465; - $expectedResponse = new MigrationSubtask(); - $expectedResponse->setName($name2); - $expectedResponse->setTaskId($taskId); - $expectedResponse->setType($type); - $expectedResponse->setResourceErrorCount($resourceErrorCount); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->migrationSubtaskName('[PROJECT]', '[LOCATION]', '[WORKFLOW]', '[SUBTASK]'); - $response = $gapicClient->getMigrationSubtask($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.migration.v2.MigrationService/GetMigrationSubtask', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getMigrationSubtaskExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->migrationSubtaskName('[PROJECT]', '[LOCATION]', '[WORKFLOW]', '[SUBTASK]'); - try { - $gapicClient->getMigrationSubtask($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 getMigrationWorkflowTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $expectedResponse = new MigrationWorkflow(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $response = $gapicClient->getMigrationWorkflow($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.migration.v2.MigrationService/GetMigrationWorkflow', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getMigrationWorkflowExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - try { - $gapicClient->getMigrationWorkflow($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 listMigrationSubtasksTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $migrationSubtasksElement = new MigrationSubtask(); - $migrationSubtasks = [ - $migrationSubtasksElement, - ]; - $expectedResponse = new ListMigrationSubtasksResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setMigrationSubtasks($migrationSubtasks); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $response = $gapicClient->listMigrationSubtasks($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getMigrationSubtasks()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationSubtasks', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listMigrationSubtasksExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - try { - $gapicClient->listMigrationSubtasks($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 listMigrationWorkflowsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $migrationWorkflowsElement = new MigrationWorkflow(); - $migrationWorkflows = [ - $migrationWorkflowsElement, - ]; - $expectedResponse = new ListMigrationWorkflowsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setMigrationWorkflows($migrationWorkflows); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listMigrationWorkflows($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getMigrationWorkflows()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationWorkflows', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listMigrationWorkflowsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->listMigrationWorkflows($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 startMigrationWorkflowTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - $gapicClient->startMigrationWorkflow($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.bigquery.migration.v2.MigrationService/StartMigrationWorkflow', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function startMigrationWorkflowExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->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->migrationWorkflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); - try { - $gapicClient->startMigrationWorkflow($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()); - } -} From 5762dfc44de436088587a86eb4806439d4f632e2 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 20 Jun 2024 08:43:16 -0700 Subject: [PATCH 2/2] Update .repo-metadata-full.json --- .repo-metadata-full.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.repo-metadata-full.json b/.repo-metadata-full.json index 556b02b3e40..8d06c343ad4 100644 --- a/.repo-metadata-full.json +++ b/.repo-metadata-full.json @@ -258,7 +258,7 @@ "BigQueryDataExchange": { "language": "php", "distribution_name": "google/cloud-bigquery-data-exchange", - "release_level": "stable", + "release_level": "preview", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-bigquery-data-exchange/latest", "library_type": "GAPIC_AUTO", "api_shortname": "analyticshub"