diff --git a/.librarian/config.yaml b/.librarian/config.yaml index 2fcf99df7626..9a4d901b6bb2 100644 --- a/.librarian/config.yaml +++ b/.librarian/config.yaml @@ -1,51 +1,28 @@ -# This repo is now in legacylibrarian "release-only mode" -# as part of the migration to librarian. -# -# Attempting to regenerate using legacylibrarian will fail, -# and releasing will not expect commits to be generated by -# legacylibrarian. -release_only_mode: true +# This file is being migrated to librarian@latest, and is no longer maintained by hand. +release_only_mode: true global_files_allowlist: - # Allow the container to read and write the root `CHANGELOG.md` - # file during the `release` step to update the latest client library - # versions which are hardcoded in the file. - - path: "CHANGELOG.md" - permissions: "read-write" - + - path: CHANGELOG.md + permissions: read-write libraries: -# libraries have "release_blocked: true" so that releases are -# explicitly initiated. -# TODO(https://github.com/googleapis/google-cloud-python/issues/16180): -# `google-django-spanner` is blocked until the presubmits are green. - - id: "google-django-spanner" + - id: google-django-spanner release_blocked: true -# TODO(https://github.com/googleapis/google-cloud-python/issues/16487): -# Allow releases for google-cloud-storage once this bug is fixed. - - id: "google-cloud-storage" + - id: google-cloud-storage release_blocked: true -# TODO(https://github.com/googleapis/google-cloud-python/issues/16494): -# Allow generation for google-cloud-bigtable once this bug is fixed. - - id: "google-cloud-bigtable" - generate_blocked: true -# TODO(https://github.com/googleapis/google-cloud-python/issues/16489): -# Allow releases for bigframes once the bug above is fixed. - - id: "bigframes" + - generate_blocked: true + id: google-cloud-bigtable + - id: bigframes release_blocked: true -# TODO(https://github.com/googleapis/google-cloud-python/issues/16506): -# Allow generation/release for google-cloud-firestore once this bug is fixed. - - id: "google-cloud-firestore" - generate_blocked: true + - generate_blocked: true + id: google-cloud-firestore release_blocked: true -# TODO(https://github.com/googleapis/google-cloud-python/issues/16165): -# Allow generation for google-cloud-dialogflow once this bug is fixed. - - id: "google-cloud-dialogflow" - generate_blocked: true -# TODO(https://github.com/googleapis/google-cloud-python/issues/16520): -# Allow release for google-crc32c once this bug is fixed. - - id: "google-crc32c" + - generate_blocked: true + id: google-cloud-dialogflow + - id: google-crc32c release_blocked: true -# TODO(https://github.com/googleapis/google-cloud-python/issues/16600): -# Allow release for google-cloud-spanner after tests are fixed. - - id: "google-cloud-spanner" + - id: google-cloud-spanner release_blocked: true + - generate_blocked: true + id: google-area120-tables + - generate_blocked: true + id: google-cloud-config diff --git a/.librarian/state.yaml b/.librarian/state.yaml index 3af4eb460caf..bbd03fcacef7 100644 --- a/.librarian/state.yaml +++ b/.librarian/state.yaml @@ -271,6 +271,9 @@ libraries: - docs/CHANGELOG.md remove_regex: - packages/google-area120-tables/ + release_exclude_paths: + - packages/google-area120-tables/.repo-metadata.json + - packages/google-area120-tables/docs/README.rst tag_format: '{id}-v{version}' - id: google-auth version: 2.49.2 @@ -1274,6 +1277,9 @@ libraries: - docs/CHANGELOG.md remove_regex: - packages/google-cloud-config/ + release_exclude_paths: + - packages/google-cloud-config/.repo-metadata.json + - packages/google-cloud-config/docs/README.rst tag_format: '{id}-v{version}' - id: google-cloud-configdelivery version: 0.4.0 diff --git a/librarian.yaml b/librarian.yaml new file mode 100644 index 000000000000..0bfd3833f0a9 --- /dev/null +++ b/librarian.yaml @@ -0,0 +1,81 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +language: python +version: v0.10.1-0.20260410064550-f49f20f3e64c +repo: googleapis/google-cloud-python +sources: + googleapis: + commit: 66fcc021fec9e5249e69da17068bea999f113622 + sha256: ce31966528ca99123c566542606ecf02d42c916a07dbf22910cee9996e9eaefb +release: + ignored_changes: + - .repo-metadata.json + - docs/README.rst +default: + output: packages + tag_format: '{name}: v{version}' + python: + common_gapic_paths: + - samples/generated_samples + - tests/unit/gapic + - testing + - '{neutral-source}/__init__.py' + - '{neutral-source}/gapic_version.py' + - '{neutral-source}/py.typed' + - tests/unit/__init__.py + - tests/__init__.py + - setup.py + - noxfile.py + - .coveragerc + - .flake8 + - .repo-metadata.json + - mypy.ini + - README.rst + - LICENSE + - MANIFEST.in + - docs/_static/custom.css + - docs/_templates/layout.html + - docs/conf.py + - docs/index.rst + - docs/multiprocessing.rst + - docs/README.rst + - docs/summary_overview.md + library_type: GAPIC_AUTO +libraries: + - name: google-area120-tables + version: 0.14.0 + apis: + - path: google/area120/tables/v1alpha1 + description_override: provides programmatic methods to the Area 120 Tables API. + keep: + - CHANGELOG.md + - docs/CHANGELOG.md + python: + name_pretty_override: Area 120 Tables + metadata_name_override: area120tables + default_version: v1alpha1 + - name: google-cloud-config + version: 0.5.0 + apis: + - path: google/cloud/config/v1 + description_override: Infrastructure Manager API + keep: + - CHANGELOG.md + - docs/CHANGELOG.md + python: + name_pretty_override: Infrastructure Manager API + product_documentation_override: https://cloud.google.com/infrastructure-manager/docs/overview + api_shortname_override: config + metadata_name_override: config + default_version: v1 diff --git a/packages/google-area120-tables/.repo-metadata.json b/packages/google-area120-tables/.repo-metadata.json index f0ffeaf75062..401f6f9adfaf 100644 --- a/packages/google-area120-tables/.repo-metadata.json +++ b/packages/google-area120-tables/.repo-metadata.json @@ -1,16 +1,15 @@ { - "api_description": "provides programmatic methods to the Area 120 Tables API.", - "api_id": "area120tables.googleapis.com", - "api_shortname": "area120tables", - "client_documentation": "https://googleapis.dev/python/area120tables/latest", - "default_version": "v1alpha1", - "distribution_name": "google-area120-tables", - "issue_tracker": "", - "language": "python", - "library_type": "GAPIC_AUTO", - "name": "area120tables", - "name_pretty": "Area 120 Tables", - "product_documentation": "https://area120.google.com", - "release_level": "preview", - "repo": "googleapis/google-cloud-python" + "api_description": "provides programmatic methods to the Area 120 Tables API.", + "api_id": "area120tables.googleapis.com", + "api_shortname": "area120tables", + "client_documentation": "https://googleapis.dev/python/area120tables/latest", + "default_version": "v1alpha1", + "distribution_name": "google-area120-tables", + "language": "python", + "library_type": "GAPIC_AUTO", + "name": "area120tables", + "name_pretty": "Area 120 Tables", + "product_documentation": "https://area120.google.com", + "release_level": "preview", + "repo": "googleapis/google-cloud-python" } \ No newline at end of file diff --git a/packages/google-cloud-config/.repo-metadata.json b/packages/google-cloud-config/.repo-metadata.json index 15118132fe79..5210406c4cda 100644 --- a/packages/google-cloud-config/.repo-metadata.json +++ b/packages/google-cloud-config/.repo-metadata.json @@ -1,16 +1,16 @@ { - "api_description": "Infrastructure Manager API", - "api_id": "config.googleapis.com", - "api_shortname": "config", - "client_documentation": "https://cloud.google.com/python/docs/reference/config/latest", - "default_version": "v1", - "distribution_name": "google-cloud-config", - "issue_tracker": "https://issuetracker.google.com/issues/new?component=536700", - "language": "python", - "library_type": "GAPIC_AUTO", - "name": "config", - "name_pretty": "Infrastructure Manager API", - "product_documentation": "https://cloud.google.com/infrastructure-manager/docs/overview", - "release_level": "preview", - "repo": "googleapis/google-cloud-python" + "api_description": "Infrastructure Manager API", + "api_id": "config.googleapis.com", + "api_shortname": "config", + "client_documentation": "https://cloud.google.com/python/docs/reference/config/latest", + "default_version": "v1", + "distribution_name": "google-cloud-config", + "issue_tracker": "https://issuetracker.google.com/issues/new?component=536700", + "language": "python", + "library_type": "GAPIC_AUTO", + "name": "config", + "name_pretty": "Infrastructure Manager API", + "product_documentation": "https://cloud.google.com/infrastructure-manager/docs/overview", + "release_level": "preview", + "repo": "googleapis/google-cloud-python" } \ No newline at end of file diff --git a/packages/google-cloud-config/google/cloud/config/__init__.py b/packages/google-cloud-config/google/cloud/config/__init__.py index 287b89353973..0ceb7664dde2 100644 --- a/packages/google-cloud-config/google/cloud/config/__init__.py +++ b/packages/google-cloud-config/google/cloud/config/__init__.py @@ -23,19 +23,32 @@ from google.cloud.config_v1.types.config import ( ApplyResults, AutoMigrationConfig, + CreateDeploymentGroupRequest, CreateDeploymentRequest, CreatePreviewRequest, + DeleteDeploymentGroupRequest, DeleteDeploymentRequest, DeletePreviewRequest, DeleteStatefileRequest, Deployment, + DeploymentGroup, + DeploymentGroupRevision, DeploymentOperationMetadata, + DeploymentOperationSummary, + DeploymentSource, + DeploymentSpec, + DeploymentUnit, + DeploymentUnitProgress, + DeprovisionDeploymentGroupRequest, ExportDeploymentStatefileRequest, ExportLockInfoRequest, ExportPreviewResultRequest, ExportPreviewResultResponse, ExportRevisionStatefileRequest, + ExternalValueSource, GetAutoMigrationConfigRequest, + GetDeploymentGroupRequest, + GetDeploymentGroupRevisionRequest, GetDeploymentRequest, GetPreviewRequest, GetResourceChangeRequest, @@ -45,6 +58,10 @@ GetTerraformVersionRequest, GitSource, ImportStatefileRequest, + ListDeploymentGroupRevisionsRequest, + ListDeploymentGroupRevisionsResponse, + ListDeploymentGroupsRequest, + ListDeploymentGroupsResponse, ListDeploymentsRequest, ListDeploymentsResponse, ListPreviewsRequest, @@ -69,6 +86,8 @@ PropertyChange, PropertyDrift, ProviderConfig, + ProvisionDeploymentGroupOperationMetadata, + ProvisionDeploymentGroupRequest, QuotaValidation, Resource, ResourceCAIInfo, @@ -86,6 +105,7 @@ TerraformVersion, UnlockDeploymentRequest, UpdateAutoMigrationConfigRequest, + UpdateDeploymentGroupRequest, UpdateDeploymentRequest, ) @@ -94,19 +114,32 @@ "ConfigAsyncClient", "ApplyResults", "AutoMigrationConfig", + "CreateDeploymentGroupRequest", "CreateDeploymentRequest", "CreatePreviewRequest", + "DeleteDeploymentGroupRequest", "DeleteDeploymentRequest", "DeletePreviewRequest", "DeleteStatefileRequest", "Deployment", + "DeploymentGroup", + "DeploymentGroupRevision", "DeploymentOperationMetadata", + "DeploymentOperationSummary", + "DeploymentSource", + "DeploymentSpec", + "DeploymentUnit", + "DeploymentUnitProgress", + "DeprovisionDeploymentGroupRequest", "ExportDeploymentStatefileRequest", "ExportLockInfoRequest", "ExportPreviewResultRequest", "ExportPreviewResultResponse", "ExportRevisionStatefileRequest", + "ExternalValueSource", "GetAutoMigrationConfigRequest", + "GetDeploymentGroupRequest", + "GetDeploymentGroupRevisionRequest", "GetDeploymentRequest", "GetPreviewRequest", "GetResourceChangeRequest", @@ -116,6 +149,10 @@ "GetTerraformVersionRequest", "GitSource", "ImportStatefileRequest", + "ListDeploymentGroupRevisionsRequest", + "ListDeploymentGroupRevisionsResponse", + "ListDeploymentGroupsRequest", + "ListDeploymentGroupsResponse", "ListDeploymentsRequest", "ListDeploymentsResponse", "ListPreviewsRequest", @@ -140,6 +177,8 @@ "PropertyChange", "PropertyDrift", "ProviderConfig", + "ProvisionDeploymentGroupOperationMetadata", + "ProvisionDeploymentGroupRequest", "Resource", "ResourceCAIInfo", "ResourceChange", @@ -156,6 +195,7 @@ "TerraformVersion", "UnlockDeploymentRequest", "UpdateAutoMigrationConfigRequest", + "UpdateDeploymentGroupRequest", "UpdateDeploymentRequest", "QuotaValidation", ) diff --git a/packages/google-cloud-config/google/cloud/config_v1/__init__.py b/packages/google-cloud-config/google/cloud/config_v1/__init__.py index ba61f7e34884..58883a570f9b 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/__init__.py +++ b/packages/google-cloud-config/google/cloud/config_v1/__init__.py @@ -33,19 +33,32 @@ from .types.config import ( ApplyResults, AutoMigrationConfig, + CreateDeploymentGroupRequest, CreateDeploymentRequest, CreatePreviewRequest, + DeleteDeploymentGroupRequest, DeleteDeploymentRequest, DeletePreviewRequest, DeleteStatefileRequest, Deployment, + DeploymentGroup, + DeploymentGroupRevision, DeploymentOperationMetadata, + DeploymentOperationSummary, + DeploymentSource, + DeploymentSpec, + DeploymentUnit, + DeploymentUnitProgress, + DeprovisionDeploymentGroupRequest, ExportDeploymentStatefileRequest, ExportLockInfoRequest, ExportPreviewResultRequest, ExportPreviewResultResponse, ExportRevisionStatefileRequest, + ExternalValueSource, GetAutoMigrationConfigRequest, + GetDeploymentGroupRequest, + GetDeploymentGroupRevisionRequest, GetDeploymentRequest, GetPreviewRequest, GetResourceChangeRequest, @@ -55,6 +68,10 @@ GetTerraformVersionRequest, GitSource, ImportStatefileRequest, + ListDeploymentGroupRevisionsRequest, + ListDeploymentGroupRevisionsResponse, + ListDeploymentGroupsRequest, + ListDeploymentGroupsResponse, ListDeploymentsRequest, ListDeploymentsResponse, ListPreviewsRequest, @@ -79,6 +96,8 @@ PropertyChange, PropertyDrift, ProviderConfig, + ProvisionDeploymentGroupOperationMetadata, + ProvisionDeploymentGroupRequest, QuotaValidation, Resource, ResourceCAIInfo, @@ -96,6 +115,7 @@ TerraformVersion, UnlockDeploymentRequest, UpdateAutoMigrationConfigRequest, + UpdateDeploymentGroupRequest, UpdateDeploymentRequest, ) @@ -198,19 +218,32 @@ def _get_version(dependency_name): "ApplyResults", "AutoMigrationConfig", "ConfigClient", + "CreateDeploymentGroupRequest", "CreateDeploymentRequest", "CreatePreviewRequest", + "DeleteDeploymentGroupRequest", "DeleteDeploymentRequest", "DeletePreviewRequest", "DeleteStatefileRequest", "Deployment", + "DeploymentGroup", + "DeploymentGroupRevision", "DeploymentOperationMetadata", + "DeploymentOperationSummary", + "DeploymentSource", + "DeploymentSpec", + "DeploymentUnit", + "DeploymentUnitProgress", + "DeprovisionDeploymentGroupRequest", "ExportDeploymentStatefileRequest", "ExportLockInfoRequest", "ExportPreviewResultRequest", "ExportPreviewResultResponse", "ExportRevisionStatefileRequest", + "ExternalValueSource", "GetAutoMigrationConfigRequest", + "GetDeploymentGroupRequest", + "GetDeploymentGroupRevisionRequest", "GetDeploymentRequest", "GetPreviewRequest", "GetResourceChangeRequest", @@ -220,6 +253,10 @@ def _get_version(dependency_name): "GetTerraformVersionRequest", "GitSource", "ImportStatefileRequest", + "ListDeploymentGroupRevisionsRequest", + "ListDeploymentGroupRevisionsResponse", + "ListDeploymentGroupsRequest", + "ListDeploymentGroupsResponse", "ListDeploymentsRequest", "ListDeploymentsResponse", "ListPreviewsRequest", @@ -244,6 +281,8 @@ def _get_version(dependency_name): "PropertyChange", "PropertyDrift", "ProviderConfig", + "ProvisionDeploymentGroupOperationMetadata", + "ProvisionDeploymentGroupRequest", "QuotaValidation", "Resource", "ResourceCAIInfo", @@ -261,5 +300,6 @@ def _get_version(dependency_name): "TerraformVersion", "UnlockDeploymentRequest", "UpdateAutoMigrationConfigRequest", + "UpdateDeploymentGroupRequest", "UpdateDeploymentRequest", ) diff --git a/packages/google-cloud-config/google/cloud/config_v1/gapic_metadata.json b/packages/google-cloud-config/google/cloud/config_v1/gapic_metadata.json index 746d54e27899..acde226fec42 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/gapic_metadata.json +++ b/packages/google-cloud-config/google/cloud/config_v1/gapic_metadata.json @@ -15,6 +15,11 @@ "create_deployment" ] }, + "CreateDeploymentGroup": { + "methods": [ + "create_deployment_group" + ] + }, "CreatePreview": { "methods": [ "create_preview" @@ -25,6 +30,11 @@ "delete_deployment" ] }, + "DeleteDeploymentGroup": { + "methods": [ + "delete_deployment_group" + ] + }, "DeletePreview": { "methods": [ "delete_preview" @@ -35,6 +45,11 @@ "delete_statefile" ] }, + "DeprovisionDeploymentGroup": { + "methods": [ + "deprovision_deployment_group" + ] + }, "ExportDeploymentStatefile": { "methods": [ "export_deployment_statefile" @@ -65,6 +80,16 @@ "get_deployment" ] }, + "GetDeploymentGroup": { + "methods": [ + "get_deployment_group" + ] + }, + "GetDeploymentGroupRevision": { + "methods": [ + "get_deployment_group_revision" + ] + }, "GetPreview": { "methods": [ "get_preview" @@ -100,6 +125,16 @@ "import_statefile" ] }, + "ListDeploymentGroupRevisions": { + "methods": [ + "list_deployment_group_revisions" + ] + }, + "ListDeploymentGroups": { + "methods": [ + "list_deployment_groups" + ] + }, "ListDeployments": { "methods": [ "list_deployments" @@ -140,6 +175,11 @@ "lock_deployment" ] }, + "ProvisionDeploymentGroup": { + "methods": [ + "provision_deployment_group" + ] + }, "UnlockDeployment": { "methods": [ "unlock_deployment" @@ -154,6 +194,11 @@ "methods": [ "update_deployment" ] + }, + "UpdateDeploymentGroup": { + "methods": [ + "update_deployment_group" + ] } } }, @@ -165,6 +210,11 @@ "create_deployment" ] }, + "CreateDeploymentGroup": { + "methods": [ + "create_deployment_group" + ] + }, "CreatePreview": { "methods": [ "create_preview" @@ -175,6 +225,11 @@ "delete_deployment" ] }, + "DeleteDeploymentGroup": { + "methods": [ + "delete_deployment_group" + ] + }, "DeletePreview": { "methods": [ "delete_preview" @@ -185,6 +240,11 @@ "delete_statefile" ] }, + "DeprovisionDeploymentGroup": { + "methods": [ + "deprovision_deployment_group" + ] + }, "ExportDeploymentStatefile": { "methods": [ "export_deployment_statefile" @@ -215,6 +275,16 @@ "get_deployment" ] }, + "GetDeploymentGroup": { + "methods": [ + "get_deployment_group" + ] + }, + "GetDeploymentGroupRevision": { + "methods": [ + "get_deployment_group_revision" + ] + }, "GetPreview": { "methods": [ "get_preview" @@ -250,6 +320,16 @@ "import_statefile" ] }, + "ListDeploymentGroupRevisions": { + "methods": [ + "list_deployment_group_revisions" + ] + }, + "ListDeploymentGroups": { + "methods": [ + "list_deployment_groups" + ] + }, "ListDeployments": { "methods": [ "list_deployments" @@ -290,6 +370,11 @@ "lock_deployment" ] }, + "ProvisionDeploymentGroup": { + "methods": [ + "provision_deployment_group" + ] + }, "UnlockDeployment": { "methods": [ "unlock_deployment" @@ -304,6 +389,11 @@ "methods": [ "update_deployment" ] + }, + "UpdateDeploymentGroup": { + "methods": [ + "update_deployment_group" + ] } } }, @@ -315,6 +405,11 @@ "create_deployment" ] }, + "CreateDeploymentGroup": { + "methods": [ + "create_deployment_group" + ] + }, "CreatePreview": { "methods": [ "create_preview" @@ -325,6 +420,11 @@ "delete_deployment" ] }, + "DeleteDeploymentGroup": { + "methods": [ + "delete_deployment_group" + ] + }, "DeletePreview": { "methods": [ "delete_preview" @@ -335,6 +435,11 @@ "delete_statefile" ] }, + "DeprovisionDeploymentGroup": { + "methods": [ + "deprovision_deployment_group" + ] + }, "ExportDeploymentStatefile": { "methods": [ "export_deployment_statefile" @@ -365,6 +470,16 @@ "get_deployment" ] }, + "GetDeploymentGroup": { + "methods": [ + "get_deployment_group" + ] + }, + "GetDeploymentGroupRevision": { + "methods": [ + "get_deployment_group_revision" + ] + }, "GetPreview": { "methods": [ "get_preview" @@ -400,6 +515,16 @@ "import_statefile" ] }, + "ListDeploymentGroupRevisions": { + "methods": [ + "list_deployment_group_revisions" + ] + }, + "ListDeploymentGroups": { + "methods": [ + "list_deployment_groups" + ] + }, "ListDeployments": { "methods": [ "list_deployments" @@ -440,6 +565,11 @@ "lock_deployment" ] }, + "ProvisionDeploymentGroup": { + "methods": [ + "provision_deployment_group" + ] + }, "UnlockDeployment": { "methods": [ "unlock_deployment" @@ -454,6 +584,11 @@ "methods": [ "update_deployment" ] + }, + "UpdateDeploymentGroup": { + "methods": [ + "update_deployment_group" + ] } } } diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/async_client.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/async_client.py index 4e11dbd7aad0..9803e8b14b4e 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/async_client.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/async_client.py @@ -95,6 +95,14 @@ class ConfigAsyncClient: ) deployment_path = staticmethod(ConfigClient.deployment_path) parse_deployment_path = staticmethod(ConfigClient.parse_deployment_path) + deployment_group_path = staticmethod(ConfigClient.deployment_group_path) + parse_deployment_group_path = staticmethod(ConfigClient.parse_deployment_group_path) + deployment_group_revision_path = staticmethod( + ConfigClient.deployment_group_revision_path + ) + parse_deployment_group_revision_path = staticmethod( + ConfigClient.parse_deployment_group_revision_path + ) preview_path = staticmethod(ConfigClient.preview_path) parse_preview_path = staticmethod(ConfigClient.parse_preview_path) resource_path = staticmethod(ConfigClient.resource_path) @@ -3805,6 +3813,1185 @@ async def sample_update_auto_migration_config(): # Done; return the response. return response + async def get_deployment_group( + self, + request: Optional[Union[config.GetDeploymentGroupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> config.DeploymentGroup: + r"""Get a DeploymentGroup for a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_get_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.GetDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_deployment_group(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.GetDeploymentGroupRequest, dict]]): + The request object. The request message for the + GetDeploymentGroup method. + name (:class:`str`): + Required. The name of the deployment group to retrieve. + Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.config_v1.types.DeploymentGroup: + A DeploymentGroup is a collection of + DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.GetDeploymentGroupRequest): + request = config.GetDeploymentGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_deployment_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_deployment_group( + self, + request: Optional[Union[config.CreateDeploymentGroupRequest, dict]] = None, + *, + parent: Optional[str] = None, + deployment_group: Optional[config.DeploymentGroup] = None, + deployment_group_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] The + newly created DeploymentGroup will be in the ``CREATING`` state + and can be retrieved via Get and List calls. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_create_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.CreateDeploymentGroupRequest( + parent="parent_value", + deployment_group_id="deployment_group_id_value", + ) + + # Make the request + operation = client.create_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.CreateDeploymentGroupRequest, dict]]): + The request object. A request to create a deployment + group + parent (:class:`str`): + Required. The parent in whose context the Deployment + Group is created. The parent value is in the format: + 'projects/{project_id}/locations/{location}' + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + deployment_group (:class:`google.cloud.config_v1.types.DeploymentGroup`): + Required. [Deployment Group][] resource to create + This corresponds to the ``deployment_group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + deployment_group_id (:class:`str`): + Required. The deployment group ID. + This corresponds to the ``deployment_group_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, deployment_group, deployment_group_id] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.CreateDeploymentGroupRequest): + request = config.CreateDeploymentGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if deployment_group is not None: + request.deployment_group = deployment_group + if deployment_group_id is not None: + request.deployment_group_id = deployment_group_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_deployment_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_deployment_group( + self, + request: Optional[Union[config.UpdateDeploymentGroupRequest, dict]] = None, + *, + deployment_group: Optional[config.DeploymentGroup] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_update_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.UpdateDeploymentGroupRequest( + ) + + # Make the request + operation = client.update_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.UpdateDeploymentGroupRequest, dict]]): + The request object. A request message for updating a + deployment group + deployment_group (:class:`google.cloud.config_v1.types.DeploymentGroup`): + Required. + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + to update. + + The deployment group's ``name`` field is used to + identify the resource to be updated. Format: + ``projects/{project}/locations/{location}/deploymentGroups/{deployment_group_id}`` + + This corresponds to the ``deployment_group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. Field mask used to specify the fields to be + overwritten in the Deployment Group resource by the + update. + + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [deployment_group, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.UpdateDeploymentGroupRequest): + request = config.UpdateDeploymentGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if deployment_group is not None: + request.deployment_group = deployment_group + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_deployment_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("deployment_group.name", request.deployment_group.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_deployment_group( + self, + request: Optional[Union[config.DeleteDeploymentGroupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_delete_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.DeleteDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.DeleteDeploymentGroupRequest, dict]]): + The request object. Request message for Delete + DeploymentGroup + name (:class:`str`): + Required. The name of DeploymentGroup in the format + projects/{project_id}/locations/{location_id}/deploymentGroups/{deploymentGroup} + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.DeleteDeploymentGroupRequest): + request = config.DeleteDeploymentGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_deployment_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_deployment_groups( + self, + request: Optional[Union[config.ListDeploymentGroupsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListDeploymentGroupsAsyncPager: + r"""List DeploymentGroups for a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_list_deployment_groups(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.ListDeploymentGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployment_groups(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.ListDeploymentGroupsRequest, dict]]): + The request object. The request message for the + ListDeploymentGroups method. + parent (:class:`str`): + Required. The parent, which owns this collection of + deployment groups. Format: + 'projects/{project_id}/locations/{location}'. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.config_v1.services.config.pagers.ListDeploymentGroupsAsyncPager: + The response message for the + ListDeploymentGroups method. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.ListDeploymentGroupsRequest): + request = config.ListDeploymentGroupsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_deployment_groups + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListDeploymentGroupsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def provision_deployment_group( + self, + request: Optional[Union[config.ProvisionDeploymentGroupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Provisions a deployment group. + + NOTE: As a first step of this operation, Infra Manager will + automatically delete any Deployments that were part of the *last + successful* + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision] + but are *no longer* included in the *current* + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + definition (e.g., following an ``UpdateDeploymentGroup`` call), + along with their actuated resources. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_provision_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.ProvisionDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.provision_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.ProvisionDeploymentGroupRequest, dict]]): + The request object. The request message for the + ProvisionDeploymentGroup method. + name (:class:`str`): + Required. The name of the deployment group to provision. + Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.ProvisionDeploymentGroupRequest): + request = config.ProvisionDeploymentGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.provision_deployment_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + async def deprovision_deployment_group( + self, + request: Optional[Union[config.DeprovisionDeploymentGroupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deprovisions a deployment group. + + NOTE: As a first step of this operation, Infra Manager will + automatically delete any Deployments that were part of the *last + successful* + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision] + but are *no longer* included in the *current* + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + definition (e.g., following an ``UpdateDeploymentGroup`` call), + along with their actuated resources. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_deprovision_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.DeprovisionDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.deprovision_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.DeprovisionDeploymentGroupRequest, dict]]): + The request object. The request message for the + DeprovisionDeploymentGroup method. + name (:class:`str`): + Required. The name of the deployment group to + deprovision. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.DeprovisionDeploymentGroupRequest): + request = config.DeprovisionDeploymentGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.deprovision_deployment_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_deployment_group_revision( + self, + request: Optional[Union[config.GetDeploymentGroupRevisionRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> config.DeploymentGroupRevision: + r"""Gets details about a + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision]. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_get_deployment_group_revision(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.GetDeploymentGroupRevisionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_deployment_group_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.GetDeploymentGroupRevisionRequest, dict]]): + The request object. The request message for the + GetDeploymentGroupRevision method. + name (:class:`str`): + Required. The name of the deployment group revision to + retrieve. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}/revisions/{revision}'. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.config_v1.types.DeploymentGroupRevision: + A DeploymentGroupRevision represents a snapshot of a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + at a given point in time, created when a + DeploymentGroup is provisioned or deprovisioned. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.GetDeploymentGroupRevisionRequest): + request = config.GetDeploymentGroupRevisionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_deployment_group_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_deployment_group_revisions( + self, + request: Optional[ + Union[config.ListDeploymentGroupRevisionsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListDeploymentGroupRevisionsAsyncPager: + r"""Lists + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision]s + in a given + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup]. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + async def sample_list_deployment_group_revisions(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.ListDeploymentGroupRevisionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployment_group_revisions(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.config_v1.types.ListDeploymentGroupRevisionsRequest, dict]]): + The request object. The request message for the + ListDeploymentGroupRevisions method. + parent (:class:`str`): + Required. The parent, which owns this collection of + deployment group revisions. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.config_v1.services.config.pagers.ListDeploymentGroupRevisionsAsyncPager: + The response message for the + ListDeploymentGroupRevisions method. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.ListDeploymentGroupRevisionsRequest): + request = config.ListDeploymentGroupRevisionsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_deployment_group_revisions + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListDeploymentGroupRevisionsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def list_operations( self, request: Optional[Union[operations_pb2.ListOperationsRequest, dict]] = None, diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/client.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/client.py index 57559a5bbf07..e184d24fcc8e 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/client.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/client.py @@ -286,6 +286,52 @@ def parse_deployment_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def deployment_group_path( + project: str, + location: str, + deployment_group: str, + ) -> str: + """Returns a fully-qualified deployment_group string.""" + return "projects/{project}/locations/{location}/deploymentGroups/{deployment_group}".format( + project=project, + location=location, + deployment_group=deployment_group, + ) + + @staticmethod + def parse_deployment_group_path(path: str) -> Dict[str, str]: + """Parses a deployment_group path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/deploymentGroups/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def deployment_group_revision_path( + project: str, + location: str, + deployment_group: str, + revision: str, + ) -> str: + """Returns a fully-qualified deployment_group_revision string.""" + return "projects/{project}/locations/{location}/deploymentGroups/{deployment_group}/revisions/{revision}".format( + project=project, + location=location, + deployment_group=deployment_group, + revision=revision, + ) + + @staticmethod + def parse_deployment_group_revision_path(path: str) -> Dict[str, str]: + """Parses a deployment_group_revision path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/deploymentGroups/(?P.+?)/revisions/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def preview_path( project: str, @@ -4356,6 +4402,1166 @@ def sample_update_auto_migration_config(): # Done; return the response. return response + def get_deployment_group( + self, + request: Optional[Union[config.GetDeploymentGroupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> config.DeploymentGroup: + r"""Get a DeploymentGroup for a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_get_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.GetDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment_group(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.config_v1.types.GetDeploymentGroupRequest, dict]): + The request object. The request message for the + GetDeploymentGroup method. + name (str): + Required. The name of the deployment group to retrieve. + Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.config_v1.types.DeploymentGroup: + A DeploymentGroup is a collection of + DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.GetDeploymentGroupRequest): + request = config.GetDeploymentGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_deployment_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_deployment_group( + self, + request: Optional[Union[config.CreateDeploymentGroupRequest, dict]] = None, + *, + parent: Optional[str] = None, + deployment_group: Optional[config.DeploymentGroup] = None, + deployment_group_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] The + newly created DeploymentGroup will be in the ``CREATING`` state + and can be retrieved via Get and List calls. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_create_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.CreateDeploymentGroupRequest( + parent="parent_value", + deployment_group_id="deployment_group_id_value", + ) + + # Make the request + operation = client.create_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.config_v1.types.CreateDeploymentGroupRequest, dict]): + The request object. A request to create a deployment + group + parent (str): + Required. The parent in whose context the Deployment + Group is created. The parent value is in the format: + 'projects/{project_id}/locations/{location}' + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + deployment_group (google.cloud.config_v1.types.DeploymentGroup): + Required. [Deployment Group][] resource to create + This corresponds to the ``deployment_group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + deployment_group_id (str): + Required. The deployment group ID. + This corresponds to the ``deployment_group_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, deployment_group, deployment_group_id] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.CreateDeploymentGroupRequest): + request = config.CreateDeploymentGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if deployment_group is not None: + request.deployment_group = deployment_group + if deployment_group_id is not None: + request.deployment_group_id = deployment_group_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_deployment_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_deployment_group( + self, + request: Optional[Union[config.UpdateDeploymentGroupRequest, dict]] = None, + *, + deployment_group: Optional[config.DeploymentGroup] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_update_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.UpdateDeploymentGroupRequest( + ) + + # Make the request + operation = client.update_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.config_v1.types.UpdateDeploymentGroupRequest, dict]): + The request object. A request message for updating a + deployment group + deployment_group (google.cloud.config_v1.types.DeploymentGroup): + Required. + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + to update. + + The deployment group's ``name`` field is used to + identify the resource to be updated. Format: + ``projects/{project}/locations/{location}/deploymentGroups/{deployment_group_id}`` + + This corresponds to the ``deployment_group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask used to specify the fields to be + overwritten in the Deployment Group resource by the + update. + + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [deployment_group, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.UpdateDeploymentGroupRequest): + request = config.UpdateDeploymentGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if deployment_group is not None: + request.deployment_group = deployment_group + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_deployment_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("deployment_group.name", request.deployment_group.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_deployment_group( + self, + request: Optional[Union[config.DeleteDeploymentGroupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_delete_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.DeleteDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.config_v1.types.DeleteDeploymentGroupRequest, dict]): + The request object. Request message for Delete + DeploymentGroup + name (str): + Required. The name of DeploymentGroup in the format + projects/{project_id}/locations/{location_id}/deploymentGroups/{deploymentGroup} + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.DeleteDeploymentGroupRequest): + request = config.DeleteDeploymentGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_deployment_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_deployment_groups( + self, + request: Optional[Union[config.ListDeploymentGroupsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListDeploymentGroupsPager: + r"""List DeploymentGroups for a given project and + location. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_list_deployment_groups(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.ListDeploymentGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployment_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.config_v1.types.ListDeploymentGroupsRequest, dict]): + The request object. The request message for the + ListDeploymentGroups method. + parent (str): + Required. The parent, which owns this collection of + deployment groups. Format: + 'projects/{project_id}/locations/{location}'. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.config_v1.services.config.pagers.ListDeploymentGroupsPager: + The response message for the + ListDeploymentGroups method. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.ListDeploymentGroupsRequest): + request = config.ListDeploymentGroupsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_deployment_groups] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListDeploymentGroupsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def provision_deployment_group( + self, + request: Optional[Union[config.ProvisionDeploymentGroupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Provisions a deployment group. + + NOTE: As a first step of this operation, Infra Manager will + automatically delete any Deployments that were part of the *last + successful* + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision] + but are *no longer* included in the *current* + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + definition (e.g., following an ``UpdateDeploymentGroup`` call), + along with their actuated resources. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_provision_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.ProvisionDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.provision_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.config_v1.types.ProvisionDeploymentGroupRequest, dict]): + The request object. The request message for the + ProvisionDeploymentGroup method. + name (str): + Required. The name of the deployment group to provision. + Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.ProvisionDeploymentGroupRequest): + request = config.ProvisionDeploymentGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.provision_deployment_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + def deprovision_deployment_group( + self, + request: Optional[Union[config.DeprovisionDeploymentGroupRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deprovisions a deployment group. + + NOTE: As a first step of this operation, Infra Manager will + automatically delete any Deployments that were part of the *last + successful* + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision] + but are *no longer* included in the *current* + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + definition (e.g., following an ``UpdateDeploymentGroup`` call), + along with their actuated resources. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_deprovision_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.DeprovisionDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.deprovision_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.config_v1.types.DeprovisionDeploymentGroupRequest, dict]): + The request object. The request message for the + DeprovisionDeploymentGroup method. + name (str): + Required. The name of the deployment group to + deprovision. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.config_v1.types.DeploymentGroup` A DeploymentGroup is a collection of DeploymentUnits that in a DAG-like + structure. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.DeprovisionDeploymentGroupRequest): + request = config.DeprovisionDeploymentGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.deprovision_deployment_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + config.DeploymentGroup, + metadata_type=config.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_deployment_group_revision( + self, + request: Optional[Union[config.GetDeploymentGroupRevisionRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> config.DeploymentGroupRevision: + r"""Gets details about a + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision]. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_get_deployment_group_revision(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.GetDeploymentGroupRevisionRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment_group_revision(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.config_v1.types.GetDeploymentGroupRevisionRequest, dict]): + The request object. The request message for the + GetDeploymentGroupRevision method. + name (str): + Required. The name of the deployment group revision to + retrieve. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}/revisions/{revision}'. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.config_v1.types.DeploymentGroupRevision: + A DeploymentGroupRevision represents a snapshot of a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + at a given point in time, created when a + DeploymentGroup is provisioned or deprovisioned. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.GetDeploymentGroupRevisionRequest): + request = config.GetDeploymentGroupRevisionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.get_deployment_group_revision + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_deployment_group_revisions( + self, + request: Optional[ + Union[config.ListDeploymentGroupRevisionsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListDeploymentGroupRevisionsPager: + r"""Lists + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision]s + in a given + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup]. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import config_v1 + + def sample_list_deployment_group_revisions(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.ListDeploymentGroupRevisionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployment_group_revisions(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.config_v1.types.ListDeploymentGroupRevisionsRequest, dict]): + The request object. The request message for the + ListDeploymentGroupRevisions method. + parent (str): + Required. The parent, which owns this collection of + deployment group revisions. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.config_v1.services.config.pagers.ListDeploymentGroupRevisionsPager: + The response message for the + ListDeploymentGroupRevisions method. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, config.ListDeploymentGroupRevisionsRequest): + request = config.ListDeploymentGroupRevisionsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.list_deployment_group_revisions + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListDeploymentGroupRevisionsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def __enter__(self) -> "ConfigClient": return self diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/pagers.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/pagers.py index 06aaa046b659..5f22454fd153 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/pagers.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/pagers.py @@ -1131,3 +1131,315 @@ async def async_generator(): def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListDeploymentGroupsPager: + """A pager for iterating through ``list_deployment_groups`` requests. + + This class thinly wraps an initial + :class:`google.cloud.config_v1.types.ListDeploymentGroupsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``deployment_groups`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListDeploymentGroups`` requests and continue to iterate + through the ``deployment_groups`` field on the + corresponding responses. + + All the usual :class:`google.cloud.config_v1.types.ListDeploymentGroupsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., config.ListDeploymentGroupsResponse], + request: config.ListDeploymentGroupsRequest, + response: config.ListDeploymentGroupsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.config_v1.types.ListDeploymentGroupsRequest): + The initial request object. + response (google.cloud.config_v1.types.ListDeploymentGroupsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = config.ListDeploymentGroupsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[config.ListDeploymentGroupsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[config.DeploymentGroup]: + for page in self.pages: + yield from page.deployment_groups + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListDeploymentGroupsAsyncPager: + """A pager for iterating through ``list_deployment_groups`` requests. + + This class thinly wraps an initial + :class:`google.cloud.config_v1.types.ListDeploymentGroupsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``deployment_groups`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListDeploymentGroups`` requests and continue to iterate + through the ``deployment_groups`` field on the + corresponding responses. + + All the usual :class:`google.cloud.config_v1.types.ListDeploymentGroupsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[config.ListDeploymentGroupsResponse]], + request: config.ListDeploymentGroupsRequest, + response: config.ListDeploymentGroupsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.config_v1.types.ListDeploymentGroupsRequest): + The initial request object. + response (google.cloud.config_v1.types.ListDeploymentGroupsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = config.ListDeploymentGroupsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[config.ListDeploymentGroupsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[config.DeploymentGroup]: + async def async_generator(): + async for page in self.pages: + for response in page.deployment_groups: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListDeploymentGroupRevisionsPager: + """A pager for iterating through ``list_deployment_group_revisions`` requests. + + This class thinly wraps an initial + :class:`google.cloud.config_v1.types.ListDeploymentGroupRevisionsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``deployment_group_revisions`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListDeploymentGroupRevisions`` requests and continue to iterate + through the ``deployment_group_revisions`` field on the + corresponding responses. + + All the usual :class:`google.cloud.config_v1.types.ListDeploymentGroupRevisionsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., config.ListDeploymentGroupRevisionsResponse], + request: config.ListDeploymentGroupRevisionsRequest, + response: config.ListDeploymentGroupRevisionsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.config_v1.types.ListDeploymentGroupRevisionsRequest): + The initial request object. + response (google.cloud.config_v1.types.ListDeploymentGroupRevisionsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = config.ListDeploymentGroupRevisionsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[config.ListDeploymentGroupRevisionsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[config.DeploymentGroupRevision]: + for page in self.pages: + yield from page.deployment_group_revisions + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListDeploymentGroupRevisionsAsyncPager: + """A pager for iterating through ``list_deployment_group_revisions`` requests. + + This class thinly wraps an initial + :class:`google.cloud.config_v1.types.ListDeploymentGroupRevisionsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``deployment_group_revisions`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListDeploymentGroupRevisions`` requests and continue to iterate + through the ``deployment_group_revisions`` field on the + corresponding responses. + + All the usual :class:`google.cloud.config_v1.types.ListDeploymentGroupRevisionsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[config.ListDeploymentGroupRevisionsResponse]], + request: config.ListDeploymentGroupRevisionsRequest, + response: config.ListDeploymentGroupRevisionsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.config_v1.types.ListDeploymentGroupRevisionsRequest): + The initial request object. + response (google.cloud.config_v1.types.ListDeploymentGroupRevisionsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = config.ListDeploymentGroupRevisionsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[config.ListDeploymentGroupRevisionsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[config.DeploymentGroupRevision]: + async def async_generator(): + async for page in self.pages: + for response in page.deployment_group_revisions: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/base.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/base.py index 4059497f0267..9ad28e561882 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/base.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/base.py @@ -294,6 +294,51 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.get_deployment_group: gapic_v1.method.wrap_method( + self.get_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.create_deployment_group: gapic_v1.method.wrap_method( + self.create_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.update_deployment_group: gapic_v1.method.wrap_method( + self.update_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.delete_deployment_group: gapic_v1.method.wrap_method( + self.delete_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.list_deployment_groups: gapic_v1.method.wrap_method( + self.list_deployment_groups, + default_timeout=None, + client_info=client_info, + ), + self.provision_deployment_group: gapic_v1.method.wrap_method( + self.provision_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.deprovision_deployment_group: gapic_v1.method.wrap_method( + self.deprovision_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.get_deployment_group_revision: gapic_v1.method.wrap_method( + self.get_deployment_group_revision, + default_timeout=None, + client_info=client_info, + ), + self.list_deployment_group_revisions: gapic_v1.method.wrap_method( + self.list_deployment_group_revisions, + default_timeout=None, + client_info=client_info, + ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, @@ -627,6 +672,95 @@ def update_auto_migration_config( ]: raise NotImplementedError() + @property + def get_deployment_group( + self, + ) -> Callable[ + [config.GetDeploymentGroupRequest], + Union[config.DeploymentGroup, Awaitable[config.DeploymentGroup]], + ]: + raise NotImplementedError() + + @property + def create_deployment_group( + self, + ) -> Callable[ + [config.CreateDeploymentGroupRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def update_deployment_group( + self, + ) -> Callable[ + [config.UpdateDeploymentGroupRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def delete_deployment_group( + self, + ) -> Callable[ + [config.DeleteDeploymentGroupRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def list_deployment_groups( + self, + ) -> Callable[ + [config.ListDeploymentGroupsRequest], + Union[ + config.ListDeploymentGroupsResponse, + Awaitable[config.ListDeploymentGroupsResponse], + ], + ]: + raise NotImplementedError() + + @property + def provision_deployment_group( + self, + ) -> Callable[ + [config.ProvisionDeploymentGroupRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def deprovision_deployment_group( + self, + ) -> Callable[ + [config.DeprovisionDeploymentGroupRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def get_deployment_group_revision( + self, + ) -> Callable[ + [config.GetDeploymentGroupRevisionRequest], + Union[ + config.DeploymentGroupRevision, Awaitable[config.DeploymentGroupRevision] + ], + ]: + raise NotImplementedError() + + @property + def list_deployment_group_revisions( + self, + ) -> Callable[ + [config.ListDeploymentGroupRevisionsRequest], + Union[ + config.ListDeploymentGroupRevisionsResponse, + Awaitable[config.ListDeploymentGroupRevisionsResponse], + ], + ]: + raise NotImplementedError() + @property def list_operations( self, diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc.py index 2cf2d8aff6a3..15337e94128a 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc.py @@ -1125,6 +1125,285 @@ def update_auto_migration_config( ) return self._stubs["update_auto_migration_config"] + @property + def get_deployment_group( + self, + ) -> Callable[[config.GetDeploymentGroupRequest], config.DeploymentGroup]: + r"""Return a callable for the get deployment group method over gRPC. + + Get a DeploymentGroup for a given project and + location. + + Returns: + Callable[[~.GetDeploymentGroupRequest], + ~.DeploymentGroup]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_deployment_group" not in self._stubs: + self._stubs["get_deployment_group"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/GetDeploymentGroup", + request_serializer=config.GetDeploymentGroupRequest.serialize, + response_deserializer=config.DeploymentGroup.deserialize, + ) + return self._stubs["get_deployment_group"] + + @property + def create_deployment_group( + self, + ) -> Callable[[config.CreateDeploymentGroupRequest], operations_pb2.Operation]: + r"""Return a callable for the create deployment group method over gRPC. + + Creates a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] The + newly created DeploymentGroup will be in the ``CREATING`` state + and can be retrieved via Get and List calls. + + Returns: + Callable[[~.CreateDeploymentGroupRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_deployment_group" not in self._stubs: + self._stubs["create_deployment_group"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/CreateDeploymentGroup", + request_serializer=config.CreateDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_deployment_group"] + + @property + def update_deployment_group( + self, + ) -> Callable[[config.UpdateDeploymentGroupRequest], operations_pb2.Operation]: + r"""Return a callable for the update deployment group method over gRPC. + + Updates a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + + Returns: + Callable[[~.UpdateDeploymentGroupRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_deployment_group" not in self._stubs: + self._stubs["update_deployment_group"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/UpdateDeploymentGroup", + request_serializer=config.UpdateDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_deployment_group"] + + @property + def delete_deployment_group( + self, + ) -> Callable[[config.DeleteDeploymentGroupRequest], operations_pb2.Operation]: + r"""Return a callable for the delete deployment group method over gRPC. + + Deletes a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + + Returns: + Callable[[~.DeleteDeploymentGroupRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_deployment_group" not in self._stubs: + self._stubs["delete_deployment_group"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/DeleteDeploymentGroup", + request_serializer=config.DeleteDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_deployment_group"] + + @property + def list_deployment_groups( + self, + ) -> Callable[ + [config.ListDeploymentGroupsRequest], config.ListDeploymentGroupsResponse + ]: + r"""Return a callable for the list deployment groups method over gRPC. + + List DeploymentGroups for a given project and + location. + + Returns: + Callable[[~.ListDeploymentGroupsRequest], + ~.ListDeploymentGroupsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_deployment_groups" not in self._stubs: + self._stubs["list_deployment_groups"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/ListDeploymentGroups", + request_serializer=config.ListDeploymentGroupsRequest.serialize, + response_deserializer=config.ListDeploymentGroupsResponse.deserialize, + ) + return self._stubs["list_deployment_groups"] + + @property + def provision_deployment_group( + self, + ) -> Callable[[config.ProvisionDeploymentGroupRequest], operations_pb2.Operation]: + r"""Return a callable for the provision deployment group method over gRPC. + + Provisions a deployment group. + + NOTE: As a first step of this operation, Infra Manager will + automatically delete any Deployments that were part of the *last + successful* + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision] + but are *no longer* included in the *current* + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + definition (e.g., following an ``UpdateDeploymentGroup`` call), + along with their actuated resources. + + Returns: + Callable[[~.ProvisionDeploymentGroupRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "provision_deployment_group" not in self._stubs: + self._stubs["provision_deployment_group"] = ( + self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/ProvisionDeploymentGroup", + request_serializer=config.ProvisionDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + ) + return self._stubs["provision_deployment_group"] + + @property + def deprovision_deployment_group( + self, + ) -> Callable[[config.DeprovisionDeploymentGroupRequest], operations_pb2.Operation]: + r"""Return a callable for the deprovision deployment group method over gRPC. + + Deprovisions a deployment group. + + NOTE: As a first step of this operation, Infra Manager will + automatically delete any Deployments that were part of the *last + successful* + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision] + but are *no longer* included in the *current* + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + definition (e.g., following an ``UpdateDeploymentGroup`` call), + along with their actuated resources. + + Returns: + Callable[[~.DeprovisionDeploymentGroupRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "deprovision_deployment_group" not in self._stubs: + self._stubs["deprovision_deployment_group"] = ( + self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/DeprovisionDeploymentGroup", + request_serializer=config.DeprovisionDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + ) + return self._stubs["deprovision_deployment_group"] + + @property + def get_deployment_group_revision( + self, + ) -> Callable[ + [config.GetDeploymentGroupRevisionRequest], config.DeploymentGroupRevision + ]: + r"""Return a callable for the get deployment group revision method over gRPC. + + Gets details about a + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision]. + + Returns: + Callable[[~.GetDeploymentGroupRevisionRequest], + ~.DeploymentGroupRevision]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_deployment_group_revision" not in self._stubs: + self._stubs["get_deployment_group_revision"] = ( + self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/GetDeploymentGroupRevision", + request_serializer=config.GetDeploymentGroupRevisionRequest.serialize, + response_deserializer=config.DeploymentGroupRevision.deserialize, + ) + ) + return self._stubs["get_deployment_group_revision"] + + @property + def list_deployment_group_revisions( + self, + ) -> Callable[ + [config.ListDeploymentGroupRevisionsRequest], + config.ListDeploymentGroupRevisionsResponse, + ]: + r"""Return a callable for the list deployment group + revisions method over gRPC. + + Lists + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision]s + in a given + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup]. + + Returns: + Callable[[~.ListDeploymentGroupRevisionsRequest], + ~.ListDeploymentGroupRevisionsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_deployment_group_revisions" not in self._stubs: + self._stubs["list_deployment_group_revisions"] = ( + self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/ListDeploymentGroupRevisions", + request_serializer=config.ListDeploymentGroupRevisionsRequest.serialize, + response_deserializer=config.ListDeploymentGroupRevisionsResponse.deserialize, + ) + ) + return self._stubs["list_deployment_group_revisions"] + def close(self): self._logged_channel.close() diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc_asyncio.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc_asyncio.py index 5d4daf465a81..a8955b250379 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc_asyncio.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc_asyncio.py @@ -1164,6 +1164,299 @@ def update_auto_migration_config( ) return self._stubs["update_auto_migration_config"] + @property + def get_deployment_group( + self, + ) -> Callable[ + [config.GetDeploymentGroupRequest], Awaitable[config.DeploymentGroup] + ]: + r"""Return a callable for the get deployment group method over gRPC. + + Get a DeploymentGroup for a given project and + location. + + Returns: + Callable[[~.GetDeploymentGroupRequest], + Awaitable[~.DeploymentGroup]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_deployment_group" not in self._stubs: + self._stubs["get_deployment_group"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/GetDeploymentGroup", + request_serializer=config.GetDeploymentGroupRequest.serialize, + response_deserializer=config.DeploymentGroup.deserialize, + ) + return self._stubs["get_deployment_group"] + + @property + def create_deployment_group( + self, + ) -> Callable[ + [config.CreateDeploymentGroupRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the create deployment group method over gRPC. + + Creates a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] The + newly created DeploymentGroup will be in the ``CREATING`` state + and can be retrieved via Get and List calls. + + Returns: + Callable[[~.CreateDeploymentGroupRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_deployment_group" not in self._stubs: + self._stubs["create_deployment_group"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/CreateDeploymentGroup", + request_serializer=config.CreateDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_deployment_group"] + + @property + def update_deployment_group( + self, + ) -> Callable[ + [config.UpdateDeploymentGroupRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the update deployment group method over gRPC. + + Updates a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + + Returns: + Callable[[~.UpdateDeploymentGroupRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_deployment_group" not in self._stubs: + self._stubs["update_deployment_group"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/UpdateDeploymentGroup", + request_serializer=config.UpdateDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_deployment_group"] + + @property + def delete_deployment_group( + self, + ) -> Callable[ + [config.DeleteDeploymentGroupRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the delete deployment group method over gRPC. + + Deletes a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + + Returns: + Callable[[~.DeleteDeploymentGroupRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_deployment_group" not in self._stubs: + self._stubs["delete_deployment_group"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/DeleteDeploymentGroup", + request_serializer=config.DeleteDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_deployment_group"] + + @property + def list_deployment_groups( + self, + ) -> Callable[ + [config.ListDeploymentGroupsRequest], + Awaitable[config.ListDeploymentGroupsResponse], + ]: + r"""Return a callable for the list deployment groups method over gRPC. + + List DeploymentGroups for a given project and + location. + + Returns: + Callable[[~.ListDeploymentGroupsRequest], + Awaitable[~.ListDeploymentGroupsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_deployment_groups" not in self._stubs: + self._stubs["list_deployment_groups"] = self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/ListDeploymentGroups", + request_serializer=config.ListDeploymentGroupsRequest.serialize, + response_deserializer=config.ListDeploymentGroupsResponse.deserialize, + ) + return self._stubs["list_deployment_groups"] + + @property + def provision_deployment_group( + self, + ) -> Callable[ + [config.ProvisionDeploymentGroupRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the provision deployment group method over gRPC. + + Provisions a deployment group. + + NOTE: As a first step of this operation, Infra Manager will + automatically delete any Deployments that were part of the *last + successful* + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision] + but are *no longer* included in the *current* + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + definition (e.g., following an ``UpdateDeploymentGroup`` call), + along with their actuated resources. + + Returns: + Callable[[~.ProvisionDeploymentGroupRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "provision_deployment_group" not in self._stubs: + self._stubs["provision_deployment_group"] = ( + self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/ProvisionDeploymentGroup", + request_serializer=config.ProvisionDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + ) + return self._stubs["provision_deployment_group"] + + @property + def deprovision_deployment_group( + self, + ) -> Callable[ + [config.DeprovisionDeploymentGroupRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the deprovision deployment group method over gRPC. + + Deprovisions a deployment group. + + NOTE: As a first step of this operation, Infra Manager will + automatically delete any Deployments that were part of the *last + successful* + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision] + but are *no longer* included in the *current* + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + definition (e.g., following an ``UpdateDeploymentGroup`` call), + along with their actuated resources. + + Returns: + Callable[[~.DeprovisionDeploymentGroupRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "deprovision_deployment_group" not in self._stubs: + self._stubs["deprovision_deployment_group"] = ( + self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/DeprovisionDeploymentGroup", + request_serializer=config.DeprovisionDeploymentGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + ) + return self._stubs["deprovision_deployment_group"] + + @property + def get_deployment_group_revision( + self, + ) -> Callable[ + [config.GetDeploymentGroupRevisionRequest], + Awaitable[config.DeploymentGroupRevision], + ]: + r"""Return a callable for the get deployment group revision method over gRPC. + + Gets details about a + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision]. + + Returns: + Callable[[~.GetDeploymentGroupRevisionRequest], + Awaitable[~.DeploymentGroupRevision]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_deployment_group_revision" not in self._stubs: + self._stubs["get_deployment_group_revision"] = ( + self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/GetDeploymentGroupRevision", + request_serializer=config.GetDeploymentGroupRevisionRequest.serialize, + response_deserializer=config.DeploymentGroupRevision.deserialize, + ) + ) + return self._stubs["get_deployment_group_revision"] + + @property + def list_deployment_group_revisions( + self, + ) -> Callable[ + [config.ListDeploymentGroupRevisionsRequest], + Awaitable[config.ListDeploymentGroupRevisionsResponse], + ]: + r"""Return a callable for the list deployment group + revisions method over gRPC. + + Lists + [DeploymentGroupRevision][google.cloud.config.v1.DeploymentGroupRevision]s + in a given + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup]. + + Returns: + Callable[[~.ListDeploymentGroupRevisionsRequest], + Awaitable[~.ListDeploymentGroupRevisionsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_deployment_group_revisions" not in self._stubs: + self._stubs["list_deployment_group_revisions"] = ( + self._logged_channel.unary_unary( + "/google.cloud.config.v1.Config/ListDeploymentGroupRevisions", + request_serializer=config.ListDeploymentGroupRevisionsRequest.serialize, + response_deserializer=config.ListDeploymentGroupRevisionsResponse.deserialize, + ) + ) + return self._stubs["list_deployment_group_revisions"] + def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { @@ -1312,6 +1605,51 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.get_deployment_group: self._wrap_method( + self.get_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.create_deployment_group: self._wrap_method( + self.create_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.update_deployment_group: self._wrap_method( + self.update_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.delete_deployment_group: self._wrap_method( + self.delete_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.list_deployment_groups: self._wrap_method( + self.list_deployment_groups, + default_timeout=None, + client_info=client_info, + ), + self.provision_deployment_group: self._wrap_method( + self.provision_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.deprovision_deployment_group: self._wrap_method( + self.deprovision_deployment_group, + default_timeout=None, + client_info=client_info, + ), + self.get_deployment_group_revision: self._wrap_method( + self.get_deployment_group_revision, + default_timeout=None, + client_info=client_info, + ), + self.list_deployment_group_revisions: self._wrap_method( + self.list_deployment_group_revisions, + default_timeout=None, + client_info=client_info, + ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest.py index c07961a3d7f5..63229fb1d76b 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest.py @@ -87,6 +87,14 @@ def post_create_deployment(self, response): logging.log(f"Received response: {response}") return response + def pre_create_deployment_group(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_deployment_group(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_preview(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -103,6 +111,14 @@ def post_delete_deployment(self, response): logging.log(f"Received response: {response}") return response + def pre_delete_deployment_group(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_deployment_group(self, response): + logging.log(f"Received response: {response}") + return response + def pre_delete_preview(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -115,6 +131,14 @@ def pre_delete_statefile(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata + def pre_deprovision_deployment_group(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_deprovision_deployment_group(self, response): + logging.log(f"Received response: {response}") + return response + def pre_export_deployment_statefile(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -163,6 +187,22 @@ def post_get_deployment(self, response): logging.log(f"Received response: {response}") return response + def pre_get_deployment_group(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_deployment_group(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_deployment_group_revision(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_deployment_group_revision(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_preview(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -219,6 +259,22 @@ def post_import_statefile(self, response): logging.log(f"Received response: {response}") return response + def pre_list_deployment_group_revisions(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_deployment_group_revisions(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_deployment_groups(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_deployment_groups(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_deployments(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -283,6 +339,14 @@ def post_lock_deployment(self, response): logging.log(f"Received response: {response}") return response + def pre_provision_deployment_group(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_provision_deployment_group(self, response): + logging.log(f"Received response: {response}") + return response + def pre_unlock_deployment(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -307,6 +371,14 @@ def post_update_deployment(self, response): logging.log(f"Received response: {response}") return response + def pre_update_deployment_group(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_deployment_group(self, response): + logging.log(f"Received response: {response}") + return response + transport = ConfigRestTransport(interceptor=MyCustomConfigInterceptor()) client = ConfigClient(transport=transport) @@ -359,6 +431,54 @@ def post_create_deployment_with_metadata( """ return response, metadata + def pre_create_deployment_group( + self, + request: config.CreateDeploymentGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.CreateDeploymentGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for create_deployment_group + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_create_deployment_group( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_deployment_group + + DEPRECATED. Please use the `post_create_deployment_group_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_create_deployment_group` interceptor runs + before the `post_create_deployment_group_with_metadata` interceptor. + """ + return response + + def post_create_deployment_group_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_deployment_group + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_create_deployment_group_with_metadata` + interceptor in new development instead of the `post_create_deployment_group` interceptor. + When both interceptors are used, this `post_create_deployment_group_with_metadata` interceptor runs after the + `post_create_deployment_group` interceptor. The (possibly modified) response returned by + `post_create_deployment_group` will be passed to + `post_create_deployment_group_with_metadata`. + """ + return response, metadata + def pre_create_preview( self, request: config.CreatePreviewRequest, @@ -451,6 +571,54 @@ def post_delete_deployment_with_metadata( """ return response, metadata + def pre_delete_deployment_group( + self, + request: config.DeleteDeploymentGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.DeleteDeploymentGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for delete_deployment_group + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_delete_deployment_group( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_deployment_group + + DEPRECATED. Please use the `post_delete_deployment_group_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_delete_deployment_group` interceptor runs + before the `post_delete_deployment_group_with_metadata` interceptor. + """ + return response + + def post_delete_deployment_group_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_deployment_group + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_delete_deployment_group_with_metadata` + interceptor in new development instead of the `post_delete_deployment_group` interceptor. + When both interceptors are used, this `post_delete_deployment_group_with_metadata` interceptor runs after the + `post_delete_deployment_group` interceptor. The (possibly modified) response returned by + `post_delete_deployment_group` will be passed to + `post_delete_deployment_group_with_metadata`. + """ + return response, metadata + def pre_delete_preview( self, request: config.DeletePreviewRequest, @@ -509,6 +677,55 @@ def pre_delete_statefile( """ return request, metadata + def pre_deprovision_deployment_group( + self, + request: config.DeprovisionDeploymentGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.DeprovisionDeploymentGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for deprovision_deployment_group + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_deprovision_deployment_group( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for deprovision_deployment_group + + DEPRECATED. Please use the `post_deprovision_deployment_group_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_deprovision_deployment_group` interceptor runs + before the `post_deprovision_deployment_group_with_metadata` interceptor. + """ + return response + + def post_deprovision_deployment_group_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for deprovision_deployment_group + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_deprovision_deployment_group_with_metadata` + interceptor in new development instead of the `post_deprovision_deployment_group` interceptor. + When both interceptors are used, this `post_deprovision_deployment_group_with_metadata` interceptor runs after the + `post_deprovision_deployment_group` interceptor. The (possibly modified) response returned by + `post_deprovision_deployment_group` will be passed to + `post_deprovision_deployment_group_with_metadata`. + """ + return response, metadata + def pre_export_deployment_statefile( self, request: config.ExportDeploymentStatefileRequest, @@ -791,6 +1008,103 @@ def post_get_deployment_with_metadata( """ return response, metadata + def pre_get_deployment_group( + self, + request: config.GetDeploymentGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.GetDeploymentGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_deployment_group + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_get_deployment_group( + self, response: config.DeploymentGroup + ) -> config.DeploymentGroup: + """Post-rpc interceptor for get_deployment_group + + DEPRECATED. Please use the `post_get_deployment_group_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_get_deployment_group` interceptor runs + before the `post_get_deployment_group_with_metadata` interceptor. + """ + return response + + def post_get_deployment_group_with_metadata( + self, + response: config.DeploymentGroup, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.DeploymentGroup, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_deployment_group + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_get_deployment_group_with_metadata` + interceptor in new development instead of the `post_get_deployment_group` interceptor. + When both interceptors are used, this `post_get_deployment_group_with_metadata` interceptor runs after the + `post_get_deployment_group` interceptor. The (possibly modified) response returned by + `post_get_deployment_group` will be passed to + `post_get_deployment_group_with_metadata`. + """ + return response, metadata + + def pre_get_deployment_group_revision( + self, + request: config.GetDeploymentGroupRevisionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.GetDeploymentGroupRevisionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_deployment_group_revision + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_get_deployment_group_revision( + self, response: config.DeploymentGroupRevision + ) -> config.DeploymentGroupRevision: + """Post-rpc interceptor for get_deployment_group_revision + + DEPRECATED. Please use the `post_get_deployment_group_revision_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_get_deployment_group_revision` interceptor runs + before the `post_get_deployment_group_revision_with_metadata` interceptor. + """ + return response + + def post_get_deployment_group_revision_with_metadata( + self, + response: config.DeploymentGroupRevision, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.DeploymentGroupRevision, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_deployment_group_revision + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_get_deployment_group_revision_with_metadata` + interceptor in new development instead of the `post_get_deployment_group_revision` interceptor. + When both interceptors are used, this `post_get_deployment_group_revision_with_metadata` interceptor runs after the + `post_get_deployment_group_revision` interceptor. The (possibly modified) response returned by + `post_get_deployment_group_revision` will be passed to + `post_get_deployment_group_revision_with_metadata`. + """ + return response, metadata + def pre_get_preview( self, request: config.GetPreviewRequest, @@ -1109,99 +1423,201 @@ def post_import_statefile_with_metadata( """ return response, metadata - def pre_list_deployments( + def pre_list_deployment_group_revisions( self, - request: config.ListDeploymentsRequest, + request: config.ListDeploymentGroupRevisionsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[config.ListDeploymentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_deployments + ) -> Tuple[ + config.ListDeploymentGroupRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_deployment_group_revisions Override in a subclass to manipulate the request or metadata before they are sent to the Config server. """ return request, metadata - def post_list_deployments( - self, response: config.ListDeploymentsResponse - ) -> config.ListDeploymentsResponse: - """Post-rpc interceptor for list_deployments + def post_list_deployment_group_revisions( + self, response: config.ListDeploymentGroupRevisionsResponse + ) -> config.ListDeploymentGroupRevisionsResponse: + """Post-rpc interceptor for list_deployment_group_revisions - DEPRECATED. Please use the `post_list_deployments_with_metadata` + DEPRECATED. Please use the `post_list_deployment_group_revisions_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the Config server but before - it is returned to user code. This `post_list_deployments` interceptor runs - before the `post_list_deployments_with_metadata` interceptor. + it is returned to user code. This `post_list_deployment_group_revisions` interceptor runs + before the `post_list_deployment_group_revisions_with_metadata` interceptor. """ return response - def post_list_deployments_with_metadata( + def post_list_deployment_group_revisions_with_metadata( self, - response: config.ListDeploymentsResponse, + response: config.ListDeploymentGroupRevisionsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[config.ListDeploymentsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_deployments + ) -> Tuple[ + config.ListDeploymentGroupRevisionsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_deployment_group_revisions Override in a subclass to read or manipulate the response or metadata after it is returned by the Config server but before it is returned to user code. - We recommend only using this `post_list_deployments_with_metadata` - interceptor in new development instead of the `post_list_deployments` interceptor. - When both interceptors are used, this `post_list_deployments_with_metadata` interceptor runs after the - `post_list_deployments` interceptor. The (possibly modified) response returned by - `post_list_deployments` will be passed to - `post_list_deployments_with_metadata`. + We recommend only using this `post_list_deployment_group_revisions_with_metadata` + interceptor in new development instead of the `post_list_deployment_group_revisions` interceptor. + When both interceptors are used, this `post_list_deployment_group_revisions_with_metadata` interceptor runs after the + `post_list_deployment_group_revisions` interceptor. The (possibly modified) response returned by + `post_list_deployment_group_revisions` will be passed to + `post_list_deployment_group_revisions_with_metadata`. """ return response, metadata - def pre_list_previews( + def pre_list_deployment_groups( self, - request: config.ListPreviewsRequest, + request: config.ListDeploymentGroupsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[config.ListPreviewsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_previews + ) -> Tuple[ + config.ListDeploymentGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for list_deployment_groups Override in a subclass to manipulate the request or metadata before they are sent to the Config server. """ return request, metadata - def post_list_previews( - self, response: config.ListPreviewsResponse - ) -> config.ListPreviewsResponse: - """Post-rpc interceptor for list_previews + def post_list_deployment_groups( + self, response: config.ListDeploymentGroupsResponse + ) -> config.ListDeploymentGroupsResponse: + """Post-rpc interceptor for list_deployment_groups - DEPRECATED. Please use the `post_list_previews_with_metadata` + DEPRECATED. Please use the `post_list_deployment_groups_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the Config server but before - it is returned to user code. This `post_list_previews` interceptor runs - before the `post_list_previews_with_metadata` interceptor. + it is returned to user code. This `post_list_deployment_groups` interceptor runs + before the `post_list_deployment_groups_with_metadata` interceptor. """ return response - def post_list_previews_with_metadata( + def post_list_deployment_groups_with_metadata( self, - response: config.ListPreviewsResponse, + response: config.ListDeploymentGroupsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[config.ListPreviewsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_previews + ) -> Tuple[ + config.ListDeploymentGroupsResponse, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Post-rpc interceptor for list_deployment_groups Override in a subclass to read or manipulate the response or metadata after it is returned by the Config server but before it is returned to user code. - We recommend only using this `post_list_previews_with_metadata` - interceptor in new development instead of the `post_list_previews` interceptor. - When both interceptors are used, this `post_list_previews_with_metadata` interceptor runs after the - `post_list_previews` interceptor. The (possibly modified) response returned by - `post_list_previews` will be passed to - `post_list_previews_with_metadata`. + We recommend only using this `post_list_deployment_groups_with_metadata` + interceptor in new development instead of the `post_list_deployment_groups` interceptor. + When both interceptors are used, this `post_list_deployment_groups_with_metadata` interceptor runs after the + `post_list_deployment_groups` interceptor. The (possibly modified) response returned by + `post_list_deployment_groups` will be passed to + `post_list_deployment_groups_with_metadata`. """ return response, metadata - def pre_list_resource_changes( + def pre_list_deployments( + self, + request: config.ListDeploymentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ListDeploymentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_deployments + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_list_deployments( + self, response: config.ListDeploymentsResponse + ) -> config.ListDeploymentsResponse: + """Post-rpc interceptor for list_deployments + + DEPRECATED. Please use the `post_list_deployments_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_list_deployments` interceptor runs + before the `post_list_deployments_with_metadata` interceptor. + """ + return response + + def post_list_deployments_with_metadata( + self, + response: config.ListDeploymentsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ListDeploymentsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_deployments + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_list_deployments_with_metadata` + interceptor in new development instead of the `post_list_deployments` interceptor. + When both interceptors are used, this `post_list_deployments_with_metadata` interceptor runs after the + `post_list_deployments` interceptor. The (possibly modified) response returned by + `post_list_deployments` will be passed to + `post_list_deployments_with_metadata`. + """ + return response, metadata + + def pre_list_previews( + self, + request: config.ListPreviewsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ListPreviewsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_previews + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_list_previews( + self, response: config.ListPreviewsResponse + ) -> config.ListPreviewsResponse: + """Post-rpc interceptor for list_previews + + DEPRECATED. Please use the `post_list_previews_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_list_previews` interceptor runs + before the `post_list_previews_with_metadata` interceptor. + """ + return response + + def post_list_previews_with_metadata( + self, + response: config.ListPreviewsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ListPreviewsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_previews + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_list_previews_with_metadata` + interceptor in new development instead of the `post_list_previews` interceptor. + When both interceptors are used, this `post_list_previews_with_metadata` interceptor runs after the + `post_list_previews` interceptor. The (possibly modified) response returned by + `post_list_previews` will be passed to + `post_list_previews_with_metadata`. + """ + return response, metadata + + def pre_list_resource_changes( self, request: config.ListResourceChangesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], @@ -1489,6 +1905,54 @@ def post_lock_deployment_with_metadata( """ return response, metadata + def pre_provision_deployment_group( + self, + request: config.ProvisionDeploymentGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.ProvisionDeploymentGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for provision_deployment_group + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_provision_deployment_group( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for provision_deployment_group + + DEPRECATED. Please use the `post_provision_deployment_group_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_provision_deployment_group` interceptor runs + before the `post_provision_deployment_group_with_metadata` interceptor. + """ + return response + + def post_provision_deployment_group_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for provision_deployment_group + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_provision_deployment_group_with_metadata` + interceptor in new development instead of the `post_provision_deployment_group` interceptor. + When both interceptors are used, this `post_provision_deployment_group_with_metadata` interceptor runs after the + `post_provision_deployment_group` interceptor. The (possibly modified) response returned by + `post_provision_deployment_group` will be passed to + `post_provision_deployment_group_with_metadata`. + """ + return response, metadata + def pre_unlock_deployment( self, request: config.UnlockDeploymentRequest, @@ -1629,6 +2093,54 @@ def post_update_deployment_with_metadata( """ return response, metadata + def pre_update_deployment_group( + self, + request: config.UpdateDeploymentGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.UpdateDeploymentGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for update_deployment_group + + Override in a subclass to manipulate the request or metadata + before they are sent to the Config server. + """ + return request, metadata + + def post_update_deployment_group( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_deployment_group + + DEPRECATED. Please use the `post_update_deployment_group_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the Config server but before + it is returned to user code. This `post_update_deployment_group` interceptor runs + before the `post_update_deployment_group_with_metadata` interceptor. + """ + return response + + def post_update_deployment_group_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_deployment_group + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the Config server but before it is returned to user code. + + We recommend only using this `post_update_deployment_group_with_metadata` + interceptor in new development instead of the `post_update_deployment_group` interceptor. + When both interceptors are used, this `post_update_deployment_group_with_metadata` interceptor runs after the + `post_update_deployment_group` interceptor. The (possibly modified) response returned by + `post_update_deployment_group` will be passed to + `post_update_deployment_group_with_metadata`. + """ + return response, metadata + def pre_get_location( self, request: locations_pb2.GetLocationRequest, @@ -2156,9 +2668,11 @@ def __call__( ) return resp - class _CreatePreview(_BaseConfigRestTransport._BaseCreatePreview, ConfigRestStub): + class _CreateDeploymentGroup( + _BaseConfigRestTransport._BaseCreateDeploymentGroup, ConfigRestStub + ): def __hash__(self): - return hash("ConfigRestTransport.CreatePreview") + return hash("ConfigRestTransport.CreateDeploymentGroup") @staticmethod def _get_response( @@ -2185,17 +2699,18 @@ def _get_response( def __call__( self, - request: config.CreatePreviewRequest, + request: config.CreateDeploymentGroupRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: - r"""Call the create preview method over HTTP. + r"""Call the create deployment group method over HTTP. Args: - request (~.config.CreatePreviewRequest): - The request object. A request to create a preview. + request (~.config.CreateDeploymentGroupRequest): + The request object. A request to create a deployment + group retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2213,25 +2728,23 @@ def __call__( """ http_options = ( - _BaseConfigRestTransport._BaseCreatePreview._get_http_options() + _BaseConfigRestTransport._BaseCreateDeploymentGroup._get_http_options() ) - request, metadata = self._interceptor.pre_create_preview(request, metadata) - transcoded_request = ( - _BaseConfigRestTransport._BaseCreatePreview._get_transcoded_request( - http_options, request - ) + request, metadata = self._interceptor.pre_create_deployment_group( + request, metadata + ) + transcoded_request = _BaseConfigRestTransport._BaseCreateDeploymentGroup._get_transcoded_request( + http_options, request ) - body = _BaseConfigRestTransport._BaseCreatePreview._get_request_body_json( + body = _BaseConfigRestTransport._BaseCreateDeploymentGroup._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = ( - _BaseConfigRestTransport._BaseCreatePreview._get_query_params_json( - transcoded_request - ) + query_params = _BaseConfigRestTransport._BaseCreateDeploymentGroup._get_query_params_json( + transcoded_request ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -2252,17 +2765,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.CreatePreview", + f"Sending request for google.cloud.config_v1.ConfigClient.CreateDeploymentGroup", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "CreatePreview", + "rpcName": "CreateDeploymentGroup", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._CreatePreview._get_response( + response = ConfigRestTransport._CreateDeploymentGroup._get_response( self._host, metadata, query_params, @@ -2281,9 +2794,9 @@ def __call__( resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_preview(resp) + resp = self._interceptor.post_create_deployment_group(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_preview_with_metadata( + resp, _ = self._interceptor.post_create_deployment_group_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -2299,21 +2812,19 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.create_preview", + "Received response for google.cloud.config_v1.ConfigClient.create_deployment_group", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "CreatePreview", + "rpcName": "CreateDeploymentGroup", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _DeleteDeployment( - _BaseConfigRestTransport._BaseDeleteDeployment, ConfigRestStub - ): + class _CreatePreview(_BaseConfigRestTransport._BaseCreatePreview, ConfigRestStub): def __hash__(self): - return hash("ConfigRestTransport.DeleteDeployment") + return hash("ConfigRestTransport.CreatePreview") @staticmethod def _get_response( @@ -2334,22 +2845,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: config.DeleteDeploymentRequest, + request: config.CreatePreviewRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: - r"""Call the delete deployment method over HTTP. + r"""Call the create preview method over HTTP. Args: - request (~.config.DeleteDeploymentRequest): - The request object. + request (~.config.CreatePreviewRequest): + The request object. A request to create a preview. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2367,21 +2879,23 @@ def __call__( """ http_options = ( - _BaseConfigRestTransport._BaseDeleteDeployment._get_http_options() + _BaseConfigRestTransport._BaseCreatePreview._get_http_options() ) - request, metadata = self._interceptor.pre_delete_deployment( - request, metadata - ) + request, metadata = self._interceptor.pre_create_preview(request, metadata) transcoded_request = ( - _BaseConfigRestTransport._BaseDeleteDeployment._get_transcoded_request( + _BaseConfigRestTransport._BaseCreatePreview._get_transcoded_request( http_options, request ) ) + body = _BaseConfigRestTransport._BaseCreatePreview._get_request_body_json( + transcoded_request + ) + # Jsonify the query params query_params = ( - _BaseConfigRestTransport._BaseDeleteDeployment._get_query_params_json( + _BaseConfigRestTransport._BaseCreatePreview._get_query_params_json( transcoded_request ) ) @@ -2404,23 +2918,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.DeleteDeployment", + f"Sending request for google.cloud.config_v1.ConfigClient.CreatePreview", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "DeleteDeployment", + "rpcName": "CreatePreview", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._DeleteDeployment._get_response( + response = ConfigRestTransport._CreatePreview._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2432,9 +2947,9 @@ def __call__( resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_deployment(resp) + resp = self._interceptor.post_create_preview(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_deployment_with_metadata( + resp, _ = self._interceptor.post_create_preview_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -2450,19 +2965,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.delete_deployment", + "Received response for google.cloud.config_v1.ConfigClient.create_preview", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "DeleteDeployment", + "rpcName": "CreatePreview", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _DeletePreview(_BaseConfigRestTransport._BaseDeletePreview, ConfigRestStub): + class _DeleteDeployment( + _BaseConfigRestTransport._BaseDeleteDeployment, ConfigRestStub + ): def __hash__(self): - return hash("ConfigRestTransport.DeletePreview") + return hash("ConfigRestTransport.DeleteDeployment") @staticmethod def _get_response( @@ -2488,17 +3005,17 @@ def _get_response( def __call__( self, - request: config.DeletePreviewRequest, + request: config.DeleteDeploymentRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: - r"""Call the delete preview method over HTTP. + r"""Call the delete deployment method over HTTP. Args: - request (~.config.DeletePreviewRequest): - The request object. A request to delete a preview. + request (~.config.DeleteDeploymentRequest): + The request object. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2516,19 +3033,21 @@ def __call__( """ http_options = ( - _BaseConfigRestTransport._BaseDeletePreview._get_http_options() + _BaseConfigRestTransport._BaseDeleteDeployment._get_http_options() ) - request, metadata = self._interceptor.pre_delete_preview(request, metadata) + request, metadata = self._interceptor.pre_delete_deployment( + request, metadata + ) transcoded_request = ( - _BaseConfigRestTransport._BaseDeletePreview._get_transcoded_request( + _BaseConfigRestTransport._BaseDeleteDeployment._get_transcoded_request( http_options, request ) ) # Jsonify the query params query_params = ( - _BaseConfigRestTransport._BaseDeletePreview._get_query_params_json( + _BaseConfigRestTransport._BaseDeleteDeployment._get_query_params_json( transcoded_request ) ) @@ -2551,10 +3070,305 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.DeletePreview", + f"Sending request for google.cloud.config_v1.ConfigClient.DeleteDeployment", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "DeletePreview", + "rpcName": "DeleteDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._DeleteDeployment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_deployment(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_deployment_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.delete_deployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeleteDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteDeploymentGroup( + _BaseConfigRestTransport._BaseDeleteDeploymentGroup, ConfigRestStub + ): + def __hash__(self): + return hash("ConfigRestTransport.DeleteDeploymentGroup") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: config.DeleteDeploymentGroupRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete deployment group method over HTTP. + + Args: + request (~.config.DeleteDeploymentGroupRequest): + The request object. Request message for Delete + DeploymentGroup + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseConfigRestTransport._BaseDeleteDeploymentGroup._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_deployment_group( + request, metadata + ) + transcoded_request = _BaseConfigRestTransport._BaseDeleteDeploymentGroup._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseConfigRestTransport._BaseDeleteDeploymentGroup._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.DeleteDeploymentGroup", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeleteDeploymentGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._DeleteDeploymentGroup._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_deployment_group(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_deployment_group_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.delete_deployment_group", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeleteDeploymentGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeletePreview(_BaseConfigRestTransport._BaseDeletePreview, ConfigRestStub): + def __hash__(self): + return hash("ConfigRestTransport.DeletePreview") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: config.DeletePreviewRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete preview method over HTTP. + + Args: + request (~.config.DeletePreviewRequest): + The request object. A request to delete a preview. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseConfigRestTransport._BaseDeletePreview._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_preview(request, metadata) + transcoded_request = ( + _BaseConfigRestTransport._BaseDeletePreview._get_transcoded_request( + http_options, request + ) + ) + + # Jsonify the query params + query_params = ( + _BaseConfigRestTransport._BaseDeletePreview._get_query_params_json( + transcoded_request + ) + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.DeletePreview", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeletePreview", "httpRequest": http_request, "metadata": http_request["headers"], }, @@ -2576,19 +3390,753 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_preview(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_preview_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.delete_preview", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeletePreview", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteStatefile( + _BaseConfigRestTransport._BaseDeleteStatefile, ConfigRestStub + ): + def __hash__(self): + return hash("ConfigRestTransport.DeleteStatefile") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: config.DeleteStatefileRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ): + r"""Call the delete statefile method over HTTP. + + Args: + request (~.config.DeleteStatefileRequest): + The request object. A request to delete a state file + passed to a 'DeleteStatefile' call. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + + http_options = ( + _BaseConfigRestTransport._BaseDeleteStatefile._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_statefile( + request, metadata + ) + transcoded_request = ( + _BaseConfigRestTransport._BaseDeleteStatefile._get_transcoded_request( + http_options, request + ) + ) + + body = _BaseConfigRestTransport._BaseDeleteStatefile._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = ( + _BaseConfigRestTransport._BaseDeleteStatefile._get_query_params_json( + transcoded_request + ) + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.DeleteStatefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeleteStatefile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._DeleteStatefile._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeprovisionDeploymentGroup( + _BaseConfigRestTransport._BaseDeprovisionDeploymentGroup, ConfigRestStub + ): + def __hash__(self): + return hash("ConfigRestTransport.DeprovisionDeploymentGroup") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: config.DeprovisionDeploymentGroupRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the deprovision deployment + group method over HTTP. + + Args: + request (~.config.DeprovisionDeploymentGroupRequest): + The request object. The request message for the + DeprovisionDeploymentGroup method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseConfigRestTransport._BaseDeprovisionDeploymentGroup._get_http_options() + + request, metadata = self._interceptor.pre_deprovision_deployment_group( + request, metadata + ) + transcoded_request = _BaseConfigRestTransport._BaseDeprovisionDeploymentGroup._get_transcoded_request( + http_options, request + ) + + body = _BaseConfigRestTransport._BaseDeprovisionDeploymentGroup._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseConfigRestTransport._BaseDeprovisionDeploymentGroup._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.DeprovisionDeploymentGroup", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeprovisionDeploymentGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._DeprovisionDeploymentGroup._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_deprovision_deployment_group(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_deprovision_deployment_group_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.deprovision_deployment_group", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeprovisionDeploymentGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ExportDeploymentStatefile( + _BaseConfigRestTransport._BaseExportDeploymentStatefile, ConfigRestStub + ): + def __hash__(self): + return hash("ConfigRestTransport.ExportDeploymentStatefile") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: config.ExportDeploymentStatefileRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> config.Statefile: + r"""Call the export deployment + statefile method over HTTP. + + Args: + request (~.config.ExportDeploymentStatefileRequest): + The request object. A request to export a state file + passed to a 'ExportDeploymentStatefile' + call. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.config.Statefile: + Contains info about a Terraform state + file + + """ + + http_options = _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_http_options() + + request, metadata = self._interceptor.pre_export_deployment_statefile( + request, metadata + ) + transcoded_request = _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_transcoded_request( + http_options, request + ) + + body = _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.ExportDeploymentStatefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportDeploymentStatefile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._ExportDeploymentStatefile._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = config.Statefile() + pb_resp = config.Statefile.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_export_deployment_statefile(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_export_deployment_statefile_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Statefile.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.export_deployment_statefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportDeploymentStatefile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ExportLockInfo(_BaseConfigRestTransport._BaseExportLockInfo, ConfigRestStub): + def __hash__(self): + return hash("ConfigRestTransport.ExportLockInfo") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: config.ExportLockInfoRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> config.LockInfo: + r"""Call the export lock info method over HTTP. + + Args: + request (~.config.ExportLockInfoRequest): + The request object. A request to get a state file lock + info passed to a 'ExportLockInfo' call. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.config.LockInfo: + Details about the lock which locked + the deployment. + + """ + + http_options = ( + _BaseConfigRestTransport._BaseExportLockInfo._get_http_options() + ) + + request, metadata = self._interceptor.pre_export_lock_info( + request, metadata + ) + transcoded_request = ( + _BaseConfigRestTransport._BaseExportLockInfo._get_transcoded_request( + http_options, request + ) + ) + + # Jsonify the query params + query_params = ( + _BaseConfigRestTransport._BaseExportLockInfo._get_query_params_json( + transcoded_request + ) + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.ExportLockInfo", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportLockInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._ExportLockInfo._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = config.LockInfo() + pb_resp = config.LockInfo.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_export_lock_info(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_export_lock_info_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.LockInfo.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.export_lock_info", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportLockInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ExportPreviewResult( + _BaseConfigRestTransport._BaseExportPreviewResult, ConfigRestStub + ): + def __hash__(self): + return hash("ConfigRestTransport.ExportPreviewResult") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: config.ExportPreviewResultRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> config.ExportPreviewResultResponse: + r"""Call the export preview result method over HTTP. + + Args: + request (~.config.ExportPreviewResultRequest): + The request object. A request to export preview results. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.config.ExportPreviewResultResponse: + A response to ``ExportPreviewResult`` call. Contains + preview results. + + """ + + http_options = ( + _BaseConfigRestTransport._BaseExportPreviewResult._get_http_options() + ) + + request, metadata = self._interceptor.pre_export_preview_result( + request, metadata + ) + transcoded_request = _BaseConfigRestTransport._BaseExportPreviewResult._get_transcoded_request( + http_options, request + ) + + body = _BaseConfigRestTransport._BaseExportPreviewResult._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseConfigRestTransport._BaseExportPreviewResult._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.ExportPreviewResult", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportPreviewResult", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._ExportPreviewResult._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = config.ExportPreviewResultResponse() + pb_resp = config.ExportPreviewResultResponse.pb(resp) - resp = self._interceptor.post_delete_preview(resp) + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_export_preview_result(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_preview_with_metadata( + resp, _ = self._interceptor.post_export_preview_result_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = json_format.MessageToJson(resp) + response_payload = config.ExportPreviewResultResponse.to_json( + response + ) except: response_payload = None http_response = { @@ -2597,21 +4145,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.delete_preview", + "Received response for google.cloud.config_v1.ConfigClient.export_preview_result", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "DeletePreview", + "rpcName": "ExportPreviewResult", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _DeleteStatefile( - _BaseConfigRestTransport._BaseDeleteStatefile, ConfigRestStub + class _ExportRevisionStatefile( + _BaseConfigRestTransport._BaseExportRevisionStatefile, ConfigRestStub ): def __hash__(self): - return hash("ConfigRestTransport.DeleteStatefile") + return hash("ConfigRestTransport.ExportRevisionStatefile") @staticmethod def _get_response( @@ -2638,18 +4186,19 @@ def _get_response( def __call__( self, - request: config.DeleteStatefileRequest, + request: config.ExportRevisionStatefileRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ): - r"""Call the delete statefile method over HTTP. + ) -> config.Statefile: + r"""Call the export revision statefile method over HTTP. Args: - request (~.config.DeleteStatefileRequest): - The request object. A request to delete a state file - passed to a 'DeleteStatefile' call. + request (~.config.ExportRevisionStatefileRequest): + The request object. A request to export a state file + passed to a 'ExportRevisionStatefile' + call. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2657,30 +4206,30 @@ def __call__( sent along with the request as metadata. Normally, each value must be of type `str`, but for metadata keys ending with the suffix `-bin`, the corresponding values must be of type `bytes`. + + Returns: + ~.config.Statefile: + Contains info about a Terraform state + file + """ - http_options = ( - _BaseConfigRestTransport._BaseDeleteStatefile._get_http_options() - ) + http_options = _BaseConfigRestTransport._BaseExportRevisionStatefile._get_http_options() - request, metadata = self._interceptor.pre_delete_statefile( + request, metadata = self._interceptor.pre_export_revision_statefile( request, metadata ) - transcoded_request = ( - _BaseConfigRestTransport._BaseDeleteStatefile._get_transcoded_request( - http_options, request - ) + transcoded_request = _BaseConfigRestTransport._BaseExportRevisionStatefile._get_transcoded_request( + http_options, request ) - body = _BaseConfigRestTransport._BaseDeleteStatefile._get_request_body_json( + body = _BaseConfigRestTransport._BaseExportRevisionStatefile._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = ( - _BaseConfigRestTransport._BaseDeleteStatefile._get_query_params_json( - transcoded_request - ) + query_params = _BaseConfigRestTransport._BaseExportRevisionStatefile._get_query_params_json( + transcoded_request ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -2701,17 +4250,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.DeleteStatefile", + f"Sending request for google.cloud.config_v1.ConfigClient.ExportRevisionStatefile", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "DeleteStatefile", + "rpcName": "ExportRevisionStatefile", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._DeleteStatefile._get_response( + response = ConfigRestTransport._ExportRevisionStatefile._get_response( self._host, metadata, query_params, @@ -2726,11 +4275,45 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - class _ExportDeploymentStatefile( - _BaseConfigRestTransport._BaseExportDeploymentStatefile, ConfigRestStub + # Return the response + resp = config.Statefile() + pb_resp = config.Statefile.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_export_revision_statefile(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_export_revision_statefile_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Statefile.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.export_revision_statefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportRevisionStatefile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetAutoMigrationConfig( + _BaseConfigRestTransport._BaseGetAutoMigrationConfig, ConfigRestStub ): def __hash__(self): - return hash("ConfigRestTransport.ExportDeploymentStatefile") + return hash("ConfigRestTransport.GetAutoMigrationConfig") @staticmethod def _get_response( @@ -2751,56 +4334,52 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: config.ExportDeploymentStatefileRequest, + request: config.GetAutoMigrationConfigRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.Statefile: - r"""Call the export deployment - statefile method over HTTP. + ) -> config.AutoMigrationConfig: + r"""Call the get auto migration config method over HTTP. - Args: - request (~.config.ExportDeploymentStatefileRequest): - The request object. A request to export a state file - passed to a 'ExportDeploymentStatefile' - call. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. + Args: + request (~.config.GetAutoMigrationConfigRequest): + The request object. The request message for the + GetAutoMigrationConfig method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. - Returns: - ~.config.Statefile: - Contains info about a Terraform state - file + Returns: + ~.config.AutoMigrationConfig: + AutoMigrationConfig contains the + automigration configuration for a + project. """ - http_options = _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_http_options() + http_options = ( + _BaseConfigRestTransport._BaseGetAutoMigrationConfig._get_http_options() + ) - request, metadata = self._interceptor.pre_export_deployment_statefile( + request, metadata = self._interceptor.pre_get_auto_migration_config( request, metadata ) - transcoded_request = _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_transcoded_request( + transcoded_request = _BaseConfigRestTransport._BaseGetAutoMigrationConfig._get_transcoded_request( http_options, request ) - body = _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_query_params_json( + query_params = _BaseConfigRestTransport._BaseGetAutoMigrationConfig._get_query_params_json( transcoded_request ) @@ -2822,24 +4401,23 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.ExportDeploymentStatefile", + f"Sending request for google.cloud.config_v1.ConfigClient.GetAutoMigrationConfig", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ExportDeploymentStatefile", + "rpcName": "GetAutoMigrationConfig", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._ExportDeploymentStatefile._get_response( + response = ConfigRestTransport._GetAutoMigrationConfig._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2848,21 +4426,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.Statefile() - pb_resp = config.Statefile.pb(resp) + resp = config.AutoMigrationConfig() + pb_resp = config.AutoMigrationConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_export_deployment_statefile(resp) + resp = self._interceptor.post_get_auto_migration_config(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_export_deployment_statefile_with_metadata( + resp, _ = self._interceptor.post_get_auto_migration_config_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.Statefile.to_json(response) + response_payload = config.AutoMigrationConfig.to_json(response) except: response_payload = None http_response = { @@ -2871,19 +4449,19 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.export_deployment_statefile", + "Received response for google.cloud.config_v1.ConfigClient.get_auto_migration_config", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ExportDeploymentStatefile", + "rpcName": "GetAutoMigrationConfig", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _ExportLockInfo(_BaseConfigRestTransport._BaseExportLockInfo, ConfigRestStub): + class _GetDeployment(_BaseConfigRestTransport._BaseGetDeployment, ConfigRestStub): def __hash__(self): - return hash("ConfigRestTransport.ExportLockInfo") + return hash("ConfigRestTransport.GetDeployment") @staticmethod def _get_response( @@ -2909,18 +4487,17 @@ def _get_response( def __call__( self, - request: config.ExportLockInfoRequest, + request: config.GetDeploymentRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.LockInfo: - r"""Call the export lock info method over HTTP. + ) -> config.Deployment: + r"""Call the get deployment method over HTTP. Args: - request (~.config.ExportLockInfoRequest): - The request object. A request to get a state file lock - info passed to a 'ExportLockInfo' call. + request (~.config.GetDeploymentRequest): + The request object. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2930,28 +4507,27 @@ def __call__( be of type `bytes`. Returns: - ~.config.LockInfo: - Details about the lock which locked - the deployment. + ~.config.Deployment: + A Deployment is a group of resources + and configs managed and provisioned by + Infra Manager. """ http_options = ( - _BaseConfigRestTransport._BaseExportLockInfo._get_http_options() + _BaseConfigRestTransport._BaseGetDeployment._get_http_options() ) - request, metadata = self._interceptor.pre_export_lock_info( - request, metadata - ) + request, metadata = self._interceptor.pre_get_deployment(request, metadata) transcoded_request = ( - _BaseConfigRestTransport._BaseExportLockInfo._get_transcoded_request( + _BaseConfigRestTransport._BaseGetDeployment._get_transcoded_request( http_options, request ) ) # Jsonify the query params query_params = ( - _BaseConfigRestTransport._BaseExportLockInfo._get_query_params_json( + _BaseConfigRestTransport._BaseGetDeployment._get_query_params_json( transcoded_request ) ) @@ -2974,17 +4550,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.ExportLockInfo", + f"Sending request for google.cloud.config_v1.ConfigClient.GetDeployment", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ExportLockInfo", + "rpcName": "GetDeployment", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._ExportLockInfo._get_response( + response = ConfigRestTransport._GetDeployment._get_response( self._host, metadata, query_params, @@ -2999,21 +4575,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.LockInfo() - pb_resp = config.LockInfo.pb(resp) + resp = config.Deployment() + pb_resp = config.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_export_lock_info(resp) + resp = self._interceptor.post_get_deployment(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_export_lock_info_with_metadata( + resp, _ = self._interceptor.post_get_deployment_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.LockInfo.to_json(response) + response_payload = config.Deployment.to_json(response) except: response_payload = None http_response = { @@ -3022,21 +4598,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.export_lock_info", + "Received response for google.cloud.config_v1.ConfigClient.get_deployment", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ExportLockInfo", + "rpcName": "GetDeployment", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _ExportPreviewResult( - _BaseConfigRestTransport._BaseExportPreviewResult, ConfigRestStub + class _GetDeploymentGroup( + _BaseConfigRestTransport._BaseGetDeploymentGroup, ConfigRestStub ): def __hash__(self): - return hash("ConfigRestTransport.ExportPreviewResult") + return hash("ConfigRestTransport.GetDeploymentGroup") @staticmethod def _get_response( @@ -3057,23 +4633,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: config.ExportPreviewResultRequest, + request: config.GetDeploymentGroupRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.ExportPreviewResultResponse: - r"""Call the export preview result method over HTTP. + ) -> config.DeploymentGroup: + r"""Call the get deployment group method over HTTP. Args: - request (~.config.ExportPreviewResultRequest): - The request object. A request to export preview results. + request (~.config.GetDeploymentGroupRequest): + The request object. The request message for the + GetDeploymentGroup method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3083,30 +4659,29 @@ def __call__( be of type `bytes`. Returns: - ~.config.ExportPreviewResultResponse: - A response to ``ExportPreviewResult`` call. Contains - preview results. + ~.config.DeploymentGroup: + A DeploymentGroup is a collection of + DeploymentUnits that in a DAG-like + structure. """ http_options = ( - _BaseConfigRestTransport._BaseExportPreviewResult._get_http_options() + _BaseConfigRestTransport._BaseGetDeploymentGroup._get_http_options() ) - request, metadata = self._interceptor.pre_export_preview_result( + request, metadata = self._interceptor.pre_get_deployment_group( request, metadata ) - transcoded_request = _BaseConfigRestTransport._BaseExportPreviewResult._get_transcoded_request( + transcoded_request = _BaseConfigRestTransport._BaseGetDeploymentGroup._get_transcoded_request( http_options, request ) - body = _BaseConfigRestTransport._BaseExportPreviewResult._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseConfigRestTransport._BaseExportPreviewResult._get_query_params_json( - transcoded_request + query_params = ( + _BaseConfigRestTransport._BaseGetDeploymentGroup._get_query_params_json( + transcoded_request + ) ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -3127,24 +4702,23 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.ExportPreviewResult", + f"Sending request for google.cloud.config_v1.ConfigClient.GetDeploymentGroup", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ExportPreviewResult", + "rpcName": "GetDeploymentGroup", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._ExportPreviewResult._get_response( + response = ConfigRestTransport._GetDeploymentGroup._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3153,23 +4727,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.ExportPreviewResultResponse() - pb_resp = config.ExportPreviewResultResponse.pb(resp) + resp = config.DeploymentGroup() + pb_resp = config.DeploymentGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_export_preview_result(resp) + resp = self._interceptor.post_get_deployment_group(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_export_preview_result_with_metadata( + resp, _ = self._interceptor.post_get_deployment_group_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.ExportPreviewResultResponse.to_json( - response - ) + response_payload = config.DeploymentGroup.to_json(response) except: response_payload = None http_response = { @@ -3178,21 +4750,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.export_preview_result", + "Received response for google.cloud.config_v1.ConfigClient.get_deployment_group", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ExportPreviewResult", + "rpcName": "GetDeploymentGroup", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _ExportRevisionStatefile( - _BaseConfigRestTransport._BaseExportRevisionStatefile, ConfigRestStub + class _GetDeploymentGroupRevision( + _BaseConfigRestTransport._BaseGetDeploymentGroupRevision, ConfigRestStub ): def __hash__(self): - return hash("ConfigRestTransport.ExportRevisionStatefile") + return hash("ConfigRestTransport.GetDeploymentGroupRevision") @staticmethod def _get_response( @@ -3213,55 +4785,52 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: config.ExportRevisionStatefileRequest, + request: config.GetDeploymentGroupRevisionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.Statefile: - r"""Call the export revision statefile method over HTTP. + ) -> config.DeploymentGroupRevision: + r"""Call the get deployment group + revision method over HTTP. - Args: - request (~.config.ExportRevisionStatefileRequest): - The request object. A request to export a state file - passed to a 'ExportRevisionStatefile' - call. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. + Args: + request (~.config.GetDeploymentGroupRevisionRequest): + The request object. The request message for the + GetDeploymentGroupRevision method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. - Returns: - ~.config.Statefile: - Contains info about a Terraform state - file + Returns: + ~.config.DeploymentGroupRevision: + A DeploymentGroupRevision represents a snapshot of a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] + at a given point in time, created when a DeploymentGroup + is provisioned or deprovisioned. """ - http_options = _BaseConfigRestTransport._BaseExportRevisionStatefile._get_http_options() + http_options = _BaseConfigRestTransport._BaseGetDeploymentGroupRevision._get_http_options() - request, metadata = self._interceptor.pre_export_revision_statefile( + request, metadata = self._interceptor.pre_get_deployment_group_revision( request, metadata ) - transcoded_request = _BaseConfigRestTransport._BaseExportRevisionStatefile._get_transcoded_request( + transcoded_request = _BaseConfigRestTransport._BaseGetDeploymentGroupRevision._get_transcoded_request( http_options, request ) - body = _BaseConfigRestTransport._BaseExportRevisionStatefile._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseConfigRestTransport._BaseExportRevisionStatefile._get_query_params_json( + query_params = _BaseConfigRestTransport._BaseGetDeploymentGroupRevision._get_query_params_json( transcoded_request ) @@ -3283,24 +4852,23 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.ExportRevisionStatefile", + f"Sending request for google.cloud.config_v1.ConfigClient.GetDeploymentGroupRevision", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ExportRevisionStatefile", + "rpcName": "GetDeploymentGroupRevision", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._ExportRevisionStatefile._get_response( + response = ConfigRestTransport._GetDeploymentGroupRevision._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3309,21 +4877,23 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.Statefile() - pb_resp = config.Statefile.pb(resp) + resp = config.DeploymentGroupRevision() + pb_resp = config.DeploymentGroupRevision.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_export_revision_statefile(resp) + resp = self._interceptor.post_get_deployment_group_revision(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_export_revision_statefile_with_metadata( - resp, response_metadata + resp, _ = ( + self._interceptor.post_get_deployment_group_revision_with_metadata( + resp, response_metadata + ) ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.Statefile.to_json(response) + response_payload = config.DeploymentGroupRevision.to_json(response) except: response_payload = None http_response = { @@ -3332,21 +4902,19 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.export_revision_statefile", + "Received response for google.cloud.config_v1.ConfigClient.get_deployment_group_revision", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ExportRevisionStatefile", + "rpcName": "GetDeploymentGroupRevision", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetAutoMigrationConfig( - _BaseConfigRestTransport._BaseGetAutoMigrationConfig, ConfigRestStub - ): + class _GetPreview(_BaseConfigRestTransport._BaseGetPreview, ConfigRestStub): def __hash__(self): - return hash("ConfigRestTransport.GetAutoMigrationConfig") + return hash("ConfigRestTransport.GetPreview") @staticmethod def _get_response( @@ -3372,18 +4940,18 @@ def _get_response( def __call__( self, - request: config.GetAutoMigrationConfigRequest, + request: config.GetPreviewRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.AutoMigrationConfig: - r"""Call the get auto migration config method over HTTP. + ) -> config.Preview: + r"""Call the get preview method over HTTP. Args: - request (~.config.GetAutoMigrationConfigRequest): - The request object. The request message for the - GetAutoMigrationConfig method. + request (~.config.GetPreviewRequest): + The request object. A request to get details about a + preview. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3393,27 +4961,28 @@ def __call__( be of type `bytes`. Returns: - ~.config.AutoMigrationConfig: - AutoMigrationConfig contains the - automigration configuration for a - project. + ~.config.Preview: + A preview represents a set of actions + Infra Manager would perform to move the + resources towards the desired state as + specified in the configuration. """ - http_options = ( - _BaseConfigRestTransport._BaseGetAutoMigrationConfig._get_http_options() - ) + http_options = _BaseConfigRestTransport._BaseGetPreview._get_http_options() - request, metadata = self._interceptor.pre_get_auto_migration_config( - request, metadata - ) - transcoded_request = _BaseConfigRestTransport._BaseGetAutoMigrationConfig._get_transcoded_request( - http_options, request + request, metadata = self._interceptor.pre_get_preview(request, metadata) + transcoded_request = ( + _BaseConfigRestTransport._BaseGetPreview._get_transcoded_request( + http_options, request + ) ) # Jsonify the query params - query_params = _BaseConfigRestTransport._BaseGetAutoMigrationConfig._get_query_params_json( - transcoded_request + query_params = ( + _BaseConfigRestTransport._BaseGetPreview._get_query_params_json( + transcoded_request + ) ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -3434,17 +5003,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.GetAutoMigrationConfig", + f"Sending request for google.cloud.config_v1.ConfigClient.GetPreview", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetAutoMigrationConfig", + "rpcName": "GetPreview", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._GetAutoMigrationConfig._get_response( + response = ConfigRestTransport._GetPreview._get_response( self._host, metadata, query_params, @@ -3459,21 +5028,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.AutoMigrationConfig() - pb_resp = config.AutoMigrationConfig.pb(resp) + resp = config.Preview() + pb_resp = config.Preview.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_auto_migration_config(resp) + resp = self._interceptor.post_get_preview(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_auto_migration_config_with_metadata( + resp, _ = self._interceptor.post_get_preview_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.AutoMigrationConfig.to_json(response) + response_payload = config.Preview.to_json(response) except: response_payload = None http_response = { @@ -3482,19 +5051,19 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.get_auto_migration_config", + "Received response for google.cloud.config_v1.ConfigClient.get_preview", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetAutoMigrationConfig", + "rpcName": "GetPreview", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetDeployment(_BaseConfigRestTransport._BaseGetDeployment, ConfigRestStub): + class _GetResource(_BaseConfigRestTransport._BaseGetResource, ConfigRestStub): def __hash__(self): - return hash("ConfigRestTransport.GetDeployment") + return hash("ConfigRestTransport.GetResource") @staticmethod def _get_response( @@ -3520,17 +5089,18 @@ def _get_response( def __call__( self, - request: config.GetDeploymentRequest, + request: config.GetResourceRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.Deployment: - r"""Call the get deployment method over HTTP. + ) -> config.Resource: + r"""Call the get resource method over HTTP. Args: - request (~.config.GetDeploymentRequest): - The request object. + request (~.config.GetResourceRequest): + The request object. A request to get a Resource from a + 'GetResource' call. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3540,27 +5110,26 @@ def __call__( be of type `bytes`. Returns: - ~.config.Deployment: - A Deployment is a group of resources - and configs managed and provisioned by - Infra Manager. + ~.config.Resource: + Resource represents a Google Cloud + Platform resource actuated by IM. + Resources are child resources of + Revisions. """ - http_options = ( - _BaseConfigRestTransport._BaseGetDeployment._get_http_options() - ) + http_options = _BaseConfigRestTransport._BaseGetResource._get_http_options() - request, metadata = self._interceptor.pre_get_deployment(request, metadata) + request, metadata = self._interceptor.pre_get_resource(request, metadata) transcoded_request = ( - _BaseConfigRestTransport._BaseGetDeployment._get_transcoded_request( + _BaseConfigRestTransport._BaseGetResource._get_transcoded_request( http_options, request ) ) # Jsonify the query params query_params = ( - _BaseConfigRestTransport._BaseGetDeployment._get_query_params_json( + _BaseConfigRestTransport._BaseGetResource._get_query_params_json( transcoded_request ) ) @@ -3583,17 +5152,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.GetDeployment", + f"Sending request for google.cloud.config_v1.ConfigClient.GetResource", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetDeployment", + "rpcName": "GetResource", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._GetDeployment._get_response( + response = ConfigRestTransport._GetResource._get_response( self._host, metadata, query_params, @@ -3608,21 +5177,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.Deployment() - pb_resp = config.Deployment.pb(resp) + resp = config.Resource() + pb_resp = config.Resource.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_deployment(resp) + resp = self._interceptor.post_get_resource(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_deployment_with_metadata( + resp, _ = self._interceptor.post_get_resource_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.Deployment.to_json(response) + response_payload = config.Resource.to_json(response) except: response_payload = None http_response = { @@ -3631,19 +5200,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.get_deployment", + "Received response for google.cloud.config_v1.ConfigClient.get_resource", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetDeployment", + "rpcName": "GetResource", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetPreview(_BaseConfigRestTransport._BaseGetPreview, ConfigRestStub): + class _GetResourceChange( + _BaseConfigRestTransport._BaseGetResourceChange, ConfigRestStub + ): def __hash__(self): - return hash("ConfigRestTransport.GetPreview") + return hash("ConfigRestTransport.GetResourceChange") @staticmethod def _get_response( @@ -3669,18 +5240,18 @@ def _get_response( def __call__( self, - request: config.GetPreviewRequest, + request: config.GetResourceChangeRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.Preview: - r"""Call the get preview method over HTTP. + ) -> config.ResourceChange: + r"""Call the get resource change method over HTTP. Args: - request (~.config.GetPreviewRequest): - The request object. A request to get details about a - preview. + request (~.config.GetResourceChangeRequest): + The request object. The request message for the + GetResourceChange method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3690,26 +5261,28 @@ def __call__( be of type `bytes`. Returns: - ~.config.Preview: - A preview represents a set of actions - Infra Manager would perform to move the - resources towards the desired state as - specified in the configuration. + ~.config.ResourceChange: + A resource change represents a change + to a resource in the state file. """ - http_options = _BaseConfigRestTransport._BaseGetPreview._get_http_options() + http_options = ( + _BaseConfigRestTransport._BaseGetResourceChange._get_http_options() + ) - request, metadata = self._interceptor.pre_get_preview(request, metadata) + request, metadata = self._interceptor.pre_get_resource_change( + request, metadata + ) transcoded_request = ( - _BaseConfigRestTransport._BaseGetPreview._get_transcoded_request( + _BaseConfigRestTransport._BaseGetResourceChange._get_transcoded_request( http_options, request ) ) # Jsonify the query params query_params = ( - _BaseConfigRestTransport._BaseGetPreview._get_query_params_json( + _BaseConfigRestTransport._BaseGetResourceChange._get_query_params_json( transcoded_request ) ) @@ -3732,17 +5305,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.GetPreview", + f"Sending request for google.cloud.config_v1.ConfigClient.GetResourceChange", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetPreview", + "rpcName": "GetResourceChange", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._GetPreview._get_response( + response = ConfigRestTransport._GetResourceChange._get_response( self._host, metadata, query_params, @@ -3757,21 +5330,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.Preview() - pb_resp = config.Preview.pb(resp) + resp = config.ResourceChange() + pb_resp = config.ResourceChange.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_preview(resp) + resp = self._interceptor.post_get_resource_change(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_preview_with_metadata( + resp, _ = self._interceptor.post_get_resource_change_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.Preview.to_json(response) + response_payload = config.ResourceChange.to_json(response) except: response_payload = None http_response = { @@ -3780,19 +5353,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.get_preview", + "Received response for google.cloud.config_v1.ConfigClient.get_resource_change", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetPreview", + "rpcName": "GetResourceChange", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetResource(_BaseConfigRestTransport._BaseGetResource, ConfigRestStub): + class _GetResourceDrift( + _BaseConfigRestTransport._BaseGetResourceDrift, ConfigRestStub + ): def __hash__(self): - return hash("ConfigRestTransport.GetResource") + return hash("ConfigRestTransport.GetResourceDrift") @staticmethod def _get_response( @@ -3818,18 +5393,18 @@ def _get_response( def __call__( self, - request: config.GetResourceRequest, + request: config.GetResourceDriftRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.Resource: - r"""Call the get resource method over HTTP. + ) -> config.ResourceDrift: + r"""Call the get resource drift method over HTTP. Args: - request (~.config.GetResourceRequest): - The request object. A request to get a Resource from a - 'GetResource' call. + request (~.config.GetResourceDriftRequest): + The request object. The request message for the + GetResourceDrift method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3839,26 +5414,28 @@ def __call__( be of type `bytes`. Returns: - ~.config.Resource: - Resource represents a Google Cloud - Platform resource actuated by IM. - Resources are child resources of - Revisions. + ~.config.ResourceDrift: + A resource drift represents a drift + to a resource in the state file. """ - http_options = _BaseConfigRestTransport._BaseGetResource._get_http_options() + http_options = ( + _BaseConfigRestTransport._BaseGetResourceDrift._get_http_options() + ) - request, metadata = self._interceptor.pre_get_resource(request, metadata) + request, metadata = self._interceptor.pre_get_resource_drift( + request, metadata + ) transcoded_request = ( - _BaseConfigRestTransport._BaseGetResource._get_transcoded_request( + _BaseConfigRestTransport._BaseGetResourceDrift._get_transcoded_request( http_options, request ) ) # Jsonify the query params query_params = ( - _BaseConfigRestTransport._BaseGetResource._get_query_params_json( + _BaseConfigRestTransport._BaseGetResourceDrift._get_query_params_json( transcoded_request ) ) @@ -3881,17 +5458,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.GetResource", + f"Sending request for google.cloud.config_v1.ConfigClient.GetResourceDrift", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetResource", + "rpcName": "GetResourceDrift", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._GetResource._get_response( + response = ConfigRestTransport._GetResourceDrift._get_response( self._host, metadata, query_params, @@ -3906,21 +5483,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.Resource() - pb_resp = config.Resource.pb(resp) + resp = config.ResourceDrift() + pb_resp = config.ResourceDrift.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_resource(resp) + resp = self._interceptor.post_get_resource_drift(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_resource_with_metadata( + resp, _ = self._interceptor.post_get_resource_drift_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.Resource.to_json(response) + response_payload = config.ResourceDrift.to_json(response) except: response_payload = None http_response = { @@ -3929,21 +5506,19 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.get_resource", + "Received response for google.cloud.config_v1.ConfigClient.get_resource_drift", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetResource", + "rpcName": "GetResourceDrift", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetResourceChange( - _BaseConfigRestTransport._BaseGetResourceChange, ConfigRestStub - ): + class _GetRevision(_BaseConfigRestTransport._BaseGetRevision, ConfigRestStub): def __hash__(self): - return hash("ConfigRestTransport.GetResourceChange") + return hash("ConfigRestTransport.GetRevision") @staticmethod def _get_response( @@ -3969,18 +5544,18 @@ def _get_response( def __call__( self, - request: config.GetResourceChangeRequest, + request: config.GetRevisionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.ResourceChange: - r"""Call the get resource change method over HTTP. + ) -> config.Revision: + r"""Call the get revision method over HTTP. Args: - request (~.config.GetResourceChangeRequest): - The request object. The request message for the - GetResourceChange method. + request (~.config.GetRevisionRequest): + The request object. A request to get a Revision from a + 'GetRevision' call. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3990,28 +5565,27 @@ def __call__( be of type `bytes`. Returns: - ~.config.ResourceChange: - A resource change represents a change - to a resource in the state file. + ~.config.Revision: + A child resource of a Deployment + generated by a 'CreateDeployment' or + 'UpdateDeployment' call. Each Revision + contains metadata pertaining to a + snapshot of a particular Deployment. """ - http_options = ( - _BaseConfigRestTransport._BaseGetResourceChange._get_http_options() - ) + http_options = _BaseConfigRestTransport._BaseGetRevision._get_http_options() - request, metadata = self._interceptor.pre_get_resource_change( - request, metadata - ) + request, metadata = self._interceptor.pre_get_revision(request, metadata) transcoded_request = ( - _BaseConfigRestTransport._BaseGetResourceChange._get_transcoded_request( + _BaseConfigRestTransport._BaseGetRevision._get_transcoded_request( http_options, request ) ) # Jsonify the query params query_params = ( - _BaseConfigRestTransport._BaseGetResourceChange._get_query_params_json( + _BaseConfigRestTransport._BaseGetRevision._get_query_params_json( transcoded_request ) ) @@ -4034,17 +5608,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.GetResourceChange", + f"Sending request for google.cloud.config_v1.ConfigClient.GetRevision", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetResourceChange", + "rpcName": "GetRevision", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._GetResourceChange._get_response( + response = ConfigRestTransport._GetRevision._get_response( self._host, metadata, query_params, @@ -4059,21 +5633,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.ResourceChange() - pb_resp = config.ResourceChange.pb(resp) + resp = config.Revision() + pb_resp = config.Revision.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_resource_change(resp) + resp = self._interceptor.post_get_revision(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_resource_change_with_metadata( + resp, _ = self._interceptor.post_get_revision_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.ResourceChange.to_json(response) + response_payload = config.Revision.to_json(response) except: response_payload = None http_response = { @@ -4082,21 +5656,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.get_resource_change", + "Received response for google.cloud.config_v1.ConfigClient.get_revision", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetResourceChange", + "rpcName": "GetRevision", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetResourceDrift( - _BaseConfigRestTransport._BaseGetResourceDrift, ConfigRestStub + class _GetTerraformVersion( + _BaseConfigRestTransport._BaseGetTerraformVersion, ConfigRestStub ): def __hash__(self): - return hash("ConfigRestTransport.GetResourceDrift") + return hash("ConfigRestTransport.GetTerraformVersion") @staticmethod def _get_response( @@ -4122,18 +5696,18 @@ def _get_response( def __call__( self, - request: config.GetResourceDriftRequest, + request: config.GetTerraformVersionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.ResourceDrift: - r"""Call the get resource drift method over HTTP. + ) -> config.TerraformVersion: + r"""Call the get terraform version method over HTTP. Args: - request (~.config.GetResourceDriftRequest): + request (~.config.GetTerraformVersionRequest): The request object. The request message for the - GetResourceDrift method. + GetTerraformVersion method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4143,30 +5717,27 @@ def __call__( be of type `bytes`. Returns: - ~.config.ResourceDrift: - A resource drift represents a drift - to a resource in the state file. + ~.config.TerraformVersion: + A TerraformVersion represents the + support state the corresponding + Terraform version. """ http_options = ( - _BaseConfigRestTransport._BaseGetResourceDrift._get_http_options() + _BaseConfigRestTransport._BaseGetTerraformVersion._get_http_options() ) - request, metadata = self._interceptor.pre_get_resource_drift( + request, metadata = self._interceptor.pre_get_terraform_version( request, metadata ) - transcoded_request = ( - _BaseConfigRestTransport._BaseGetResourceDrift._get_transcoded_request( - http_options, request - ) + transcoded_request = _BaseConfigRestTransport._BaseGetTerraformVersion._get_transcoded_request( + http_options, request ) # Jsonify the query params - query_params = ( - _BaseConfigRestTransport._BaseGetResourceDrift._get_query_params_json( - transcoded_request - ) + query_params = _BaseConfigRestTransport._BaseGetTerraformVersion._get_query_params_json( + transcoded_request ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -4187,17 +5758,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.GetResourceDrift", + f"Sending request for google.cloud.config_v1.ConfigClient.GetTerraformVersion", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetResourceDrift", + "rpcName": "GetTerraformVersion", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._GetResourceDrift._get_response( + response = ConfigRestTransport._GetTerraformVersion._get_response( self._host, metadata, query_params, @@ -4212,21 +5783,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.ResourceDrift() - pb_resp = config.ResourceDrift.pb(resp) + resp = config.TerraformVersion() + pb_resp = config.TerraformVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_resource_drift(resp) + resp = self._interceptor.post_get_terraform_version(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_resource_drift_with_metadata( + resp, _ = self._interceptor.post_get_terraform_version_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.ResourceDrift.to_json(response) + response_payload = config.TerraformVersion.to_json(response) except: response_payload = None http_response = { @@ -4235,19 +5806,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.get_resource_drift", + "Received response for google.cloud.config_v1.ConfigClient.get_terraform_version", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetResourceDrift", + "rpcName": "GetTerraformVersion", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetRevision(_BaseConfigRestTransport._BaseGetRevision, ConfigRestStub): + class _ImportStatefile( + _BaseConfigRestTransport._BaseImportStatefile, ConfigRestStub + ): def __hash__(self): - return hash("ConfigRestTransport.GetRevision") + return hash("ConfigRestTransport.ImportStatefile") @staticmethod def _get_response( @@ -4268,23 +5841,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: config.GetRevisionRequest, + request: config.ImportStatefileRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.Revision: - r"""Call the get revision method over HTTP. + ) -> config.Statefile: + r"""Call the import statefile method over HTTP. Args: - request (~.config.GetRevisionRequest): - The request object. A request to get a Revision from a - 'GetRevision' call. + request (~.config.ImportStatefileRequest): + The request object. A request to import a state file + passed to a 'ImportStatefile' call. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4294,27 +5868,32 @@ def __call__( be of type `bytes`. Returns: - ~.config.Revision: - A child resource of a Deployment - generated by a 'CreateDeployment' or - 'UpdateDeployment' call. Each Revision - contains metadata pertaining to a - snapshot of a particular Deployment. + ~.config.Statefile: + Contains info about a Terraform state + file """ - http_options = _BaseConfigRestTransport._BaseGetRevision._get_http_options() + http_options = ( + _BaseConfigRestTransport._BaseImportStatefile._get_http_options() + ) - request, metadata = self._interceptor.pre_get_revision(request, metadata) + request, metadata = self._interceptor.pre_import_statefile( + request, metadata + ) transcoded_request = ( - _BaseConfigRestTransport._BaseGetRevision._get_transcoded_request( + _BaseConfigRestTransport._BaseImportStatefile._get_transcoded_request( http_options, request ) ) + body = _BaseConfigRestTransport._BaseImportStatefile._get_request_body_json( + transcoded_request + ) + # Jsonify the query params query_params = ( - _BaseConfigRestTransport._BaseGetRevision._get_query_params_json( + _BaseConfigRestTransport._BaseImportStatefile._get_query_params_json( transcoded_request ) ) @@ -4337,23 +5916,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.GetRevision", + f"Sending request for google.cloud.config_v1.ConfigClient.ImportStatefile", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetRevision", + "rpcName": "ImportStatefile", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._GetRevision._get_response( + response = ConfigRestTransport._ImportStatefile._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -4362,21 +5942,21 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.Revision() - pb_resp = config.Revision.pb(resp) + resp = config.Statefile() + pb_resp = config.Statefile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_revision(resp) + resp = self._interceptor.post_import_statefile(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_revision_with_metadata( + resp, _ = self._interceptor.post_import_statefile_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.Revision.to_json(response) + response_payload = config.Statefile.to_json(response) except: response_payload = None http_response = { @@ -4385,21 +5965,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.get_revision", + "Received response for google.cloud.config_v1.ConfigClient.import_statefile", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetRevision", + "rpcName": "ImportStatefile", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetTerraformVersion( - _BaseConfigRestTransport._BaseGetTerraformVersion, ConfigRestStub + class _ListDeploymentGroupRevisions( + _BaseConfigRestTransport._BaseListDeploymentGroupRevisions, ConfigRestStub ): def __hash__(self): - return hash("ConfigRestTransport.GetTerraformVersion") + return hash("ConfigRestTransport.ListDeploymentGroupRevisions") @staticmethod def _get_response( @@ -4425,47 +6005,45 @@ def _get_response( def __call__( self, - request: config.GetTerraformVersionRequest, + request: config.ListDeploymentGroupRevisionsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.TerraformVersion: - r"""Call the get terraform version method over HTTP. + ) -> config.ListDeploymentGroupRevisionsResponse: + r"""Call the list deployment group + revisions method over HTTP. - Args: - request (~.config.GetTerraformVersionRequest): - The request object. The request message for the - GetTerraformVersion method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. + Args: + request (~.config.ListDeploymentGroupRevisionsRequest): + The request object. The request message for the + ListDeploymentGroupRevisions method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. - Returns: - ~.config.TerraformVersion: - A TerraformVersion represents the - support state the corresponding - Terraform version. + Returns: + ~.config.ListDeploymentGroupRevisionsResponse: + The response message for the + ListDeploymentGroupRevisions method. """ - http_options = ( - _BaseConfigRestTransport._BaseGetTerraformVersion._get_http_options() - ) + http_options = _BaseConfigRestTransport._BaseListDeploymentGroupRevisions._get_http_options() - request, metadata = self._interceptor.pre_get_terraform_version( + request, metadata = self._interceptor.pre_list_deployment_group_revisions( request, metadata ) - transcoded_request = _BaseConfigRestTransport._BaseGetTerraformVersion._get_transcoded_request( + transcoded_request = _BaseConfigRestTransport._BaseListDeploymentGroupRevisions._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseConfigRestTransport._BaseGetTerraformVersion._get_query_params_json( + query_params = _BaseConfigRestTransport._BaseListDeploymentGroupRevisions._get_query_params_json( transcoded_request ) @@ -4487,17 +6065,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.GetTerraformVersion", + f"Sending request for google.cloud.config_v1.ConfigClient.ListDeploymentGroupRevisions", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetTerraformVersion", + "rpcName": "ListDeploymentGroupRevisions", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._GetTerraformVersion._get_response( + response = ConfigRestTransport._ListDeploymentGroupRevisions._get_response( self._host, metadata, query_params, @@ -4512,21 +6090,25 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.TerraformVersion() - pb_resp = config.TerraformVersion.pb(resp) + resp = config.ListDeploymentGroupRevisionsResponse() + pb_resp = config.ListDeploymentGroupRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_terraform_version(resp) + resp = self._interceptor.post_list_deployment_group_revisions(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_terraform_version_with_metadata( - resp, response_metadata + resp, _ = ( + self._interceptor.post_list_deployment_group_revisions_with_metadata( + resp, response_metadata + ) ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.TerraformVersion.to_json(response) + response_payload = ( + config.ListDeploymentGroupRevisionsResponse.to_json(response) + ) except: response_payload = None http_response = { @@ -4535,21 +6117,21 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.get_terraform_version", + "Received response for google.cloud.config_v1.ConfigClient.list_deployment_group_revisions", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "GetTerraformVersion", + "rpcName": "ListDeploymentGroupRevisions", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _ImportStatefile( - _BaseConfigRestTransport._BaseImportStatefile, ConfigRestStub + class _ListDeploymentGroups( + _BaseConfigRestTransport._BaseListDeploymentGroups, ConfigRestStub ): def __hash__(self): - return hash("ConfigRestTransport.ImportStatefile") + return hash("ConfigRestTransport.ListDeploymentGroups") @staticmethod def _get_response( @@ -4570,24 +6152,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: config.ImportStatefileRequest, + request: config.ListDeploymentGroupsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> config.Statefile: - r"""Call the import statefile method over HTTP. + ) -> config.ListDeploymentGroupsResponse: + r"""Call the list deployment groups method over HTTP. Args: - request (~.config.ImportStatefileRequest): - The request object. A request to import a state file - passed to a 'ImportStatefile' call. + request (~.config.ListDeploymentGroupsRequest): + The request object. The request message for the + ListDeploymentGroups method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4597,34 +6178,26 @@ def __call__( be of type `bytes`. Returns: - ~.config.Statefile: - Contains info about a Terraform state - file + ~.config.ListDeploymentGroupsResponse: + The response message for the + ListDeploymentGroups method. """ http_options = ( - _BaseConfigRestTransport._BaseImportStatefile._get_http_options() + _BaseConfigRestTransport._BaseListDeploymentGroups._get_http_options() ) - request, metadata = self._interceptor.pre_import_statefile( + request, metadata = self._interceptor.pre_list_deployment_groups( request, metadata ) - transcoded_request = ( - _BaseConfigRestTransport._BaseImportStatefile._get_transcoded_request( - http_options, request - ) - ) - - body = _BaseConfigRestTransport._BaseImportStatefile._get_request_body_json( - transcoded_request + transcoded_request = _BaseConfigRestTransport._BaseListDeploymentGroups._get_transcoded_request( + http_options, request ) # Jsonify the query params - query_params = ( - _BaseConfigRestTransport._BaseImportStatefile._get_query_params_json( - transcoded_request - ) + query_params = _BaseConfigRestTransport._BaseListDeploymentGroups._get_query_params_json( + transcoded_request ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -4645,24 +6218,23 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.ImportStatefile", + f"Sending request for google.cloud.config_v1.ConfigClient.ListDeploymentGroups", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ImportStatefile", + "rpcName": "ListDeploymentGroups", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._ImportStatefile._get_response( + response = ConfigRestTransport._ListDeploymentGroups._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -4671,21 +6243,23 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = config.Statefile() - pb_resp = config.Statefile.pb(resp) + resp = config.ListDeploymentGroupsResponse() + pb_resp = config.ListDeploymentGroupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_import_statefile(resp) + resp = self._interceptor.post_list_deployment_groups(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_import_statefile_with_metadata( + resp, _ = self._interceptor.post_list_deployment_groups_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = config.Statefile.to_json(response) + response_payload = config.ListDeploymentGroupsResponse.to_json( + response + ) except: response_payload = None http_response = { @@ -4694,10 +6268,10 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.import_statefile", + "Received response for google.cloud.config_v1.ConfigClient.list_deployment_groups", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ImportStatefile", + "rpcName": "ListDeploymentGroups", "metadata": http_response["headers"], "httpResponse": http_response, }, @@ -5747,19 +7321,175 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.list_terraform_versions", + "Received response for google.cloud.config_v1.ConfigClient.list_terraform_versions", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListTerraformVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _LockDeployment(_BaseConfigRestTransport._BaseLockDeployment, ConfigRestStub): + def __hash__(self): + return hash("ConfigRestTransport.LockDeployment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: config.LockDeploymentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the lock deployment method over HTTP. + + Args: + request (~.config.LockDeploymentRequest): + The request object. A request to lock a deployment passed + to a 'LockDeployment' call. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseConfigRestTransport._BaseLockDeployment._get_http_options() + ) + + request, metadata = self._interceptor.pre_lock_deployment(request, metadata) + transcoded_request = ( + _BaseConfigRestTransport._BaseLockDeployment._get_transcoded_request( + http_options, request + ) + ) + + body = _BaseConfigRestTransport._BaseLockDeployment._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = ( + _BaseConfigRestTransport._BaseLockDeployment._get_query_params_json( + transcoded_request + ) + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.LockDeployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "LockDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._LockDeployment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_lock_deployment(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_lock_deployment_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.lock_deployment", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "ListTerraformVersions", + "rpcName": "LockDeployment", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _LockDeployment(_BaseConfigRestTransport._BaseLockDeployment, ConfigRestStub): + class _ProvisionDeploymentGroup( + _BaseConfigRestTransport._BaseProvisionDeploymentGroup, ConfigRestStub + ): def __hash__(self): - return hash("ConfigRestTransport.LockDeployment") + return hash("ConfigRestTransport.ProvisionDeploymentGroup") @staticmethod def _get_response( @@ -5786,54 +7516,51 @@ def _get_response( def __call__( self, - request: config.LockDeploymentRequest, + request: config.ProvisionDeploymentGroupRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: - r"""Call the lock deployment method over HTTP. + r"""Call the provision deployment + group method over HTTP. - Args: - request (~.config.LockDeploymentRequest): - The request object. A request to lock a deployment passed - to a 'LockDeployment' call. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. + Args: + request (~.config.ProvisionDeploymentGroupRequest): + The request object. The request message for the + ProvisionDeploymentGroup method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ - http_options = ( - _BaseConfigRestTransport._BaseLockDeployment._get_http_options() - ) + http_options = _BaseConfigRestTransport._BaseProvisionDeploymentGroup._get_http_options() - request, metadata = self._interceptor.pre_lock_deployment(request, metadata) - transcoded_request = ( - _BaseConfigRestTransport._BaseLockDeployment._get_transcoded_request( - http_options, request - ) + request, metadata = self._interceptor.pre_provision_deployment_group( + request, metadata + ) + transcoded_request = _BaseConfigRestTransport._BaseProvisionDeploymentGroup._get_transcoded_request( + http_options, request ) - body = _BaseConfigRestTransport._BaseLockDeployment._get_request_body_json( + body = _BaseConfigRestTransport._BaseProvisionDeploymentGroup._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = ( - _BaseConfigRestTransport._BaseLockDeployment._get_query_params_json( - transcoded_request - ) + query_params = _BaseConfigRestTransport._BaseProvisionDeploymentGroup._get_query_params_json( + transcoded_request ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -5854,17 +7581,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.config_v1.ConfigClient.LockDeployment", + f"Sending request for google.cloud.config_v1.ConfigClient.ProvisionDeploymentGroup", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "LockDeployment", + "rpcName": "ProvisionDeploymentGroup", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ConfigRestTransport._LockDeployment._get_response( + response = ConfigRestTransport._ProvisionDeploymentGroup._get_response( self._host, metadata, query_params, @@ -5883,9 +7610,9 @@ def __call__( resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_lock_deployment(resp) + resp = self._interceptor.post_provision_deployment_group(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_lock_deployment_with_metadata( + resp, _ = self._interceptor.post_provision_deployment_group_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -5901,10 +7628,10 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.config_v1.ConfigClient.lock_deployment", + "Received response for google.cloud.config_v1.ConfigClient.provision_deployment_group", extra={ "serviceName": "google.cloud.config.v1.Config", - "rpcName": "LockDeployment", + "rpcName": "ProvisionDeploymentGroup", "metadata": http_response["headers"], "httpResponse": http_response, }, @@ -6383,6 +8110,160 @@ def __call__( ) return resp + class _UpdateDeploymentGroup( + _BaseConfigRestTransport._BaseUpdateDeploymentGroup, ConfigRestStub + ): + def __hash__(self): + return hash("ConfigRestTransport.UpdateDeploymentGroup") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: config.UpdateDeploymentGroupRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the update deployment group method over HTTP. + + Args: + request (~.config.UpdateDeploymentGroupRequest): + The request object. A request message for updating a + deployment group + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseConfigRestTransport._BaseUpdateDeploymentGroup._get_http_options() + ) + + request, metadata = self._interceptor.pre_update_deployment_group( + request, metadata + ) + transcoded_request = _BaseConfigRestTransport._BaseUpdateDeploymentGroup._get_transcoded_request( + http_options, request + ) + + body = _BaseConfigRestTransport._BaseUpdateDeploymentGroup._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseConfigRestTransport._BaseUpdateDeploymentGroup._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.config_v1.ConfigClient.UpdateDeploymentGroup", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "UpdateDeploymentGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ConfigRestTransport._UpdateDeploymentGroup._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_update_deployment_group(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_deployment_group_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.config_v1.ConfigClient.update_deployment_group", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "UpdateDeploymentGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + @property def create_deployment( self, @@ -6391,6 +8272,14 @@ def create_deployment( # In C++ this would require a dynamic_cast return self._CreateDeployment(self._session, self._host, self._interceptor) # type: ignore + @property + def create_deployment_group( + self, + ) -> Callable[[config.CreateDeploymentGroupRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateDeploymentGroup(self._session, self._host, self._interceptor) # type: ignore + @property def create_preview( self, @@ -6407,6 +8296,14 @@ def delete_deployment( # In C++ this would require a dynamic_cast return self._DeleteDeployment(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_deployment_group( + self, + ) -> Callable[[config.DeleteDeploymentGroupRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteDeploymentGroup(self._session, self._host, self._interceptor) # type: ignore + @property def delete_preview( self, @@ -6423,6 +8320,16 @@ def delete_statefile( # In C++ this would require a dynamic_cast return self._DeleteStatefile(self._session, self._host, self._interceptor) # type: ignore + @property + def deprovision_deployment_group( + self, + ) -> Callable[[config.DeprovisionDeploymentGroupRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeprovisionDeploymentGroup( + self._session, self._host, self._interceptor + ) # type: ignore + @property def export_deployment_statefile( self, @@ -6479,6 +8386,26 @@ def get_deployment( # In C++ this would require a dynamic_cast return self._GetDeployment(self._session, self._host, self._interceptor) # type: ignore + @property + def get_deployment_group( + self, + ) -> Callable[[config.GetDeploymentGroupRequest], config.DeploymentGroup]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetDeploymentGroup(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_deployment_group_revision( + self, + ) -> Callable[ + [config.GetDeploymentGroupRevisionRequest], config.DeploymentGroupRevision + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetDeploymentGroupRevision( + self._session, self._host, self._interceptor + ) # type: ignore + @property def get_preview(self) -> Callable[[config.GetPreviewRequest], config.Preview]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. @@ -6529,6 +8456,29 @@ def import_statefile( # In C++ this would require a dynamic_cast return self._ImportStatefile(self._session, self._host, self._interceptor) # type: ignore + @property + def list_deployment_group_revisions( + self, + ) -> Callable[ + [config.ListDeploymentGroupRevisionsRequest], + config.ListDeploymentGroupRevisionsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListDeploymentGroupRevisions( + self._session, self._host, self._interceptor + ) # type: ignore + + @property + def list_deployment_groups( + self, + ) -> Callable[ + [config.ListDeploymentGroupsRequest], config.ListDeploymentGroupsResponse + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListDeploymentGroups(self._session, self._host, self._interceptor) # type: ignore + @property def list_deployments( self, @@ -6599,6 +8549,16 @@ def lock_deployment( # In C++ this would require a dynamic_cast return self._LockDeployment(self._session, self._host, self._interceptor) # type: ignore + @property + def provision_deployment_group( + self, + ) -> Callable[[config.ProvisionDeploymentGroupRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ProvisionDeploymentGroup( + self._session, self._host, self._interceptor + ) # type: ignore + @property def unlock_deployment( self, @@ -6625,6 +8585,14 @@ def update_deployment( # In C++ this would require a dynamic_cast return self._UpdateDeployment(self._session, self._host, self._interceptor) # type: ignore + @property + def update_deployment_group( + self, + ) -> Callable[[config.UpdateDeploymentGroupRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateDeploymentGroup(self._session, self._host, self._interceptor) # type: ignore + @property def get_location(self): return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest_base.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest_base.py index 0dc1774eae33..71f58c3a92c8 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest_base.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest_base.py @@ -153,6 +153,65 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseCreateDeploymentGroup: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "deploymentGroupId": "", + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/deploymentGroups", + "body": "deployment_group", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.CreateDeploymentGroupRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseCreateDeploymentGroup._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseCreatePreview: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -257,6 +316,53 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseDeleteDeploymentGroup: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/deploymentGroups/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.DeleteDeploymentGroupRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseDeleteDeploymentGroup._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseDeletePreview: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -361,6 +467,63 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseDeprovisionDeploymentGroup: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/deploymentGroups/*}:deprovision", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.DeprovisionDeploymentGroupRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseDeprovisionDeploymentGroup._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseExportDeploymentStatefile: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -673,6 +836,100 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseGetDeploymentGroup: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/deploymentGroups/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.GetDeploymentGroupRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseGetDeploymentGroup._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetDeploymentGroupRevision: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/deploymentGroups/*/revisions/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.GetDeploymentGroupRevisionRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseGetDeploymentGroupRevision._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseGetPreview: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1012,6 +1269,100 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseListDeploymentGroupRevisions: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/deploymentGroups/*}/revisions", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.ListDeploymentGroupRevisionsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseListDeploymentGroupRevisions._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListDeploymentGroups: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/deploymentGroups", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.ListDeploymentGroupsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseListDeploymentGroups._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseListDeployments: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1398,6 +1749,63 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseProvisionDeploymentGroup: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/deploymentGroups/*}:provision", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.ProvisionDeploymentGroupRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseProvisionDeploymentGroup._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseUnlockDeployment: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1569,6 +1977,63 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseUpdateDeploymentGroup: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{deployment_group.name=projects/*/locations/*/deploymentGroups/*}", + "body": "deployment_group", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = config.UpdateDeploymentGroupRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseConfigRestTransport._BaseUpdateDeploymentGroup._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseGetLocation: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") diff --git a/packages/google-cloud-config/google/cloud/config_v1/types/__init__.py b/packages/google-cloud-config/google/cloud/config_v1/types/__init__.py index e06713bdc121..bcd6513c88f6 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/types/__init__.py +++ b/packages/google-cloud-config/google/cloud/config_v1/types/__init__.py @@ -16,19 +16,32 @@ from .config import ( ApplyResults, AutoMigrationConfig, + CreateDeploymentGroupRequest, CreateDeploymentRequest, CreatePreviewRequest, + DeleteDeploymentGroupRequest, DeleteDeploymentRequest, DeletePreviewRequest, DeleteStatefileRequest, Deployment, + DeploymentGroup, + DeploymentGroupRevision, DeploymentOperationMetadata, + DeploymentOperationSummary, + DeploymentSource, + DeploymentSpec, + DeploymentUnit, + DeploymentUnitProgress, + DeprovisionDeploymentGroupRequest, ExportDeploymentStatefileRequest, ExportLockInfoRequest, ExportPreviewResultRequest, ExportPreviewResultResponse, ExportRevisionStatefileRequest, + ExternalValueSource, GetAutoMigrationConfigRequest, + GetDeploymentGroupRequest, + GetDeploymentGroupRevisionRequest, GetDeploymentRequest, GetPreviewRequest, GetResourceChangeRequest, @@ -38,6 +51,10 @@ GetTerraformVersionRequest, GitSource, ImportStatefileRequest, + ListDeploymentGroupRevisionsRequest, + ListDeploymentGroupRevisionsResponse, + ListDeploymentGroupsRequest, + ListDeploymentGroupsResponse, ListDeploymentsRequest, ListDeploymentsResponse, ListPreviewsRequest, @@ -62,6 +79,8 @@ PropertyChange, PropertyDrift, ProviderConfig, + ProvisionDeploymentGroupOperationMetadata, + ProvisionDeploymentGroupRequest, QuotaValidation, Resource, ResourceCAIInfo, @@ -79,25 +98,39 @@ TerraformVersion, UnlockDeploymentRequest, UpdateAutoMigrationConfigRequest, + UpdateDeploymentGroupRequest, UpdateDeploymentRequest, ) __all__ = ( "ApplyResults", "AutoMigrationConfig", + "CreateDeploymentGroupRequest", "CreateDeploymentRequest", "CreatePreviewRequest", + "DeleteDeploymentGroupRequest", "DeleteDeploymentRequest", "DeletePreviewRequest", "DeleteStatefileRequest", "Deployment", + "DeploymentGroup", + "DeploymentGroupRevision", "DeploymentOperationMetadata", + "DeploymentOperationSummary", + "DeploymentSource", + "DeploymentSpec", + "DeploymentUnit", + "DeploymentUnitProgress", + "DeprovisionDeploymentGroupRequest", "ExportDeploymentStatefileRequest", "ExportLockInfoRequest", "ExportPreviewResultRequest", "ExportPreviewResultResponse", "ExportRevisionStatefileRequest", + "ExternalValueSource", "GetAutoMigrationConfigRequest", + "GetDeploymentGroupRequest", + "GetDeploymentGroupRevisionRequest", "GetDeploymentRequest", "GetPreviewRequest", "GetResourceChangeRequest", @@ -107,6 +140,10 @@ "GetTerraformVersionRequest", "GitSource", "ImportStatefileRequest", + "ListDeploymentGroupRevisionsRequest", + "ListDeploymentGroupRevisionsResponse", + "ListDeploymentGroupsRequest", + "ListDeploymentGroupsResponse", "ListDeploymentsRequest", "ListDeploymentsResponse", "ListPreviewsRequest", @@ -131,6 +168,8 @@ "PropertyChange", "PropertyDrift", "ProviderConfig", + "ProvisionDeploymentGroupOperationMetadata", + "ProvisionDeploymentGroupRequest", "Resource", "ResourceCAIInfo", "ResourceChange", @@ -147,6 +186,7 @@ "TerraformVersion", "UnlockDeploymentRequest", "UpdateAutoMigrationConfigRequest", + "UpdateDeploymentGroupRequest", "UpdateDeploymentRequest", "QuotaValidation", ) diff --git a/packages/google-cloud-config/google/cloud/config_v1/types/config.py b/packages/google-cloud-config/google/cloud/config_v1/types/config.py index 6e7b92dfcd28..c03c6b18dfac 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/types/config.py +++ b/packages/google-cloud-config/google/cloud/config_v1/types/config.py @@ -30,6 +30,8 @@ "Deployment", "TerraformBlueprint", "TerraformVariable", + "ExternalValueSource", + "DeploymentSource", "ApplyResults", "TerraformOutput", "ListDeploymentsRequest", @@ -39,6 +41,9 @@ "ListRevisionsResponse", "GetRevisionRequest", "CreateDeploymentRequest", + "CreateDeploymentGroupRequest", + "UpdateDeploymentGroupRequest", + "DeleteDeploymentGroupRequest", "UpdateDeploymentRequest", "DeleteDeploymentRequest", "OperationMetadata", @@ -92,6 +97,21 @@ "GetAutoMigrationConfigRequest", "AutoMigrationConfig", "UpdateAutoMigrationConfigRequest", + "DeploymentGroup", + "DeploymentUnit", + "DeploymentSpec", + "GetDeploymentGroupRequest", + "ListDeploymentGroupsRequest", + "ListDeploymentGroupsResponse", + "ProvisionDeploymentGroupRequest", + "DeprovisionDeploymentGroupRequest", + "DeploymentOperationSummary", + "DeploymentUnitProgress", + "ProvisionDeploymentGroupOperationMetadata", + "DeploymentGroupRevision", + "GetDeploymentGroupRevisionRequest", + "ListDeploymentGroupRevisionsRequest", + "ListDeploymentGroupRevisionsResponse", }, ) @@ -492,6 +512,10 @@ class TerraformBlueprint(proto.Message): input_values (MutableMapping[str, google.cloud.config_v1.types.TerraformVariable]): Optional. Input variable values for the Terraform blueprint. + external_values (MutableMapping[str, google.cloud.config_v1.types.ExternalValueSource]): + Optional. Map of input variable names in this + blueprint to configurations for importing values + from external sources. """ gcs_source: str = proto.Field( @@ -511,6 +535,12 @@ class TerraformBlueprint(proto.Message): number=4, message="TerraformVariable", ) + external_values: MutableMapping[str, "ExternalValueSource"] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=5, + message="ExternalValueSource", + ) class TerraformVariable(proto.Message): @@ -528,6 +558,53 @@ class TerraformVariable(proto.Message): ) +class ExternalValueSource(proto.Message): + r"""Configuration for a source of an external value. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + deployment_source (google.cloud.config_v1.types.DeploymentSource): + A source from a Deployment. + + This field is a member of `oneof`_ ``source``. + """ + + deployment_source: "DeploymentSource" = proto.Field( + proto.MESSAGE, + number=1, + oneof="source", + message="DeploymentSource", + ) + + +class DeploymentSource(proto.Message): + r"""Configuration for a value sourced from a Deployment. + + Attributes: + deployment (str): + Required. The resource name of the source + Deployment to import the output from. Format: + + projects/{project}/locations/{location}/deployments/{deployment} + The source deployment must be in the same + project and location. + output_name (str): + Required. The name of the output variable in + the source deployment's latest successfully + applied revision. + """ + + deployment: str = proto.Field( + proto.STRING, + number=1, + ) + output_name: str = proto.Field( + proto.STRING, + number=2, + ) + + class ApplyResults(proto.Message): r"""Outputs and artifacts from applying a deployment. @@ -865,6 +942,205 @@ class CreateDeploymentRequest(proto.Message): ) +class CreateDeploymentGroupRequest(proto.Message): + r"""A request to create a deployment group + + Attributes: + parent (str): + Required. The parent in whose context the Deployment Group + is created. The parent value is in the format: + 'projects/{project_id}/locations/{location}' + deployment_group_id (str): + Required. The deployment group ID. + deployment_group (google.cloud.config_v1.types.DeploymentGroup): + Required. [Deployment Group][] resource to create + request_id (str): + Optional. An optional request ID to identify + requests. Specify a unique request ID so that if + you must retry your request, the server will + know to ignore the request if it has already + been completed. The server will guarantee that + for at least 60 minutes since the first request. + + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + deployment_group_id: str = proto.Field( + proto.STRING, + number=2, + ) + deployment_group: "DeploymentGroup" = proto.Field( + proto.MESSAGE, + number=3, + message="DeploymentGroup", + ) + request_id: str = proto.Field( + proto.STRING, + number=4, + ) + + +class UpdateDeploymentGroupRequest(proto.Message): + r"""A request message for updating a deployment group + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask used to specify the fields to be + overwritten in the Deployment Group resource by the update. + + The fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. If the user does not provide a mask + then all fields will be overwritten. + deployment_group (google.cloud.config_v1.types.DeploymentGroup): + Required. + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] to + update. + + The deployment group's ``name`` field is used to identify + the resource to be updated. Format: + ``projects/{project}/locations/{location}/deploymentGroups/{deployment_group_id}`` + request_id (str): + Optional. An optional request ID to identify + requests. Specify a unique request ID so that if + you must retry your request, the server will + know to ignore the request if it has already + been completed. The server will guarantee that + for at least 60 minutes since the first request. + + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + deployment_group: "DeploymentGroup" = proto.Field( + proto.MESSAGE, + number=2, + message="DeploymentGroup", + ) + request_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class DeleteDeploymentGroupRequest(proto.Message): + r"""Request message for Delete DeploymentGroup + + Attributes: + name (str): + Required. The name of DeploymentGroup in the format + projects/{project_id}/locations/{location_id}/deploymentGroups/{deploymentGroup} + request_id (str): + Optional. An optional request ID to identify + requests. Specify a unique request ID so that if + you must retry your request, the server will + know to ignore the request if it has already + been completed. The server will guarantee that + for at least 60 minutes after the first request. + + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + force (bool): + Optional. If set to true, any revisions for + this deployment group will also be deleted. + (Otherwise, the request will only work if the + deployment group has no revisions.) + deployment_reference_policy (google.cloud.config_v1.types.DeleteDeploymentGroupRequest.DeploymentReferencePolicy): + Optional. Policy on how to handle referenced deployments + when deleting the DeploymentGroup. If unspecified, the + default behavior is to fail the deletion if any deployments + currently referenced in the ``deployment_units`` of the + DeploymentGroup or in the latest revision are not deleted. + """ + + class DeploymentReferencePolicy(proto.Enum): + r"""Policy on how to handle referenced deployments when deleting + the DeploymentGroup. + + Values: + DEPLOYMENT_REFERENCE_POLICY_UNSPECIFIED (0): + The default behavior. If unspecified, the system will act as + if ``FAIL_IF_ANY_REFERENCES_EXIST`` is specified. + FAIL_IF_ANY_REFERENCES_EXIST (1): + Fail the deletion if any deployments currently referenced in + the ``deployment_units`` of the DeploymentGroup or in the + latest revision are not deleted. + FAIL_IF_METADATA_REFERENCES_EXIST (2): + Fail the deletion only if any deployments currently + referenced in the ``deployment_units`` of the + DeploymentGroup are not deleted. The deletion will proceed + even if the deployments in the latest revision of the + DeploymentGroup are not deleted. + IGNORE_DEPLOYMENT_REFERENCES (3): + Ignore any deployments currently referenced in the + ``deployment_units`` of the DeploymentGroup or in the latest + revision. + """ + + DEPLOYMENT_REFERENCE_POLICY_UNSPECIFIED = 0 + FAIL_IF_ANY_REFERENCES_EXIST = 1 + FAIL_IF_METADATA_REFERENCES_EXIST = 2 + IGNORE_DEPLOYMENT_REFERENCES = 3 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + request_id: str = proto.Field( + proto.STRING, + number=2, + ) + force: bool = proto.Field( + proto.BOOL, + number=3, + ) + deployment_reference_policy: DeploymentReferencePolicy = proto.Field( + proto.ENUM, + number=4, + enum=DeploymentReferencePolicy, + ) + + class UpdateDeploymentRequest(proto.Message): r""" @@ -1019,6 +1295,11 @@ class OperationMetadata(proto.Message): Output only. Metadata about the preview operation state. + This field is a member of `oneof`_ ``resource_metadata``. + provision_deployment_group_metadata (google.cloud.config_v1.types.ProvisionDeploymentGroupOperationMetadata): + Output only. Metadata about + ProvisionDeploymentGroup operation state. + This field is a member of `oneof`_ ``resource_metadata``. create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when the operation was @@ -1060,6 +1341,14 @@ class OperationMetadata(proto.Message): oneof="resource_metadata", message="PreviewOperationMetadata", ) + provision_deployment_group_metadata: "ProvisionDeploymentGroupOperationMetadata" = ( + proto.Field( + proto.MESSAGE, + number=10, + oneof="resource_metadata", + message="ProvisionDeploymentGroupOperationMetadata", + ) + ) create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, @@ -3416,4 +3705,795 @@ class UpdateAutoMigrationConfigRequest(proto.Message): ) +class DeploymentGroup(proto.Message): + r"""A DeploymentGroup is a collection of DeploymentUnits that in + a DAG-like structure. + + Attributes: + name (str): + Identifier. The name of the deployment group. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when the deployment group + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when the deployment group + was last updated. + labels (MutableMapping[str, str]): + Optional. User-defined metadata for the + deployment group. + annotations (MutableMapping[str, str]): + Optional. Arbitrary key-value metadata + storage e.g. to help client tools identify + deployment group during automation. See + https://google.aip.dev/148#annotations for + details on format and size limitations. + state (google.cloud.config_v1.types.DeploymentGroup.State): + Output only. Current state of the deployment + group. + state_description (str): + Output only. Additional information regarding + the current state. + deployment_units (MutableSequence[google.cloud.config_v1.types.DeploymentUnit]): + The deployment units of the deployment group + in a DAG like structure. When a deployment group + is being provisioned, the deployment units are + deployed in a DAG order. + The provided units must be in a DAG order, + otherwise an error will be returned. + provisioning_state (google.cloud.config_v1.types.DeploymentGroup.ProvisioningState): + Output only. The provisioning state of the + deployment group. + provisioning_state_description (str): + Output only. Additional information regarding + the current provisioning state. + provisioning_error (google.rpc.status_pb2.Status): + Output only. The error status of the + deployment group provisioning or deprovisioning. + """ + + class State(proto.Enum): + r"""Possible states of a deployment group. + + Values: + STATE_UNSPECIFIED (0): + The default value. This value is used if the + state is omitted. + CREATING (1): + The deployment group is being created. + ACTIVE (2): + The deployment group is healthy. + UPDATING (3): + The deployment group is being updated. + DELETING (4): + The deployment group is being deleted. + FAILED (5): + The deployment group has encountered an + unexpected error. + SUSPENDED (6): + The deployment group is no longer being + actively reconciled. This may be the result of + recovering the project after deletion. + DELETED (7): + The deployment group has been deleted. + """ + + STATE_UNSPECIFIED = 0 + CREATING = 1 + ACTIVE = 2 + UPDATING = 3 + DELETING = 4 + FAILED = 5 + SUSPENDED = 6 + DELETED = 7 + + class ProvisioningState(proto.Enum): + r"""Possible provisioning states of a deployment group. + + Values: + PROVISIONING_STATE_UNSPECIFIED (0): + Unspecified provisioning state. + PROVISIONING (1): + The deployment group is being provisioned. + PROVISIONED (2): + The deployment group is provisioned. + FAILED_TO_PROVISION (3): + The deployment group failed to be + provisioned. + DEPROVISIONING (4): + The deployment group is being deprovisioned. + DEPROVISIONED (5): + The deployment group is deprovisioned. + FAILED_TO_DEPROVISION (6): + The deployment group failed to be + deprovisioned. + """ + + PROVISIONING_STATE_UNSPECIFIED = 0 + PROVISIONING = 1 + PROVISIONED = 2 + FAILED_TO_PROVISION = 3 + DEPROVISIONING = 4 + DEPROVISIONED = 5 + FAILED_TO_DEPROVISION = 6 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + annotations: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=5, + ) + state: State = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + state_description: str = proto.Field( + proto.STRING, + number=7, + ) + deployment_units: MutableSequence["DeploymentUnit"] = proto.RepeatedField( + proto.MESSAGE, + number=8, + message="DeploymentUnit", + ) + provisioning_state: ProvisioningState = proto.Field( + proto.ENUM, + number=9, + enum=ProvisioningState, + ) + provisioning_state_description: str = proto.Field( + proto.STRING, + number=10, + ) + provisioning_error: status_pb2.Status = proto.Field( + proto.MESSAGE, + number=11, + message=status_pb2.Status, + ) + + +class DeploymentUnit(proto.Message): + r"""A DeploymentUnit is a container for a deployment and its + dependencies. An existing deployment can be provided directly in the + unit, or the unit can act as a placeholder to define the DAG, with + the deployment specs supplied in a ``provisionDeploymentRequest``. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + id (str): + The id of the deployment unit. Must be unique + within the deployment group. + deployment (str): + Optional. The name of the deployment to be provisioned. + Format: + 'projects/{project_id}/locations/{location}/deployments/{deployment}'. + + This field is a member of `oneof`_ ``_deployment``. + dependencies (MutableSequence[str]): + Required. The IDs of the deployment units + within the deployment group that this unit + depends on. + """ + + id: str = proto.Field( + proto.STRING, + number=1, + ) + deployment: str = proto.Field( + proto.STRING, + number=2, + optional=True, + ) + dependencies: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class DeploymentSpec(proto.Message): + r"""Spec for a deployment to be created. + + Attributes: + deployment_id (str): + Required. The id of the deployment to be + created which doesn't include the project id and + location. + deployment (google.cloud.config_v1.types.Deployment): + Required. The deployment to be created. + """ + + deployment_id: str = proto.Field( + proto.STRING, + number=1, + ) + deployment: "Deployment" = proto.Field( + proto.MESSAGE, + number=2, + message="Deployment", + ) + + +class GetDeploymentGroupRequest(proto.Message): + r"""The request message for the GetDeploymentGroup method. + + Attributes: + name (str): + Required. The name of the deployment group to retrieve. + Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListDeploymentGroupsRequest(proto.Message): + r"""The request message for the ListDeploymentGroups method. + + Attributes: + parent (str): + Required. The parent, which owns this collection of + deployment groups. Format: + 'projects/{project_id}/locations/{location}'. + page_size (int): + Optional. When requesting a page of resources, 'page_size' + specifies number of resources to return. If unspecified, at + most 500 will be returned. The maximum value is 1000. + page_token (str): + Optional. Token returned by previous call to + 'ListDeploymentGroups' which specifies the + position in the list from where to continue + listing the deployment groups. + filter (str): + Optional. Lists the DeploymentGroups that match the filter + expression. A filter expression filters the deployment + groups listed in the response. The expression must be of the + form '{field} {operator} {value}' where operators: '<', '>', + '<=', '>=', '!=', '=', ':' are supported (colon ':' + represents a HAS operator which is roughly synonymous with + equality). {field} can refer to a proto or JSON field, or a + synthetic field. Field names can be camelCase or snake_case. + + Examples: + + - Filter by name: name = + "projects/foo/locations/us-central1/deploymentGroups/bar" + + - Filter by labels: + + - Resources that have a key called 'foo' labels.foo:\* + - Resources that have a key called 'foo' whose value is + 'bar' labels.foo = bar + + - Filter by state: + + - DeploymentGroups in CREATING state. state=CREATING + order_by (str): + Optional. Field to use to sort the list. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListDeploymentGroupsResponse(proto.Message): + r"""The response message for the ListDeploymentGroups method. + + Attributes: + deployment_groups (MutableSequence[google.cloud.config_v1.types.DeploymentGroup]): + The deployment groups from the specified + collection. + next_page_token (str): + Token to be supplied to the next ListDeploymentGroups + request via ``page_token`` to obtain the next set of + results. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + deployment_groups: MutableSequence["DeploymentGroup"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="DeploymentGroup", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class ProvisionDeploymentGroupRequest(proto.Message): + r"""The request message for the ProvisionDeploymentGroup method. + + Attributes: + name (str): + Required. The name of the deployment group to provision. + Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + deployment_specs (MutableMapping[str, google.cloud.config_v1.types.DeploymentSpec]): + Optional. The deployment specs of the deployment units to be + created within the same project and location of the + deployment group. The key is the unit ID, and the value is + the ``DeploymentSpec``. Provisioning will fail if a + ``deployment_spec`` has a ``deployment_id`` that matches an + existing deployment in the same project and location. If an + existing deployment was part of the last successful revision + but is no longer in the current DeploymentGroup's + ``deployment_units``, it will be recreated if included in + ``deployment_specs``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + deployment_specs: MutableMapping[str, "DeploymentSpec"] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=3, + message="DeploymentSpec", + ) + + +class DeprovisionDeploymentGroupRequest(proto.Message): + r"""The request message for the DeprovisionDeploymentGroup + method. + + Attributes: + name (str): + Required. The name of the deployment group to deprovision. + Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + force (bool): + Optional. If set to true, this option is + propagated to the deletion of each deployment in + the group. This corresponds to the 'force' field + in DeleteDeploymentRequest. + delete_policy (google.cloud.config_v1.types.DeleteDeploymentRequest.DeletePolicy): + Optional. Policy on how resources within each deployment + should be handled during deletion. This policy is applied + globally to the deletion of all deployments in this group. + This corresponds to the 'delete_policy' field in + DeleteDeploymentRequest. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + force: bool = proto.Field( + proto.BOOL, + number=2, + ) + delete_policy: "DeleteDeploymentRequest.DeletePolicy" = proto.Field( + proto.ENUM, + number=3, + enum="DeleteDeploymentRequest.DeletePolicy", + ) + + +class DeploymentOperationSummary(proto.Message): + r"""The summary of the deployment operation. + + Attributes: + deployment_step (google.cloud.config_v1.types.DeploymentOperationMetadata.DeploymentStep): + Output only. The current step the deployment + operation is running. + build (str): + Output only. Cloud Build instance UUID + associated with this operation. + logs (str): + Output only. Location of Deployment operations logs in + ``gs://{bucket}/{object}`` format. + content (str): + Output only. Location of Deployment operations content in + ``gs://{bucket}/{object}`` format. + artifacts (str): + Output only. Location of Deployment operations artifacts in + ``gs://{bucket}/{object}`` format. + """ + + deployment_step: "DeploymentOperationMetadata.DeploymentStep" = proto.Field( + proto.ENUM, + number=1, + enum="DeploymentOperationMetadata.DeploymentStep", + ) + build: str = proto.Field( + proto.STRING, + number=2, + ) + logs: str = proto.Field( + proto.STRING, + number=3, + ) + content: str = proto.Field( + proto.STRING, + number=4, + ) + artifacts: str = proto.Field( + proto.STRING, + number=5, + ) + + +class DeploymentUnitProgress(proto.Message): + r"""The progress of a deployment unit provisioning or + deprovisioning. + + Attributes: + unit_id (str): + Output only. The unit id of the deployment + unit to be provisioned. + deployment (str): + Output only. The name of the deployment to be + provisioned. Format: + + 'projects/{project}/locations/{location}/deployments/{deployment}'. + state (google.cloud.config_v1.types.DeploymentUnitProgress.State): + Output only. The current step of the + deployment unit provisioning. + state_description (str): + Output only. Additional information regarding + the current state. + deployment_operation_summary (google.cloud.config_v1.types.DeploymentOperationSummary): + Output only. The summary of the deployment + operation. + error (google.rpc.status_pb2.Status): + Output only. Holds the error status of the + deployment unit provisioning. + intent (google.cloud.config_v1.types.DeploymentUnitProgress.Intent): + Output only. The intent of the deployment + unit. + """ + + class State(proto.Enum): + r"""The possible steps a deployment unit provisioning may be + running. + + Values: + STATE_UNSPECIFIED (0): + The default value. This value is unused. + QUEUED (1): + The deployment unit is queued for deployment + creation or update. + APPLYING_DEPLOYMENT (2): + The underlying deployment of the unit is + being created or updated. + SUCCEEDED (4): + The underlying deployment operation of the + unit has succeeded. + FAILED (5): + The underlying deployment operation of the + unit has failed. + ABORTED (6): + The deployment unit was aborted, likely due + to failures in other dependent deployment units. + SKIPPED (7): + The deployment unit was skipped because there + were no changes to apply. + DELETING_DEPLOYMENT (8): + The deployment is being deleted. + PREVIEWING_DEPLOYMENT (9): + The deployment is being previewed. + """ + + STATE_UNSPECIFIED = 0 + QUEUED = 1 + APPLYING_DEPLOYMENT = 2 + SUCCEEDED = 4 + FAILED = 5 + ABORTED = 6 + SKIPPED = 7 + DELETING_DEPLOYMENT = 8 + PREVIEWING_DEPLOYMENT = 9 + + class Intent(proto.Enum): + r"""The possible intents of a deployment unit. + + Values: + INTENT_UNSPECIFIED (0): + Unspecified intent. + CREATE_DEPLOYMENT (1): + Create deployment in the unit from the + deployment spec. + UPDATE_DEPLOYMENT (2): + Update deployment in the unit. + DELETE_DEPLOYMENT (3): + Delete deployment in the unit. + RECREATE_DEPLOYMENT (4): + Recreate deployment in the unit. + CLEAN_UP (5): + Delete deployment in latest successful + revision while no longer referenced in any + deployment unit in the current deployment group. + UNCHANGED (6): + Expected to be unchanged. + """ + + INTENT_UNSPECIFIED = 0 + CREATE_DEPLOYMENT = 1 + UPDATE_DEPLOYMENT = 2 + DELETE_DEPLOYMENT = 3 + RECREATE_DEPLOYMENT = 4 + CLEAN_UP = 5 + UNCHANGED = 6 + + unit_id: str = proto.Field( + proto.STRING, + number=1, + ) + deployment: str = proto.Field( + proto.STRING, + number=2, + ) + state: State = proto.Field( + proto.ENUM, + number=3, + enum=State, + ) + state_description: str = proto.Field( + proto.STRING, + number=4, + ) + deployment_operation_summary: "DeploymentOperationSummary" = proto.Field( + proto.MESSAGE, + number=5, + message="DeploymentOperationSummary", + ) + error: status_pb2.Status = proto.Field( + proto.MESSAGE, + number=6, + message=status_pb2.Status, + ) + intent: Intent = proto.Field( + proto.ENUM, + number=7, + enum=Intent, + ) + + +class ProvisionDeploymentGroupOperationMetadata(proto.Message): + r"""Operation metadata for ``ProvisionDeploymentGroup`` and + ``DeprovisionDeploymentGroup`` long-running operations. + + Attributes: + step (google.cloud.config_v1.types.ProvisionDeploymentGroupOperationMetadata.ProvisionDeploymentGroupStep): + Output only. The current step of the + deployment group operation. + deployment_unit_progresses (MutableSequence[google.cloud.config_v1.types.DeploymentUnitProgress]): + Output only. Progress information for each + deployment unit within the operation. + """ + + class ProvisionDeploymentGroupStep(proto.Enum): + r"""Possible steps during a deployment group provisioning or + deprovisioning operation. + + Values: + PROVISION_DEPLOYMENT_GROUP_STEP_UNSPECIFIED (0): + Unspecified step. + VALIDATING_DEPLOYMENT_GROUP (1): + Validating the deployment group. + ASSOCIATING_DEPLOYMENTS_TO_DEPLOYMENT_GROUP (2): + Locking the deployments to the deployment + group for atomic actuation. + PROVISIONING_DEPLOYMENT_UNITS (3): + Provisioning the deployment units. + DISASSOCIATING_DEPLOYMENTS_FROM_DEPLOYMENT_GROUP (4): + Unlocking the deployments from the deployment + group after actuation. + SUCCEEDED (5): + The operation has succeeded. + FAILED (6): + The operation has failed. + DEPROVISIONING_DEPLOYMENT_UNITS (7): + Deprovisioning the deployment units. + """ + + PROVISION_DEPLOYMENT_GROUP_STEP_UNSPECIFIED = 0 + VALIDATING_DEPLOYMENT_GROUP = 1 + ASSOCIATING_DEPLOYMENTS_TO_DEPLOYMENT_GROUP = 2 + PROVISIONING_DEPLOYMENT_UNITS = 3 + DISASSOCIATING_DEPLOYMENTS_FROM_DEPLOYMENT_GROUP = 4 + SUCCEEDED = 5 + FAILED = 6 + DEPROVISIONING_DEPLOYMENT_UNITS = 7 + + step: ProvisionDeploymentGroupStep = proto.Field( + proto.ENUM, + number=1, + enum=ProvisionDeploymentGroupStep, + ) + deployment_unit_progresses: MutableSequence["DeploymentUnitProgress"] = ( + proto.RepeatedField( + proto.MESSAGE, + number=2, + message="DeploymentUnitProgress", + ) + ) + + +class DeploymentGroupRevision(proto.Message): + r"""A DeploymentGroupRevision represents a snapshot of a + [DeploymentGroup][google.cloud.config.v1.DeploymentGroup] at a given + point in time, created when a DeploymentGroup is provisioned or + deprovisioned. + + Attributes: + name (str): + Identifier. The name of the deployment group revision. + Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}/revisions/{revision}'. + snapshot (google.cloud.config_v1.types.DeploymentGroup): + Output only. The snapshot of the deployment + group at this revision. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time when the deployment group + revision was created. + alternative_ids (MutableSequence[str]): + Output only. The alternative IDs of the + deployment group revision. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + snapshot: "DeploymentGroup" = proto.Field( + proto.MESSAGE, + number=2, + message="DeploymentGroup", + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + alternative_ids: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) + + +class GetDeploymentGroupRevisionRequest(proto.Message): + r"""The request message for the GetDeploymentGroupRevision + method. + + Attributes: + name (str): + Required. The name of the deployment group revision to + retrieve. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}/revisions/{revision}'. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListDeploymentGroupRevisionsRequest(proto.Message): + r"""The request message for the ListDeploymentGroupRevisions + method. + + Attributes: + parent (str): + Required. The parent, which owns this collection of + deployment group revisions. Format: + 'projects/{project_id}/locations/{location}/deploymentGroups/{deployment_group}'. + page_size (int): + Optional. When requesting a page of resources, 'page_size' + specifies number of resources to return. If unspecified, a + sensible default will be used by the server. The maximum + value is 1000; values above 1000 will be coerced to 1000. + page_token (str): + Optional. Token returned by previous call to + 'ListDeploymentGroupRevisions' which specifies the position + in the list from where to continue listing the deployment + group revisions. All other parameters provided to + ``ListDeploymentGroupRevisions`` must match the call that + provided the page token. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListDeploymentGroupRevisionsResponse(proto.Message): + r"""The response message for the ListDeploymentGroupRevisions + method. + + Attributes: + deployment_group_revisions (MutableSequence[google.cloud.config_v1.types.DeploymentGroupRevision]): + The deployment group revisions from the + specified collection. + next_page_token (str): + Token to be supplied to the next + ListDeploymentGroupRevisions request via ``page_token`` to + obtain the next set of results. + unreachable (MutableSequence[str]): + Unordered list. Locations that could not be + reached. + """ + + @property + def raw_page(self): + return self + + deployment_group_revisions: MutableSequence["DeploymentGroupRevision"] = ( + proto.RepeatedField( + proto.MESSAGE, + number=1, + message="DeploymentGroupRevision", + ) + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_deployment_group_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_deployment_group_async.py new file mode 100644 index 000000000000..09a4a65bcb99 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_deployment_group_async.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_CreateDeploymentGroup_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_create_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.CreateDeploymentGroupRequest( + parent="parent_value", + deployment_group_id="deployment_group_id_value", + ) + + # Make the request + operation = client.create_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_CreateDeploymentGroup_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_deployment_group_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_deployment_group_sync.py new file mode 100644 index 000000000000..4c14fcf32a50 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_deployment_group_sync.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_CreateDeploymentGroup_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_create_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.CreateDeploymentGroupRequest( + parent="parent_value", + deployment_group_id="deployment_group_id_value", + ) + + # Make the request + operation = client.create_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_CreateDeploymentGroup_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_delete_deployment_group_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_delete_deployment_group_async.py new file mode 100644 index 000000000000..a6eee7ec2c07 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_delete_deployment_group_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_DeleteDeploymentGroup_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_delete_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.DeleteDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_DeleteDeploymentGroup_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_delete_deployment_group_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_delete_deployment_group_sync.py new file mode 100644 index 000000000000..287e6f377067 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_delete_deployment_group_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_DeleteDeploymentGroup_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_delete_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.DeleteDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_DeleteDeploymentGroup_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_deprovision_deployment_group_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_deprovision_deployment_group_async.py new file mode 100644 index 000000000000..66c61f13ba6b --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_deprovision_deployment_group_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeprovisionDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_DeprovisionDeploymentGroup_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_deprovision_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.DeprovisionDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.deprovision_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_DeprovisionDeploymentGroup_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_deprovision_deployment_group_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_deprovision_deployment_group_sync.py new file mode 100644 index 000000000000..74906d772d31 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_deprovision_deployment_group_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeprovisionDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_DeprovisionDeploymentGroup_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_deprovision_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.DeprovisionDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.deprovision_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_DeprovisionDeploymentGroup_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_async.py new file mode 100644 index 000000000000..5a7394a7eb72 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_GetDeploymentGroup_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_get_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.GetDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_deployment_group(request=request) + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_GetDeploymentGroup_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_revision_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_revision_async.py new file mode 100644 index 000000000000..d77c5250835e --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_revision_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeploymentGroupRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_GetDeploymentGroupRevision_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_get_deployment_group_revision(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.GetDeploymentGroupRevisionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_deployment_group_revision(request=request) + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_GetDeploymentGroupRevision_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_revision_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_revision_sync.py new file mode 100644 index 000000000000..383f6d708d6d --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_revision_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeploymentGroupRevision +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_GetDeploymentGroupRevision_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_get_deployment_group_revision(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.GetDeploymentGroupRevisionRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment_group_revision(request=request) + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_GetDeploymentGroupRevision_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_sync.py new file mode 100644 index 000000000000..19b6c4c98f31 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_get_deployment_group_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_GetDeploymentGroup_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_get_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.GetDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment_group(request=request) + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_GetDeploymentGroup_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_group_revisions_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_group_revisions_async.py new file mode 100644 index 000000000000..c69c853504dc --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_group_revisions_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeploymentGroupRevisions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_ListDeploymentGroupRevisions_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_list_deployment_group_revisions(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.ListDeploymentGroupRevisionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployment_group_revisions(request=request) + + # Handle the response + async for response in page_result: + print(response) + + +# [END config_v1_generated_Config_ListDeploymentGroupRevisions_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_group_revisions_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_group_revisions_sync.py new file mode 100644 index 000000000000..d0343a56d6be --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_group_revisions_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeploymentGroupRevisions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_ListDeploymentGroupRevisions_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_list_deployment_group_revisions(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.ListDeploymentGroupRevisionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployment_group_revisions(request=request) + + # Handle the response + for response in page_result: + print(response) + + +# [END config_v1_generated_Config_ListDeploymentGroupRevisions_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_groups_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_groups_async.py new file mode 100644 index 000000000000..9b390df027fc --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_groups_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeploymentGroups +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_ListDeploymentGroups_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_list_deployment_groups(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.ListDeploymentGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployment_groups(request=request) + + # Handle the response + async for response in page_result: + print(response) + + +# [END config_v1_generated_Config_ListDeploymentGroups_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_groups_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_groups_sync.py new file mode 100644 index 000000000000..e0b2901bc6af --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_list_deployment_groups_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeploymentGroups +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_ListDeploymentGroups_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_list_deployment_groups(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.ListDeploymentGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployment_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + + +# [END config_v1_generated_Config_ListDeploymentGroups_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_provision_deployment_group_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_provision_deployment_group_async.py new file mode 100644 index 000000000000..7fe96855bf13 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_provision_deployment_group_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ProvisionDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_ProvisionDeploymentGroup_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_provision_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.ProvisionDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.provision_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_ProvisionDeploymentGroup_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_provision_deployment_group_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_provision_deployment_group_sync.py new file mode 100644 index 000000000000..02758b9f0037 --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_provision_deployment_group_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ProvisionDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_ProvisionDeploymentGroup_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_provision_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.ProvisionDeploymentGroupRequest( + name="name_value", + ) + + # Make the request + operation = client.provision_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_ProvisionDeploymentGroup_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_update_deployment_group_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_update_deployment_group_async.py new file mode 100644 index 000000000000..02fff367a67c --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_update_deployment_group_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_UpdateDeploymentGroup_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +async def sample_update_deployment_group(): + # Create a client + client = config_v1.ConfigAsyncClient() + + # Initialize request argument(s) + request = config_v1.UpdateDeploymentGroupRequest() + + # Make the request + operation = client.update_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_UpdateDeploymentGroup_async] diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_update_deployment_group_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_update_deployment_group_sync.py new file mode 100644 index 000000000000..61fe63a760be --- /dev/null +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_update_deployment_group_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDeploymentGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-config + + +# [START config_v1_generated_Config_UpdateDeploymentGroup_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import config_v1 + + +def sample_update_deployment_group(): + # Create a client + client = config_v1.ConfigClient() + + # Initialize request argument(s) + request = config_v1.UpdateDeploymentGroupRequest() + + # Make the request + operation = client.update_deployment_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + +# [END config_v1_generated_Config_UpdateDeploymentGroup_sync] diff --git a/packages/google-cloud-config/samples/generated_samples/snippet_metadata_google.cloud.config.v1.json b/packages/google-cloud-config/samples/generated_samples/snippet_metadata_google.cloud.config.v1.json index ff7c1b9c2acd..0d1e734fadc6 100644 --- a/packages/google-cloud-config/samples/generated_samples/snippet_metadata_google.cloud.config.v1.json +++ b/packages/google-cloud-config/samples/generated_samples/snippet_metadata_google.cloud.config.v1.json @@ -11,6 +11,183 @@ "version": "0.5.0" }, "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.create_deployment_group", + "method": { + "fullName": "google.cloud.config.v1.Config.CreateDeploymentGroup", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "CreateDeploymentGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.CreateDeploymentGroupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "deployment_group", + "type": "google.cloud.config_v1.types.DeploymentGroup" + }, + { + "name": "deployment_group_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_deployment_group" + }, + "description": "Sample for CreateDeploymentGroup", + "file": "config_v1_generated_config_create_deployment_group_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_CreateDeploymentGroup_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_create_deployment_group_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.create_deployment_group", + "method": { + "fullName": "google.cloud.config.v1.Config.CreateDeploymentGroup", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "CreateDeploymentGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.CreateDeploymentGroupRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "deployment_group", + "type": "google.cloud.config_v1.types.DeploymentGroup" + }, + { + "name": "deployment_group_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_deployment_group" + }, + "description": "Sample for CreateDeploymentGroup", + "file": "config_v1_generated_config_create_deployment_group_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_CreateDeploymentGroup_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_create_deployment_group_sync.py" + }, { "canonical": true, "clientMethod": { @@ -365,19 +542,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.delete_deployment", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.delete_deployment_group", "method": { - "fullName": "google.cloud.config.v1.Config.DeleteDeployment", + "fullName": "google.cloud.config.v1.Config.DeleteDeploymentGroup", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "DeleteDeployment" + "shortName": "DeleteDeploymentGroup" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.DeleteDeploymentRequest" + "type": "google.cloud.config_v1.types.DeleteDeploymentGroupRequest" }, { "name": "name", @@ -397,13 +574,13 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_deployment" + "shortName": "delete_deployment_group" }, - "description": "Sample for DeleteDeployment", - "file": "config_v1_generated_config_delete_deployment_async.py", + "description": "Sample for DeleteDeploymentGroup", + "file": "config_v1_generated_config_delete_deployment_group_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_DeleteDeployment_async", + "regionTag": "config_v1_generated_Config_DeleteDeploymentGroup_async", "segments": [ { "end": 55, @@ -436,7 +613,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_delete_deployment_async.py" + "title": "config_v1_generated_config_delete_deployment_group_async.py" }, { "canonical": true, @@ -445,19 +622,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.delete_deployment", + "fullName": "google.cloud.config_v1.ConfigClient.delete_deployment_group", "method": { - "fullName": "google.cloud.config.v1.Config.DeleteDeployment", + "fullName": "google.cloud.config.v1.Config.DeleteDeploymentGroup", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "DeleteDeployment" + "shortName": "DeleteDeploymentGroup" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.DeleteDeploymentRequest" + "type": "google.cloud.config_v1.types.DeleteDeploymentGroupRequest" }, { "name": "name", @@ -477,13 +654,13 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "delete_deployment" + "shortName": "delete_deployment_group" }, - "description": "Sample for DeleteDeployment", - "file": "config_v1_generated_config_delete_deployment_sync.py", + "description": "Sample for DeleteDeploymentGroup", + "file": "config_v1_generated_config_delete_deployment_group_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_DeleteDeployment_sync", + "regionTag": "config_v1_generated_Config_DeleteDeploymentGroup_sync", "segments": [ { "end": 55, @@ -516,7 +693,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_delete_deployment_sync.py" + "title": "config_v1_generated_config_delete_deployment_group_sync.py" }, { "canonical": true, @@ -526,19 +703,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.delete_preview", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.delete_deployment", "method": { - "fullName": "google.cloud.config.v1.Config.DeletePreview", + "fullName": "google.cloud.config.v1.Config.DeleteDeployment", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "DeletePreview" + "shortName": "DeleteDeployment" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.DeletePreviewRequest" + "type": "google.cloud.config_v1.types.DeleteDeploymentRequest" }, { "name": "name", @@ -558,13 +735,13 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_preview" + "shortName": "delete_deployment" }, - "description": "Sample for DeletePreview", - "file": "config_v1_generated_config_delete_preview_async.py", + "description": "Sample for DeleteDeployment", + "file": "config_v1_generated_config_delete_deployment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_DeletePreview_async", + "regionTag": "config_v1_generated_Config_DeleteDeployment_async", "segments": [ { "end": 55, @@ -597,7 +774,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_delete_preview_async.py" + "title": "config_v1_generated_config_delete_deployment_async.py" }, { "canonical": true, @@ -606,19 +783,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.delete_preview", + "fullName": "google.cloud.config_v1.ConfigClient.delete_deployment", "method": { - "fullName": "google.cloud.config.v1.Config.DeletePreview", + "fullName": "google.cloud.config.v1.Config.DeleteDeployment", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "DeletePreview" + "shortName": "DeleteDeployment" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.DeletePreviewRequest" + "type": "google.cloud.config_v1.types.DeleteDeploymentRequest" }, { "name": "name", @@ -638,13 +815,13 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "delete_preview" + "shortName": "delete_deployment" }, - "description": "Sample for DeletePreview", - "file": "config_v1_generated_config_delete_preview_sync.py", + "description": "Sample for DeleteDeployment", + "file": "config_v1_generated_config_delete_deployment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_DeletePreview_sync", + "regionTag": "config_v1_generated_Config_DeleteDeployment_sync", "segments": [ { "end": 55, @@ -677,7 +854,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_delete_preview_sync.py" + "title": "config_v1_generated_config_delete_deployment_sync.py" }, { "canonical": true, @@ -687,19 +864,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.delete_statefile", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.delete_preview", "method": { - "fullName": "google.cloud.config.v1.Config.DeleteStatefile", + "fullName": "google.cloud.config.v1.Config.DeletePreview", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "DeleteStatefile" + "shortName": "DeletePreview" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.DeleteStatefileRequest" + "type": "google.cloud.config_v1.types.DeletePreviewRequest" }, { "name": "name", @@ -718,21 +895,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "shortName": "delete_statefile" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_preview" }, - "description": "Sample for DeleteStatefile", - "file": "config_v1_generated_config_delete_statefile_async.py", + "description": "Sample for DeletePreview", + "file": "config_v1_generated_config_delete_preview_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_DeleteStatefile_async", + "regionTag": "config_v1_generated_Config_DeletePreview_async", "segments": [ { - "end": 50, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 55, "start": 27, "type": "SHORT" }, @@ -742,20 +920,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 47, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_delete_statefile_async.py" + "title": "config_v1_generated_config_delete_preview_async.py" }, { "canonical": true, @@ -764,19 +944,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.delete_statefile", + "fullName": "google.cloud.config_v1.ConfigClient.delete_preview", "method": { - "fullName": "google.cloud.config.v1.Config.DeleteStatefile", + "fullName": "google.cloud.config.v1.Config.DeletePreview", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "DeleteStatefile" + "shortName": "DeletePreview" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.DeleteStatefileRequest" + "type": "google.cloud.config_v1.types.DeletePreviewRequest" }, { "name": "name", @@ -795,21 +975,958 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "shortName": "delete_statefile" + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_preview" }, - "description": "Sample for DeleteStatefile", - "file": "config_v1_generated_config_delete_statefile_sync.py", + "description": "Sample for DeletePreview", + "file": "config_v1_generated_config_delete_preview_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_DeleteStatefile_sync", + "regionTag": "config_v1_generated_Config_DeletePreview_sync", "segments": [ { - "end": 50, + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_delete_preview_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.delete_statefile", + "method": { + "fullName": "google.cloud.config.v1.Config.DeleteStatefile", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "DeleteStatefile" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.DeleteStatefileRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "shortName": "delete_statefile" + }, + "description": "Sample for DeleteStatefile", + "file": "config_v1_generated_config_delete_statefile_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_DeleteStatefile_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_delete_statefile_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.delete_statefile", + "method": { + "fullName": "google.cloud.config.v1.Config.DeleteStatefile", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "DeleteStatefile" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.DeleteStatefileRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "shortName": "delete_statefile" + }, + "description": "Sample for DeleteStatefile", + "file": "config_v1_generated_config_delete_statefile_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_DeleteStatefile_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_delete_statefile_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.deprovision_deployment_group", + "method": { + "fullName": "google.cloud.config.v1.Config.DeprovisionDeploymentGroup", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "DeprovisionDeploymentGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.DeprovisionDeploymentGroupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "deprovision_deployment_group" + }, + "description": "Sample for DeprovisionDeploymentGroup", + "file": "config_v1_generated_config_deprovision_deployment_group_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_DeprovisionDeploymentGroup_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_deprovision_deployment_group_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.deprovision_deployment_group", + "method": { + "fullName": "google.cloud.config.v1.Config.DeprovisionDeploymentGroup", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "DeprovisionDeploymentGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.DeprovisionDeploymentGroupRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "deprovision_deployment_group" + }, + "description": "Sample for DeprovisionDeploymentGroup", + "file": "config_v1_generated_config_deprovision_deployment_group_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_DeprovisionDeploymentGroup_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_deprovision_deployment_group_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.export_deployment_statefile", + "method": { + "fullName": "google.cloud.config.v1.Config.ExportDeploymentStatefile", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ExportDeploymentStatefile" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ExportDeploymentStatefileRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.types.Statefile", + "shortName": "export_deployment_statefile" + }, + "description": "Sample for ExportDeploymentStatefile", + "file": "config_v1_generated_config_export_deployment_statefile_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ExportDeploymentStatefile_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_export_deployment_statefile_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.export_deployment_statefile", + "method": { + "fullName": "google.cloud.config.v1.Config.ExportDeploymentStatefile", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ExportDeploymentStatefile" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ExportDeploymentStatefileRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.types.Statefile", + "shortName": "export_deployment_statefile" + }, + "description": "Sample for ExportDeploymentStatefile", + "file": "config_v1_generated_config_export_deployment_statefile_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ExportDeploymentStatefile_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_export_deployment_statefile_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.export_lock_info", + "method": { + "fullName": "google.cloud.config.v1.Config.ExportLockInfo", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ExportLockInfo" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ExportLockInfoRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.types.LockInfo", + "shortName": "export_lock_info" + }, + "description": "Sample for ExportLockInfo", + "file": "config_v1_generated_config_export_lock_info_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ExportLockInfo_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_export_lock_info_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.export_lock_info", + "method": { + "fullName": "google.cloud.config.v1.Config.ExportLockInfo", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ExportLockInfo" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ExportLockInfoRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.types.LockInfo", + "shortName": "export_lock_info" + }, + "description": "Sample for ExportLockInfo", + "file": "config_v1_generated_config_export_lock_info_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ExportLockInfo_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_export_lock_info_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.export_preview_result", + "method": { + "fullName": "google.cloud.config.v1.Config.ExportPreviewResult", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ExportPreviewResult" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ExportPreviewResultRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.types.ExportPreviewResultResponse", + "shortName": "export_preview_result" + }, + "description": "Sample for ExportPreviewResult", + "file": "config_v1_generated_config_export_preview_result_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ExportPreviewResult_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_export_preview_result_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.export_preview_result", + "method": { + "fullName": "google.cloud.config.v1.Config.ExportPreviewResult", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ExportPreviewResult" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ExportPreviewResultRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.types.ExportPreviewResultResponse", + "shortName": "export_preview_result" + }, + "description": "Sample for ExportPreviewResult", + "file": "config_v1_generated_config_export_preview_result_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ExportPreviewResult_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_export_preview_result_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.export_revision_statefile", + "method": { + "fullName": "google.cloud.config.v1.Config.ExportRevisionStatefile", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ExportRevisionStatefile" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ExportRevisionStatefileRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.types.Statefile", + "shortName": "export_revision_statefile" + }, + "description": "Sample for ExportRevisionStatefile", + "file": "config_v1_generated_config_export_revision_statefile_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ExportRevisionStatefile_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_export_revision_statefile_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.export_revision_statefile", + "method": { + "fullName": "google.cloud.config.v1.Config.ExportRevisionStatefile", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ExportRevisionStatefile" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ExportRevisionStatefileRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.types.Statefile", + "shortName": "export_revision_statefile" + }, + "description": "Sample for ExportRevisionStatefile", + "file": "config_v1_generated_config_export_revision_statefile_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ExportRevisionStatefile_sync", + "segments": [ + { + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -819,20 +1936,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 47, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_delete_statefile_sync.py" + "title": "config_v1_generated_config_export_revision_statefile_sync.py" }, { "canonical": true, @@ -842,19 +1961,23 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.export_deployment_statefile", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_auto_migration_config", "method": { - "fullName": "google.cloud.config.v1.Config.ExportDeploymentStatefile", + "fullName": "google.cloud.config.v1.Config.GetAutoMigrationConfig", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ExportDeploymentStatefile" + "shortName": "GetAutoMigrationConfig" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ExportDeploymentStatefileRequest" + "type": "google.cloud.config_v1.types.GetAutoMigrationConfigRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -869,14 +1992,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Statefile", - "shortName": "export_deployment_statefile" + "resultType": "google.cloud.config_v1.types.AutoMigrationConfig", + "shortName": "get_auto_migration_config" }, - "description": "Sample for ExportDeploymentStatefile", - "file": "config_v1_generated_config_export_deployment_statefile_async.py", + "description": "Sample for GetAutoMigrationConfig", + "file": "config_v1_generated_config_get_auto_migration_config_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ExportDeploymentStatefile_async", + "regionTag": "config_v1_generated_Config_GetAutoMigrationConfig_async", "segments": [ { "end": 51, @@ -909,7 +2032,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_export_deployment_statefile_async.py" + "title": "config_v1_generated_config_get_auto_migration_config_async.py" }, { "canonical": true, @@ -918,19 +2041,23 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.export_deployment_statefile", + "fullName": "google.cloud.config_v1.ConfigClient.get_auto_migration_config", "method": { - "fullName": "google.cloud.config.v1.Config.ExportDeploymentStatefile", + "fullName": "google.cloud.config.v1.Config.GetAutoMigrationConfig", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ExportDeploymentStatefile" + "shortName": "GetAutoMigrationConfig" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ExportDeploymentStatefileRequest" + "type": "google.cloud.config_v1.types.GetAutoMigrationConfigRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -945,14 +2072,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Statefile", - "shortName": "export_deployment_statefile" + "resultType": "google.cloud.config_v1.types.AutoMigrationConfig", + "shortName": "get_auto_migration_config" }, - "description": "Sample for ExportDeploymentStatefile", - "file": "config_v1_generated_config_export_deployment_statefile_sync.py", + "description": "Sample for GetAutoMigrationConfig", + "file": "config_v1_generated_config_get_auto_migration_config_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ExportDeploymentStatefile_sync", + "regionTag": "config_v1_generated_Config_GetAutoMigrationConfig_sync", "segments": [ { "end": 51, @@ -985,7 +2112,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_export_deployment_statefile_sync.py" + "title": "config_v1_generated_config_get_auto_migration_config_sync.py" }, { "canonical": true, @@ -995,19 +2122,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.export_lock_info", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_deployment_group_revision", "method": { - "fullName": "google.cloud.config.v1.Config.ExportLockInfo", + "fullName": "google.cloud.config.v1.Config.GetDeploymentGroupRevision", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ExportLockInfo" + "shortName": "GetDeploymentGroupRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ExportLockInfoRequest" + "type": "google.cloud.config_v1.types.GetDeploymentGroupRevisionRequest" }, { "name": "name", @@ -1026,14 +2153,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.LockInfo", - "shortName": "export_lock_info" + "resultType": "google.cloud.config_v1.types.DeploymentGroupRevision", + "shortName": "get_deployment_group_revision" }, - "description": "Sample for ExportLockInfo", - "file": "config_v1_generated_config_export_lock_info_async.py", + "description": "Sample for GetDeploymentGroupRevision", + "file": "config_v1_generated_config_get_deployment_group_revision_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ExportLockInfo_async", + "regionTag": "config_v1_generated_Config_GetDeploymentGroupRevision_async", "segments": [ { "end": 51, @@ -1066,7 +2193,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_export_lock_info_async.py" + "title": "config_v1_generated_config_get_deployment_group_revision_async.py" }, { "canonical": true, @@ -1075,19 +2202,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.export_lock_info", + "fullName": "google.cloud.config_v1.ConfigClient.get_deployment_group_revision", "method": { - "fullName": "google.cloud.config.v1.Config.ExportLockInfo", + "fullName": "google.cloud.config.v1.Config.GetDeploymentGroupRevision", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ExportLockInfo" + "shortName": "GetDeploymentGroupRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ExportLockInfoRequest" + "type": "google.cloud.config_v1.types.GetDeploymentGroupRevisionRequest" }, { "name": "name", @@ -1106,14 +2233,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.LockInfo", - "shortName": "export_lock_info" + "resultType": "google.cloud.config_v1.types.DeploymentGroupRevision", + "shortName": "get_deployment_group_revision" }, - "description": "Sample for ExportLockInfo", - "file": "config_v1_generated_config_export_lock_info_sync.py", + "description": "Sample for GetDeploymentGroupRevision", + "file": "config_v1_generated_config_get_deployment_group_revision_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ExportLockInfo_sync", + "regionTag": "config_v1_generated_Config_GetDeploymentGroupRevision_sync", "segments": [ { "end": 51, @@ -1146,7 +2273,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_export_lock_info_sync.py" + "title": "config_v1_generated_config_get_deployment_group_revision_sync.py" }, { "canonical": true, @@ -1156,19 +2283,23 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.export_preview_result", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_deployment_group", "method": { - "fullName": "google.cloud.config.v1.Config.ExportPreviewResult", + "fullName": "google.cloud.config.v1.Config.GetDeploymentGroup", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ExportPreviewResult" + "shortName": "GetDeploymentGroup" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ExportPreviewResultRequest" + "type": "google.cloud.config_v1.types.GetDeploymentGroupRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -1183,14 +2314,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.ExportPreviewResultResponse", - "shortName": "export_preview_result" + "resultType": "google.cloud.config_v1.types.DeploymentGroup", + "shortName": "get_deployment_group" }, - "description": "Sample for ExportPreviewResult", - "file": "config_v1_generated_config_export_preview_result_async.py", + "description": "Sample for GetDeploymentGroup", + "file": "config_v1_generated_config_get_deployment_group_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ExportPreviewResult_async", + "regionTag": "config_v1_generated_Config_GetDeploymentGroup_async", "segments": [ { "end": 51, @@ -1223,7 +2354,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_export_preview_result_async.py" + "title": "config_v1_generated_config_get_deployment_group_async.py" }, { "canonical": true, @@ -1232,19 +2363,23 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.export_preview_result", + "fullName": "google.cloud.config_v1.ConfigClient.get_deployment_group", "method": { - "fullName": "google.cloud.config.v1.Config.ExportPreviewResult", + "fullName": "google.cloud.config.v1.Config.GetDeploymentGroup", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ExportPreviewResult" + "shortName": "GetDeploymentGroup" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ExportPreviewResultRequest" + "type": "google.cloud.config_v1.types.GetDeploymentGroupRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -1259,14 +2394,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.ExportPreviewResultResponse", - "shortName": "export_preview_result" + "resultType": "google.cloud.config_v1.types.DeploymentGroup", + "shortName": "get_deployment_group" }, - "description": "Sample for ExportPreviewResult", - "file": "config_v1_generated_config_export_preview_result_sync.py", + "description": "Sample for GetDeploymentGroup", + "file": "config_v1_generated_config_get_deployment_group_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ExportPreviewResult_sync", + "regionTag": "config_v1_generated_Config_GetDeploymentGroup_sync", "segments": [ { "end": 51, @@ -1299,7 +2434,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_export_preview_result_sync.py" + "title": "config_v1_generated_config_get_deployment_group_sync.py" }, { "canonical": true, @@ -1309,19 +2444,23 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.export_revision_statefile", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_deployment", "method": { - "fullName": "google.cloud.config.v1.Config.ExportRevisionStatefile", + "fullName": "google.cloud.config.v1.Config.GetDeployment", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ExportRevisionStatefile" + "shortName": "GetDeployment" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ExportRevisionStatefileRequest" + "type": "google.cloud.config_v1.types.GetDeploymentRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -1336,14 +2475,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Statefile", - "shortName": "export_revision_statefile" + "resultType": "google.cloud.config_v1.types.Deployment", + "shortName": "get_deployment" }, - "description": "Sample for ExportRevisionStatefile", - "file": "config_v1_generated_config_export_revision_statefile_async.py", + "description": "Sample for GetDeployment", + "file": "config_v1_generated_config_get_deployment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ExportRevisionStatefile_async", + "regionTag": "config_v1_generated_Config_GetDeployment_async", "segments": [ { "end": 51, @@ -1376,7 +2515,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_export_revision_statefile_async.py" + "title": "config_v1_generated_config_get_deployment_async.py" }, { "canonical": true, @@ -1385,19 +2524,23 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.export_revision_statefile", + "fullName": "google.cloud.config_v1.ConfigClient.get_deployment", "method": { - "fullName": "google.cloud.config.v1.Config.ExportRevisionStatefile", + "fullName": "google.cloud.config.v1.Config.GetDeployment", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ExportRevisionStatefile" + "shortName": "GetDeployment" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ExportRevisionStatefileRequest" + "type": "google.cloud.config_v1.types.GetDeploymentRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -1412,14 +2555,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Statefile", - "shortName": "export_revision_statefile" + "resultType": "google.cloud.config_v1.types.Deployment", + "shortName": "get_deployment" }, - "description": "Sample for ExportRevisionStatefile", - "file": "config_v1_generated_config_export_revision_statefile_sync.py", + "description": "Sample for GetDeployment", + "file": "config_v1_generated_config_get_deployment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ExportRevisionStatefile_sync", + "regionTag": "config_v1_generated_Config_GetDeployment_sync", "segments": [ { "end": 51, @@ -1452,7 +2595,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_export_revision_statefile_sync.py" + "title": "config_v1_generated_config_get_deployment_sync.py" }, { "canonical": true, @@ -1462,19 +2605,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_auto_migration_config", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_preview", "method": { - "fullName": "google.cloud.config.v1.Config.GetAutoMigrationConfig", + "fullName": "google.cloud.config.v1.Config.GetPreview", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetAutoMigrationConfig" + "shortName": "GetPreview" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetAutoMigrationConfigRequest" + "type": "google.cloud.config_v1.types.GetPreviewRequest" }, { "name": "name", @@ -1493,14 +2636,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.AutoMigrationConfig", - "shortName": "get_auto_migration_config" + "resultType": "google.cloud.config_v1.types.Preview", + "shortName": "get_preview" }, - "description": "Sample for GetAutoMigrationConfig", - "file": "config_v1_generated_config_get_auto_migration_config_async.py", + "description": "Sample for GetPreview", + "file": "config_v1_generated_config_get_preview_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetAutoMigrationConfig_async", + "regionTag": "config_v1_generated_Config_GetPreview_async", "segments": [ { "end": 51, @@ -1533,7 +2676,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_auto_migration_config_async.py" + "title": "config_v1_generated_config_get_preview_async.py" }, { "canonical": true, @@ -1542,19 +2685,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.get_auto_migration_config", + "fullName": "google.cloud.config_v1.ConfigClient.get_preview", "method": { - "fullName": "google.cloud.config.v1.Config.GetAutoMigrationConfig", + "fullName": "google.cloud.config.v1.Config.GetPreview", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetAutoMigrationConfig" + "shortName": "GetPreview" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetAutoMigrationConfigRequest" + "type": "google.cloud.config_v1.types.GetPreviewRequest" }, { "name": "name", @@ -1573,14 +2716,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.AutoMigrationConfig", - "shortName": "get_auto_migration_config" + "resultType": "google.cloud.config_v1.types.Preview", + "shortName": "get_preview" }, - "description": "Sample for GetAutoMigrationConfig", - "file": "config_v1_generated_config_get_auto_migration_config_sync.py", + "description": "Sample for GetPreview", + "file": "config_v1_generated_config_get_preview_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetAutoMigrationConfig_sync", + "regionTag": "config_v1_generated_Config_GetPreview_sync", "segments": [ { "end": 51, @@ -1613,7 +2756,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_auto_migration_config_sync.py" + "title": "config_v1_generated_config_get_preview_sync.py" }, { "canonical": true, @@ -1623,19 +2766,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_deployment", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_resource_change", "method": { - "fullName": "google.cloud.config.v1.Config.GetDeployment", + "fullName": "google.cloud.config.v1.Config.GetResourceChange", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetDeployment" + "shortName": "GetResourceChange" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetDeploymentRequest" + "type": "google.cloud.config_v1.types.GetResourceChangeRequest" }, { "name": "name", @@ -1654,14 +2797,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Deployment", - "shortName": "get_deployment" + "resultType": "google.cloud.config_v1.types.ResourceChange", + "shortName": "get_resource_change" }, - "description": "Sample for GetDeployment", - "file": "config_v1_generated_config_get_deployment_async.py", + "description": "Sample for GetResourceChange", + "file": "config_v1_generated_config_get_resource_change_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetDeployment_async", + "regionTag": "config_v1_generated_Config_GetResourceChange_async", "segments": [ { "end": 51, @@ -1694,7 +2837,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_deployment_async.py" + "title": "config_v1_generated_config_get_resource_change_async.py" }, { "canonical": true, @@ -1703,19 +2846,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.get_deployment", + "fullName": "google.cloud.config_v1.ConfigClient.get_resource_change", "method": { - "fullName": "google.cloud.config.v1.Config.GetDeployment", + "fullName": "google.cloud.config.v1.Config.GetResourceChange", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetDeployment" + "shortName": "GetResourceChange" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetDeploymentRequest" + "type": "google.cloud.config_v1.types.GetResourceChangeRequest" }, { "name": "name", @@ -1734,14 +2877,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Deployment", - "shortName": "get_deployment" + "resultType": "google.cloud.config_v1.types.ResourceChange", + "shortName": "get_resource_change" }, - "description": "Sample for GetDeployment", - "file": "config_v1_generated_config_get_deployment_sync.py", + "description": "Sample for GetResourceChange", + "file": "config_v1_generated_config_get_resource_change_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetDeployment_sync", + "regionTag": "config_v1_generated_Config_GetResourceChange_sync", "segments": [ { "end": 51, @@ -1774,7 +2917,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_deployment_sync.py" + "title": "config_v1_generated_config_get_resource_change_sync.py" }, { "canonical": true, @@ -1784,19 +2927,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_preview", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_resource_drift", "method": { - "fullName": "google.cloud.config.v1.Config.GetPreview", + "fullName": "google.cloud.config.v1.Config.GetResourceDrift", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetPreview" + "shortName": "GetResourceDrift" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetPreviewRequest" + "type": "google.cloud.config_v1.types.GetResourceDriftRequest" }, { "name": "name", @@ -1815,14 +2958,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Preview", - "shortName": "get_preview" + "resultType": "google.cloud.config_v1.types.ResourceDrift", + "shortName": "get_resource_drift" }, - "description": "Sample for GetPreview", - "file": "config_v1_generated_config_get_preview_async.py", + "description": "Sample for GetResourceDrift", + "file": "config_v1_generated_config_get_resource_drift_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetPreview_async", + "regionTag": "config_v1_generated_Config_GetResourceDrift_async", "segments": [ { "end": 51, @@ -1855,7 +2998,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_preview_async.py" + "title": "config_v1_generated_config_get_resource_drift_async.py" }, { "canonical": true, @@ -1864,19 +3007,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.get_preview", + "fullName": "google.cloud.config_v1.ConfigClient.get_resource_drift", "method": { - "fullName": "google.cloud.config.v1.Config.GetPreview", + "fullName": "google.cloud.config.v1.Config.GetResourceDrift", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetPreview" + "shortName": "GetResourceDrift" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetPreviewRequest" + "type": "google.cloud.config_v1.types.GetResourceDriftRequest" }, { "name": "name", @@ -1895,14 +3038,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Preview", - "shortName": "get_preview" + "resultType": "google.cloud.config_v1.types.ResourceDrift", + "shortName": "get_resource_drift" }, - "description": "Sample for GetPreview", - "file": "config_v1_generated_config_get_preview_sync.py", + "description": "Sample for GetResourceDrift", + "file": "config_v1_generated_config_get_resource_drift_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetPreview_sync", + "regionTag": "config_v1_generated_Config_GetResourceDrift_sync", "segments": [ { "end": 51, @@ -1935,7 +3078,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_preview_sync.py" + "title": "config_v1_generated_config_get_resource_drift_sync.py" }, { "canonical": true, @@ -1945,19 +3088,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_resource_change", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_resource", "method": { - "fullName": "google.cloud.config.v1.Config.GetResourceChange", + "fullName": "google.cloud.config.v1.Config.GetResource", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetResourceChange" + "shortName": "GetResource" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetResourceChangeRequest" + "type": "google.cloud.config_v1.types.GetResourceRequest" }, { "name": "name", @@ -1976,14 +3119,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.ResourceChange", - "shortName": "get_resource_change" + "resultType": "google.cloud.config_v1.types.Resource", + "shortName": "get_resource" }, - "description": "Sample for GetResourceChange", - "file": "config_v1_generated_config_get_resource_change_async.py", + "description": "Sample for GetResource", + "file": "config_v1_generated_config_get_resource_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetResourceChange_async", + "regionTag": "config_v1_generated_Config_GetResource_async", "segments": [ { "end": 51, @@ -2016,7 +3159,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_resource_change_async.py" + "title": "config_v1_generated_config_get_resource_async.py" }, { "canonical": true, @@ -2025,19 +3168,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.get_resource_change", + "fullName": "google.cloud.config_v1.ConfigClient.get_resource", "method": { - "fullName": "google.cloud.config.v1.Config.GetResourceChange", + "fullName": "google.cloud.config.v1.Config.GetResource", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetResourceChange" + "shortName": "GetResource" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetResourceChangeRequest" + "type": "google.cloud.config_v1.types.GetResourceRequest" }, { "name": "name", @@ -2056,14 +3199,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.ResourceChange", - "shortName": "get_resource_change" + "resultType": "google.cloud.config_v1.types.Resource", + "shortName": "get_resource" }, - "description": "Sample for GetResourceChange", - "file": "config_v1_generated_config_get_resource_change_sync.py", + "description": "Sample for GetResource", + "file": "config_v1_generated_config_get_resource_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetResourceChange_sync", + "regionTag": "config_v1_generated_Config_GetResource_sync", "segments": [ { "end": 51, @@ -2096,7 +3239,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_resource_change_sync.py" + "title": "config_v1_generated_config_get_resource_sync.py" }, { "canonical": true, @@ -2106,19 +3249,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_resource_drift", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_revision", "method": { - "fullName": "google.cloud.config.v1.Config.GetResourceDrift", + "fullName": "google.cloud.config.v1.Config.GetRevision", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetResourceDrift" + "shortName": "GetRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetResourceDriftRequest" + "type": "google.cloud.config_v1.types.GetRevisionRequest" }, { "name": "name", @@ -2137,14 +3280,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.ResourceDrift", - "shortName": "get_resource_drift" + "resultType": "google.cloud.config_v1.types.Revision", + "shortName": "get_revision" }, - "description": "Sample for GetResourceDrift", - "file": "config_v1_generated_config_get_resource_drift_async.py", + "description": "Sample for GetRevision", + "file": "config_v1_generated_config_get_revision_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetResourceDrift_async", + "regionTag": "config_v1_generated_Config_GetRevision_async", "segments": [ { "end": 51, @@ -2177,7 +3320,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_resource_drift_async.py" + "title": "config_v1_generated_config_get_revision_async.py" }, { "canonical": true, @@ -2186,19 +3329,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.get_resource_drift", + "fullName": "google.cloud.config_v1.ConfigClient.get_revision", "method": { - "fullName": "google.cloud.config.v1.Config.GetResourceDrift", + "fullName": "google.cloud.config.v1.Config.GetRevision", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetResourceDrift" + "shortName": "GetRevision" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetResourceDriftRequest" + "type": "google.cloud.config_v1.types.GetRevisionRequest" }, { "name": "name", @@ -2217,14 +3360,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.ResourceDrift", - "shortName": "get_resource_drift" + "resultType": "google.cloud.config_v1.types.Revision", + "shortName": "get_revision" }, - "description": "Sample for GetResourceDrift", - "file": "config_v1_generated_config_get_resource_drift_sync.py", + "description": "Sample for GetRevision", + "file": "config_v1_generated_config_get_revision_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetResourceDrift_sync", + "regionTag": "config_v1_generated_Config_GetRevision_sync", "segments": [ { "end": 51, @@ -2257,7 +3400,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_resource_drift_sync.py" + "title": "config_v1_generated_config_get_revision_sync.py" }, { "canonical": true, @@ -2267,19 +3410,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_resource", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_terraform_version", "method": { - "fullName": "google.cloud.config.v1.Config.GetResource", + "fullName": "google.cloud.config.v1.Config.GetTerraformVersion", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetResource" + "shortName": "GetTerraformVersion" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetResourceRequest" + "type": "google.cloud.config_v1.types.GetTerraformVersionRequest" }, { "name": "name", @@ -2298,14 +3441,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Resource", - "shortName": "get_resource" + "resultType": "google.cloud.config_v1.types.TerraformVersion", + "shortName": "get_terraform_version" }, - "description": "Sample for GetResource", - "file": "config_v1_generated_config_get_resource_async.py", + "description": "Sample for GetTerraformVersion", + "file": "config_v1_generated_config_get_terraform_version_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetResource_async", + "regionTag": "config_v1_generated_Config_GetTerraformVersion_async", "segments": [ { "end": 51, @@ -2338,7 +3481,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_resource_async.py" + "title": "config_v1_generated_config_get_terraform_version_async.py" }, { "canonical": true, @@ -2347,19 +3490,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.get_resource", + "fullName": "google.cloud.config_v1.ConfigClient.get_terraform_version", "method": { - "fullName": "google.cloud.config.v1.Config.GetResource", + "fullName": "google.cloud.config.v1.Config.GetTerraformVersion", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetResource" + "shortName": "GetTerraformVersion" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetResourceRequest" + "type": "google.cloud.config_v1.types.GetTerraformVersionRequest" }, { "name": "name", @@ -2378,14 +3521,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Resource", - "shortName": "get_resource" + "resultType": "google.cloud.config_v1.types.TerraformVersion", + "shortName": "get_terraform_version" }, - "description": "Sample for GetResource", - "file": "config_v1_generated_config_get_resource_sync.py", + "description": "Sample for GetTerraformVersion", + "file": "config_v1_generated_config_get_terraform_version_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetResource_sync", + "regionTag": "config_v1_generated_Config_GetTerraformVersion_sync", "segments": [ { "end": 51, @@ -2418,7 +3561,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_resource_sync.py" + "title": "config_v1_generated_config_get_terraform_version_sync.py" }, { "canonical": true, @@ -2428,24 +3571,28 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_revision", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.import_statefile", "method": { - "fullName": "google.cloud.config.v1.Config.GetRevision", + "fullName": "google.cloud.config.v1.Config.ImportStatefile", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetRevision" + "shortName": "ImportStatefile" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetRevisionRequest" + "type": "google.cloud.config_v1.types.ImportStatefileRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "lock_id", + "type": "int" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -2459,22 +3606,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Revision", - "shortName": "get_revision" + "resultType": "google.cloud.config_v1.types.Statefile", + "shortName": "import_statefile" }, - "description": "Sample for GetRevision", - "file": "config_v1_generated_config_get_revision_async.py", + "description": "Sample for ImportStatefile", + "file": "config_v1_generated_config_import_statefile_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetRevision_async", + "regionTag": "config_v1_generated_Config_ImportStatefile_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -2484,22 +3631,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_revision_async.py" + "title": "config_v1_generated_config_import_statefile_async.py" }, { "canonical": true, @@ -2508,24 +3655,28 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.get_revision", + "fullName": "google.cloud.config_v1.ConfigClient.import_statefile", "method": { - "fullName": "google.cloud.config.v1.Config.GetRevision", + "fullName": "google.cloud.config.v1.Config.ImportStatefile", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetRevision" + "shortName": "ImportStatefile" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetRevisionRequest" + "type": "google.cloud.config_v1.types.ImportStatefileRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "lock_id", + "type": "int" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -2539,22 +3690,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Revision", - "shortName": "get_revision" + "resultType": "google.cloud.config_v1.types.Statefile", + "shortName": "import_statefile" }, - "description": "Sample for GetRevision", - "file": "config_v1_generated_config_get_revision_sync.py", + "description": "Sample for ImportStatefile", + "file": "config_v1_generated_config_import_statefile_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetRevision_sync", + "regionTag": "config_v1_generated_Config_ImportStatefile_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -2564,22 +3715,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_revision_sync.py" + "title": "config_v1_generated_config_import_statefile_sync.py" }, { "canonical": true, @@ -2589,22 +3740,22 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.get_terraform_version", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.list_deployment_group_revisions", "method": { - "fullName": "google.cloud.config.v1.Config.GetTerraformVersion", + "fullName": "google.cloud.config.v1.Config.ListDeploymentGroupRevisions", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetTerraformVersion" + "shortName": "ListDeploymentGroupRevisions" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetTerraformVersionRequest" + "type": "google.cloud.config_v1.types.ListDeploymentGroupRevisionsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -2620,22 +3771,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.TerraformVersion", - "shortName": "get_terraform_version" + "resultType": "google.cloud.config_v1.services.config.pagers.ListDeploymentGroupRevisionsAsyncPager", + "shortName": "list_deployment_group_revisions" }, - "description": "Sample for GetTerraformVersion", - "file": "config_v1_generated_config_get_terraform_version_async.py", + "description": "Sample for ListDeploymentGroupRevisions", + "file": "config_v1_generated_config_list_deployment_group_revisions_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetTerraformVersion_async", + "regionTag": "config_v1_generated_Config_ListDeploymentGroupRevisions_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -2655,12 +3806,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_terraform_version_async.py" + "title": "config_v1_generated_config_list_deployment_group_revisions_async.py" }, { "canonical": true, @@ -2669,22 +3820,22 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.get_terraform_version", + "fullName": "google.cloud.config_v1.ConfigClient.list_deployment_group_revisions", "method": { - "fullName": "google.cloud.config.v1.Config.GetTerraformVersion", + "fullName": "google.cloud.config.v1.Config.ListDeploymentGroupRevisions", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "GetTerraformVersion" + "shortName": "ListDeploymentGroupRevisions" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.GetTerraformVersionRequest" + "type": "google.cloud.config_v1.types.ListDeploymentGroupRevisionsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -2700,22 +3851,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.TerraformVersion", - "shortName": "get_terraform_version" + "resultType": "google.cloud.config_v1.services.config.pagers.ListDeploymentGroupRevisionsPager", + "shortName": "list_deployment_group_revisions" }, - "description": "Sample for GetTerraformVersion", - "file": "config_v1_generated_config_get_terraform_version_sync.py", + "description": "Sample for ListDeploymentGroupRevisions", + "file": "config_v1_generated_config_list_deployment_group_revisions_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_GetTerraformVersion_sync", + "regionTag": "config_v1_generated_Config_ListDeploymentGroupRevisions_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -2735,12 +3886,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_get_terraform_version_sync.py" + "title": "config_v1_generated_config_list_deployment_group_revisions_sync.py" }, { "canonical": true, @@ -2750,28 +3901,24 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.import_statefile", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.list_deployment_groups", "method": { - "fullName": "google.cloud.config.v1.Config.ImportStatefile", + "fullName": "google.cloud.config.v1.Config.ListDeploymentGroups", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ImportStatefile" + "shortName": "ListDeploymentGroups" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ImportStatefileRequest" + "type": "google.cloud.config_v1.types.ListDeploymentGroupsRequest" }, { "name": "parent", "type": "str" }, - { - "name": "lock_id", - "type": "int" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -2785,14 +3932,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Statefile", - "shortName": "import_statefile" + "resultType": "google.cloud.config_v1.services.config.pagers.ListDeploymentGroupsAsyncPager", + "shortName": "list_deployment_groups" }, - "description": "Sample for ImportStatefile", - "file": "config_v1_generated_config_import_statefile_async.py", + "description": "Sample for ListDeploymentGroups", + "file": "config_v1_generated_config_list_deployment_groups_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ImportStatefile_async", + "regionTag": "config_v1_generated_Config_ListDeploymentGroups_async", "segments": [ { "end": 52, @@ -2810,22 +3957,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { "end": 53, - "start": 50, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_import_statefile_async.py" + "title": "config_v1_generated_config_list_deployment_groups_async.py" }, { "canonical": true, @@ -2834,28 +3981,24 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.import_statefile", + "fullName": "google.cloud.config_v1.ConfigClient.list_deployment_groups", "method": { - "fullName": "google.cloud.config.v1.Config.ImportStatefile", + "fullName": "google.cloud.config.v1.Config.ListDeploymentGroups", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ImportStatefile" + "shortName": "ListDeploymentGroups" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ImportStatefileRequest" + "type": "google.cloud.config_v1.types.ListDeploymentGroupsRequest" }, { "name": "parent", "type": "str" }, - { - "name": "lock_id", - "type": "int" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -2869,14 +4012,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.types.Statefile", - "shortName": "import_statefile" + "resultType": "google.cloud.config_v1.services.config.pagers.ListDeploymentGroupsPager", + "shortName": "list_deployment_groups" }, - "description": "Sample for ImportStatefile", - "file": "config_v1_generated_config_import_statefile_sync.py", + "description": "Sample for ListDeploymentGroups", + "file": "config_v1_generated_config_list_deployment_groups_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ImportStatefile_sync", + "regionTag": "config_v1_generated_Config_ListDeploymentGroups_sync", "segments": [ { "end": 52, @@ -2894,22 +4037,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { "end": 53, - "start": 50, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_import_statefile_sync.py" + "title": "config_v1_generated_config_list_deployment_groups_sync.py" }, { "canonical": true, @@ -3762,7 +4905,168 @@ "file": "config_v1_generated_config_list_revisions_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ListRevisions_async", + "regionTag": "config_v1_generated_Config_ListRevisions_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_list_revisions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.list_revisions", + "method": { + "fullName": "google.cloud.config.v1.Config.ListRevisions", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ListRevisions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ListRevisionsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.services.config.pagers.ListRevisionsPager", + "shortName": "list_revisions" + }, + "description": "Sample for ListRevisions", + "file": "config_v1_generated_config_list_revisions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ListRevisions_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_list_revisions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.list_terraform_versions", + "method": { + "fullName": "google.cloud.config.v1.Config.ListTerraformVersions", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "ListTerraformVersions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.ListTerraformVersionsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.config_v1.services.config.pagers.ListTerraformVersionsAsyncPager", + "shortName": "list_terraform_versions" + }, + "description": "Sample for ListTerraformVersions", + "file": "config_v1_generated_config_list_terraform_versions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_ListTerraformVersions_async", "segments": [ { "end": 52, @@ -3795,7 +5099,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_list_revisions_async.py" + "title": "config_v1_generated_config_list_terraform_versions_async.py" }, { "canonical": true, @@ -3804,19 +5108,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.list_revisions", + "fullName": "google.cloud.config_v1.ConfigClient.list_terraform_versions", "method": { - "fullName": "google.cloud.config.v1.Config.ListRevisions", + "fullName": "google.cloud.config.v1.Config.ListTerraformVersions", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ListRevisions" + "shortName": "ListTerraformVersions" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ListRevisionsRequest" + "type": "google.cloud.config_v1.types.ListTerraformVersionsRequest" }, { "name": "parent", @@ -3835,14 +5139,14 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.services.config.pagers.ListRevisionsPager", - "shortName": "list_revisions" + "resultType": "google.cloud.config_v1.services.config.pagers.ListTerraformVersionsPager", + "shortName": "list_terraform_versions" }, - "description": "Sample for ListRevisions", - "file": "config_v1_generated_config_list_revisions_sync.py", + "description": "Sample for ListTerraformVersions", + "file": "config_v1_generated_config_list_terraform_versions_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ListRevisions_sync", + "regionTag": "config_v1_generated_Config_ListTerraformVersions_sync", "segments": [ { "end": 52, @@ -3875,7 +5179,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_list_revisions_sync.py" + "title": "config_v1_generated_config_list_terraform_versions_sync.py" }, { "canonical": true, @@ -3885,22 +5189,22 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.list_terraform_versions", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.lock_deployment", "method": { - "fullName": "google.cloud.config.v1.Config.ListTerraformVersions", + "fullName": "google.cloud.config.v1.Config.LockDeployment", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ListTerraformVersions" + "shortName": "LockDeployment" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ListTerraformVersionsRequest" + "type": "google.cloud.config_v1.types.LockDeploymentRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3916,22 +5220,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.services.config.pagers.ListTerraformVersionsAsyncPager", - "shortName": "list_terraform_versions" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "lock_deployment" }, - "description": "Sample for ListTerraformVersions", - "file": "config_v1_generated_config_list_terraform_versions_async.py", + "description": "Sample for LockDeployment", + "file": "config_v1_generated_config_lock_deployment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ListTerraformVersions_async", + "regionTag": "config_v1_generated_Config_LockDeployment_async", "segments": [ { - "end": 52, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 55, "start": 27, "type": "SHORT" }, @@ -3946,17 +5250,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_list_terraform_versions_async.py" + "title": "config_v1_generated_config_lock_deployment_async.py" }, { "canonical": true, @@ -3965,22 +5269,22 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.list_terraform_versions", + "fullName": "google.cloud.config_v1.ConfigClient.lock_deployment", "method": { - "fullName": "google.cloud.config.v1.Config.ListTerraformVersions", + "fullName": "google.cloud.config.v1.Config.LockDeployment", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "ListTerraformVersions" + "shortName": "LockDeployment" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.ListTerraformVersionsRequest" + "type": "google.cloud.config_v1.types.LockDeploymentRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3996,22 +5300,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.config_v1.services.config.pagers.ListTerraformVersionsPager", - "shortName": "list_terraform_versions" + "resultType": "google.api_core.operation.Operation", + "shortName": "lock_deployment" }, - "description": "Sample for ListTerraformVersions", - "file": "config_v1_generated_config_list_terraform_versions_sync.py", + "description": "Sample for LockDeployment", + "file": "config_v1_generated_config_lock_deployment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_ListTerraformVersions_sync", + "regionTag": "config_v1_generated_Config_LockDeployment_sync", "segments": [ { - "end": 52, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 55, "start": 27, "type": "SHORT" }, @@ -4026,17 +5330,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_list_terraform_versions_sync.py" + "title": "config_v1_generated_config_lock_deployment_sync.py" }, { "canonical": true, @@ -4046,19 +5350,19 @@ "fullName": "google.cloud.config_v1.ConfigAsyncClient", "shortName": "ConfigAsyncClient" }, - "fullName": "google.cloud.config_v1.ConfigAsyncClient.lock_deployment", + "fullName": "google.cloud.config_v1.ConfigAsyncClient.provision_deployment_group", "method": { - "fullName": "google.cloud.config.v1.Config.LockDeployment", + "fullName": "google.cloud.config.v1.Config.ProvisionDeploymentGroup", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "LockDeployment" + "shortName": "ProvisionDeploymentGroup" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.LockDeploymentRequest" + "type": "google.cloud.config_v1.types.ProvisionDeploymentGroupRequest" }, { "name": "name", @@ -4078,13 +5382,13 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "lock_deployment" + "shortName": "provision_deployment_group" }, - "description": "Sample for LockDeployment", - "file": "config_v1_generated_config_lock_deployment_async.py", + "description": "Sample for ProvisionDeploymentGroup", + "file": "config_v1_generated_config_provision_deployment_group_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_LockDeployment_async", + "regionTag": "config_v1_generated_Config_ProvisionDeploymentGroup_async", "segments": [ { "end": 55, @@ -4117,7 +5421,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_lock_deployment_async.py" + "title": "config_v1_generated_config_provision_deployment_group_async.py" }, { "canonical": true, @@ -4126,19 +5430,19 @@ "fullName": "google.cloud.config_v1.ConfigClient", "shortName": "ConfigClient" }, - "fullName": "google.cloud.config_v1.ConfigClient.lock_deployment", + "fullName": "google.cloud.config_v1.ConfigClient.provision_deployment_group", "method": { - "fullName": "google.cloud.config.v1.Config.LockDeployment", + "fullName": "google.cloud.config.v1.Config.ProvisionDeploymentGroup", "service": { "fullName": "google.cloud.config.v1.Config", "shortName": "Config" }, - "shortName": "LockDeployment" + "shortName": "ProvisionDeploymentGroup" }, "parameters": [ { "name": "request", - "type": "google.cloud.config_v1.types.LockDeploymentRequest" + "type": "google.cloud.config_v1.types.ProvisionDeploymentGroupRequest" }, { "name": "name", @@ -4158,13 +5462,13 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "lock_deployment" + "shortName": "provision_deployment_group" }, - "description": "Sample for LockDeployment", - "file": "config_v1_generated_config_lock_deployment_sync.py", + "description": "Sample for ProvisionDeploymentGroup", + "file": "config_v1_generated_config_provision_deployment_group_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "config_v1_generated_Config_LockDeployment_sync", + "regionTag": "config_v1_generated_Config_ProvisionDeploymentGroup_sync", "segments": [ { "end": 55, @@ -4197,7 +5501,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "config_v1_generated_config_lock_deployment_sync.py" + "title": "config_v1_generated_config_provision_deployment_group_sync.py" }, { "canonical": true, @@ -4537,6 +5841,175 @@ ], "title": "config_v1_generated_config_update_auto_migration_config_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.config_v1.ConfigAsyncClient", + "shortName": "ConfigAsyncClient" + }, + "fullName": "google.cloud.config_v1.ConfigAsyncClient.update_deployment_group", + "method": { + "fullName": "google.cloud.config.v1.Config.UpdateDeploymentGroup", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "UpdateDeploymentGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.UpdateDeploymentGroupRequest" + }, + { + "name": "deployment_group", + "type": "google.cloud.config_v1.types.DeploymentGroup" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_deployment_group" + }, + "description": "Sample for UpdateDeploymentGroup", + "file": "config_v1_generated_config_update_deployment_group_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_UpdateDeploymentGroup_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_update_deployment_group_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.config_v1.ConfigClient", + "shortName": "ConfigClient" + }, + "fullName": "google.cloud.config_v1.ConfigClient.update_deployment_group", + "method": { + "fullName": "google.cloud.config.v1.Config.UpdateDeploymentGroup", + "service": { + "fullName": "google.cloud.config.v1.Config", + "shortName": "Config" + }, + "shortName": "UpdateDeploymentGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.config_v1.types.UpdateDeploymentGroupRequest" + }, + { + "name": "deployment_group", + "type": "google.cloud.config_v1.types.DeploymentGroup" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_deployment_group" + }, + "description": "Sample for UpdateDeploymentGroup", + "file": "config_v1_generated_config_update_deployment_group_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "config_v1_generated_Config_UpdateDeploymentGroup_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "config_v1_generated_config_update_deployment_group_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/packages/google-cloud-config/tests/unit/gapic/config_v1/test_config.py b/packages/google-cloud-config/tests/unit/gapic/config_v1/test_config.py index 0130d81d8f67..c08376af2c14 100644 --- a/packages/google-cloud-config/tests/unit/gapic/config_v1/test_config.py +++ b/packages/google-cloud-config/tests/unit/gapic/config_v1/test_config.py @@ -12424,13 +12424,95 @@ async def test_update_auto_migration_config_flattened_error_async(): ) -def test_list_deployments_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + config.GetDeploymentGroupRequest, + dict, + ], +) +def test_get_deployment_group(request_type, transport: str = "grpc"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.DeploymentGroup( + name="name_value", + state=config.DeploymentGroup.State.CREATING, + state_description="state_description_value", + provisioning_state=config.DeploymentGroup.ProvisioningState.PROVISIONING, + provisioning_state_description="provisioning_state_description_value", + ) + response = client.get_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.GetDeploymentGroupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, config.DeploymentGroup) + assert response.name == "name_value" + assert response.state == config.DeploymentGroup.State.CREATING + assert response.state_description == "state_description_value" + assert ( + response.provisioning_state + == config.DeploymentGroup.ProvisioningState.PROVISIONING + ) + assert ( + response.provisioning_state_description + == "provisioning_state_description_value" + ) + + +def test_get_deployment_group_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.GetDeploymentGroupRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_deployment_group(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.GetDeploymentGroupRequest( + name="name_value", + ) + + +def test_get_deployment_group_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -12438,259 +12520,353 @@ def test_list_deployments_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_deployments in client._transport._wrapped_methods + assert ( + client._transport.get_deployment_group in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_deployments] = ( + client._transport._wrapped_methods[client._transport.get_deployment_group] = ( mock_rpc ) - request = {} - client.list_deployments(request) + client.get_deployment_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_deployments(request) + client.get_deployment_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_deployments_rest_required_fields( - request_type=config.ListDeploymentsRequest, +@pytest.mark.asyncio +async def test_get_deployment_group_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ConfigRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.get_deployment_group + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_deployments._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_deployment_group + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.get_deployment_group(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_deployments._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "order_by", - "page_size", - "page_token", + await client.get_deployment_group(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_deployment_group_async( + transport: str = "grpc_asyncio", request_type=config.GetDeploymentGroupRequest +): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.DeploymentGroup( + name="name_value", + state=config.DeploymentGroup.State.CREATING, + state_description="state_description_value", + provisioning_state=config.DeploymentGroup.ProvisioningState.PROVISIONING, + provisioning_state_description="provisioning_state_description_value", + ) ) + response = await client.get_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.GetDeploymentGroupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, config.DeploymentGroup) + assert response.name == "name_value" + assert response.state == config.DeploymentGroup.State.CREATING + assert response.state_description == "state_description_value" + assert ( + response.provisioning_state + == config.DeploymentGroup.ProvisioningState.PROVISIONING + ) + assert ( + response.provisioning_state_description + == "provisioning_state_description_value" ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_get_deployment_group_async_from_dict(): + await test_get_deployment_group_async(request_type=dict) + + +def test_get_deployment_group_field_headers(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = config.ListDeploymentsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.GetDeploymentGroupRequest() - # Convert return value to protobuf type - return_value = config.ListDeploymentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + call.return_value = config.DeploymentGroup() + client.get_deployment_group(request) - response = client.list_deployments(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_list_deployments_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_deployment_group_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.list_deployments._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "orderBy", - "pageSize", - "pageToken", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.GetDeploymentGroupRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.DeploymentGroup() ) - & set(("parent",)) - ) + await client.get_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_list_deployments_rest_flattened(): +def test_get_deployment_group_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = config.ListDeploymentsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.DeploymentGroup() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_deployment_group( + name="name_value", + ) - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_deployment_group_flattened_error(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_deployment_group( + config.GetDeploymentGroupRequest(), + name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.ListDeploymentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_deployments(**mock_args) +@pytest.mark.asyncio +async def test_get_deployment_group_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.DeploymentGroup() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.DeploymentGroup() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_deployment_group( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/deployments" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_list_deployments_rest_flattened_error(transport: str = "rest"): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_get_deployment_group_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_deployments( - config.ListDeploymentsRequest(), - parent="parent_value", + await client.get_deployment_group( + config.GetDeploymentGroupRequest(), + name="name_value", ) -def test_list_deployments_rest_pager(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + config.CreateDeploymentGroupRequest, + dict, + ], +) +def test_create_deployment_group(request_type, transport: str = "grpc"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - config.ListDeploymentsResponse( - deployments=[ - config.Deployment(), - config.Deployment(), - config.Deployment(), - ], - next_page_token="abc", - ), - config.ListDeploymentsResponse( - deployments=[], - next_page_token="def", - ), - config.ListDeploymentsResponse( - deployments=[ - config.Deployment(), - ], - next_page_token="ghi", - ), - config.ListDeploymentsResponse( - deployments=[ - config.Deployment(), - config.Deployment(), - ], - ), - ) - # Two responses for two calls - response = response + response + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - # Wrap the values into proper Response objs - response = tuple(config.ListDeploymentsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_deployment_group(request) - sample_request = {"parent": "projects/sample1/locations/sample2"} + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.CreateDeploymentGroupRequest() + assert args[0] == request - pager = client.list_deployments(request=sample_request) + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, config.Deployment) for i in results) - pages = list(client.list_deployments(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +def test_create_deployment_group_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.CreateDeploymentGroupRequest( + parent="parent_value", + deployment_group_id="deployment_group_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_deployment_group(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.CreateDeploymentGroupRequest( + parent="parent_value", + deployment_group_id="deployment_group_id_value", + ) -def test_get_deployment_rest_use_cached_wrapped_rpc(): +def test_create_deployment_group_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -12698,177 +12874,361 @@ def test_get_deployment_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_deployment in client._transport._wrapped_methods + assert ( + client._transport.create_deployment_group + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_deployment] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.create_deployment_group + ] = mock_rpc request = {} - client.get_deployment(request) + client.create_deployment_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_deployment(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_deployment_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_deployment_rest_required_fields(request_type=config.GetDeploymentRequest): - transport_class = transports.ConfigRestTransport +@pytest.mark.asyncio +async def test_create_deployment_group_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.create_deployment_group + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_deployment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_deployment_group + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.create_deployment_group(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_deployment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + await client.create_deployment_group(request) - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_deployment_group_async( + transport: str = "grpc_asyncio", request_type=config.CreateDeploymentGroupRequest +): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = config.Deployment() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.create_deployment_group(request) - # Convert return value to protobuf type - return_value = config.Deployment.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.CreateDeploymentGroupRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) - response = client.get_deployment(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_create_deployment_group_async_from_dict(): + await test_create_deployment_group_async(request_type=dict) -def test_get_deployment_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_create_deployment_group_field_headers(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.get_deployment._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.CreateDeploymentGroupRequest() + + request.parent = "parent_value" + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_deployment_group(request) -def test_get_deployment_rest_flattened(): + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_deployment_group_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.CreateDeploymentGroupRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.create_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_deployment_group_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = config.Deployment() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_deployment_group( + parent="parent_value", + deployment_group=config.DeploymentGroup(name="name_value"), + deployment_group_id="deployment_group_id_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/deployments/sample3" - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].deployment_group + mock_val = config.DeploymentGroup(name="name_value") + assert arg == mock_val + arg = args[0].deployment_group_id + mock_val = "deployment_group_id_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + +def test_create_deployment_group_flattened_error(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_deployment_group( + config.CreateDeploymentGroupRequest(), + parent="parent_value", + deployment_group=config.DeploymentGroup(name="name_value"), + deployment_group_id="deployment_group_id_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.Deployment.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_deployment(**mock_args) +@pytest.mark.asyncio +async def test_create_deployment_group_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_deployment_group( + parent="parent_value", + deployment_group=config.DeploymentGroup(name="name_value"), + deployment_group_id="deployment_group_id_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/deployments/*}" - % client.transport._host, - args[1], + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].deployment_group + mock_val = config.DeploymentGroup(name="name_value") + assert arg == mock_val + arg = args[0].deployment_group_id + mock_val = "deployment_group_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_deployment_group_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_deployment_group( + config.CreateDeploymentGroupRequest(), + parent="parent_value", + deployment_group=config.DeploymentGroup(name="name_value"), + deployment_group_id="deployment_group_id_value", ) -def test_get_deployment_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + config.UpdateDeploymentGroupRequest, + dict, + ], +) +def test_update_deployment_group(request_type, transport: str = "grpc"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_deployment( - config.GetDeploymentRequest(), - name="name_value", + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.UpdateDeploymentGroupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_deployment_group_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.UpdateDeploymentGroupRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) + client.update_deployment_group(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.UpdateDeploymentGroupRequest() -def test_create_deployment_rest_use_cached_wrapped_rpc(): +def test_update_deployment_group_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -12876,225 +13236,355 @@ def test_create_deployment_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.create_deployment in client._transport._wrapped_methods + assert ( + client._transport.update_deployment_group + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.create_deployment] = ( - mock_rpc + client._transport._wrapped_methods[ + client._transport.update_deployment_group + ] = mock_rpc + request = {} + client.update_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_deployment_group(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_deployment_group_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.update_deployment_group + in client._client._transport._wrapped_methods ) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_deployment_group + ] = mock_rpc + request = {} - client.create_deployment(request) + await client.update_deployment_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.create_deployment(request) + await client.update_deployment_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_create_deployment_rest_required_fields( - request_type=config.CreateDeploymentRequest, +@pytest.mark.asyncio +async def test_update_deployment_group_async( + transport: str = "grpc_asyncio", request_type=config.UpdateDeploymentGroupRequest ): - transport_class = transports.ConfigRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["deployment_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped - assert "deploymentId" not in jsonified_request + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_deployment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.update_deployment_group(request) - # verify required fields with default values are now present - assert "deploymentId" in jsonified_request - assert jsonified_request["deploymentId"] == request_init["deployment_id"] + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.UpdateDeploymentGroupRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" - jsonified_request["deploymentId"] = "deployment_id_value" + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_deployment._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "deployment_id", - "request_id", - ) - ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - assert "deploymentId" in jsonified_request - assert jsonified_request["deploymentId"] == "deployment_id_value" +@pytest.mark.asyncio +async def test_update_deployment_group_async_from_dict(): + await test_update_deployment_group_async(request_type=dict) + +def test_update_deployment_group_field_headers(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.UpdateDeploymentGroupRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.deployment_group.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_deployment_group(request) - response = client.create_deployment(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [ - ( - "deploymentId", - "", - ), - ("$alt", "json;enum-encoding=int"), - ] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "deployment_group.name=name_value", + ) in kw["metadata"] -def test_create_deployment_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_update_deployment_group_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.create_deployment._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "deploymentId", - "requestId", - ) - ) - & set( - ( - "parent", - "deploymentId", - "deployment", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.UpdateDeploymentGroupRequest() + + request.deployment_group.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") ) - ) + await client.update_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "deployment_group.name=name_value", + ) in kw["metadata"] -def test_create_deployment_rest_flattened(): +def test_update_deployment_group_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - deployment=config.Deployment( - terraform_blueprint=config.TerraformBlueprint( - gcs_source="gcs_source_value" - ) - ), - deployment_id="deployment_id_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_deployment_group( + deployment_group=config.DeploymentGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_deployment(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/deployments" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].deployment_group + mock_val = config.DeploymentGroup(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val -def test_create_deployment_rest_flattened_error(transport: str = "rest"): +def test_update_deployment_group_flattened_error(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_deployment( - config.CreateDeploymentRequest(), - parent="parent_value", - deployment=config.Deployment( - terraform_blueprint=config.TerraformBlueprint( - gcs_source="gcs_source_value" - ) - ), - deployment_id="deployment_id_value", + client.update_deployment_group( + config.UpdateDeploymentGroupRequest(), + deployment_group=config.DeploymentGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_update_deployment_rest_use_cached_wrapped_rpc(): +@pytest.mark.asyncio +async def test_update_deployment_group_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_deployment_group( + deployment_group=config.DeploymentGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].deployment_group + mock_val = config.DeploymentGroup(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_deployment_group_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_deployment_group( + config.UpdateDeploymentGroupRequest(), + deployment_group=config.DeploymentGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + config.DeleteDeploymentGroupRequest, + dict, + ], +) +def test_delete_deployment_group(request_type, transport: str = "grpc"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.DeleteDeploymentGroupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_deployment_group_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.DeleteDeploymentGroupRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_deployment_group(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.DeleteDeploymentGroupRequest( + name="name_value", + ) + + +def test_delete_deployment_group_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -13102,203 +13592,356 @@ def test_update_deployment_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.update_deployment in client._transport._wrapped_methods + assert ( + client._transport.delete_deployment_group + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.update_deployment] = ( - mock_rpc - ) - + client._transport._wrapped_methods[ + client._transport.delete_deployment_group + ] = mock_rpc request = {} - client.update_deployment(request) + client.delete_deployment_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.update_deployment(request) + client.delete_deployment_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_deployment_rest_required_fields( - request_type=config.UpdateDeploymentRequest, +@pytest.mark.asyncio +async def test_delete_deployment_group_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ConfigRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.delete_deployment_group + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_deployment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_deployment_group + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.delete_deployment_group(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_deployment._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "request_id", - "update_mask", - ) - ) - jsonified_request.update(unset_fields) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # verify required fields with non-default values are left alone + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) + await client.delete_deployment_group(request) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "patch", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} +@pytest.mark.asyncio +async def test_delete_deployment_group_async( + transport: str = "grpc_asyncio", request_type=config.DeleteDeploymentGroupRequest +): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - response = client.update_deployment(request) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.delete_deployment_group(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.DeleteDeploymentGroupRequest() + assert args[0] == request -def test_update_deployment_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) - unset_fields = transport.update_deployment._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "requestId", - "updateMask", - ) - ) - & set(("deployment",)) - ) + +@pytest.mark.asyncio +async def test_delete_deployment_group_async_from_dict(): + await test_delete_deployment_group_async(request_type=dict) -def test_update_deployment_rest_flattened(): +def test_delete_deployment_group_field_headers(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.DeleteDeploymentGroupRequest() - # get arguments that satisfy an http rule for this method - sample_request = { - "deployment": { - "name": "projects/sample1/locations/sample2/deployments/sample3" - } - } + request.name = "name_value" - # get truthy value for each flattened field - mock_args = dict( - deployment=config.Deployment( - terraform_blueprint=config.TerraformBlueprint( - gcs_source="gcs_source_value" - ) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_deployment_group_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.DeleteDeploymentGroupRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") ) - mock_args.update(sample_request) + await client.delete_deployment_group(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.update_deployment(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_deployment_group_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_deployment_group( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{deployment.name=projects/*/locations/*/deployments/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_update_deployment_rest_flattened_error(transport: str = "rest"): +def test_delete_deployment_group_flattened_error(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_deployment( - config.UpdateDeploymentRequest(), - deployment=config.Deployment( - terraform_blueprint=config.TerraformBlueprint( - gcs_source="gcs_source_value" - ) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.delete_deployment_group( + config.DeleteDeploymentGroupRequest(), + name="name_value", ) -def test_delete_deployment_rest_use_cached_wrapped_rpc(): +@pytest.mark.asyncio +async def test_delete_deployment_group_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_deployment_group( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_deployment_group_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_deployment_group( + config.DeleteDeploymentGroupRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + config.ListDeploymentGroupsRequest, + dict, + ], +) +def test_list_deployment_groups(request_type, transport: str = "grpc"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.ListDeploymentGroupsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + response = client.list_deployment_groups(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.ListDeploymentGroupsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDeploymentGroupsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +def test_list_deployment_groups_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.ListDeploymentGroupsRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_deployment_groups(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.ListDeploymentGroupsRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", + ) + + +def test_list_deployment_groups_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -13306,457 +13949,542 @@ def test_delete_deployment_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_deployment in client._transport._wrapped_methods + assert ( + client._transport.list_deployment_groups + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_deployment] = ( + client._transport._wrapped_methods[client._transport.list_deployment_groups] = ( mock_rpc ) - request = {} - client.delete_deployment(request) + client.list_deployment_groups(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_deployment(request) + client.list_deployment_groups(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_deployment_rest_required_fields( - request_type=config.DeleteDeploymentRequest, +@pytest.mark.asyncio +async def test_list_deployment_groups_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ConfigRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.list_deployment_groups + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_deployment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_deployment_groups + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.list_deployment_groups(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_deployment._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "delete_policy", - "force", - "request_id", - ) + await client.list_deployment_groups(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_deployment_groups_async( + transport: str = "grpc_asyncio", request_type=config.ListDeploymentGroupsRequest +): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentGroupsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + response = await client.list_deployment_groups(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.ListDeploymentGroupsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDeploymentGroupsAsyncPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +@pytest.mark.asyncio +async def test_list_deployment_groups_async_from_dict(): + await test_list_deployment_groups_async(request_type=dict) + +def test_list_deployment_groups_field_headers(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.ListDeploymentGroupsRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.parent = "parent_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + call.return_value = config.ListDeploymentGroupsResponse() + client.list_deployment_groups(request) - response = client.delete_deployment(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_delete_deployment_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_deployment_groups_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.delete_deployment._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "deletePolicy", - "force", - "requestId", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.ListDeploymentGroupsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentGroupsResponse() ) - & set(("name",)) - ) + await client.list_deployment_groups(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request -def test_delete_deployment_rest_flattened(): + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_deployment_groups_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/deployments/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.ListDeploymentGroupsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_deployment_groups( + parent="parent_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_deployment(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/deployments/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_delete_deployment_rest_flattened_error(transport: str = "rest"): +def test_list_deployment_groups_flattened_error(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_deployment( - config.DeleteDeploymentRequest(), - name="name_value", + client.list_deployment_groups( + config.ListDeploymentGroupsRequest(), + parent="parent_value", ) -def test_list_revisions_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_list_deployment_groups_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Ensure method has been cached - assert client._transport.list_revisions in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.ListDeploymentGroupsResponse() - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentGroupsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_deployment_groups( + parent="parent_value", ) - client._transport._wrapped_methods[client._transport.list_revisions] = mock_rpc - request = {} - client.list_revisions(request) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - client.list_revisions(request) +@pytest.mark.asyncio +async def test_list_deployment_groups_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_deployment_groups( + config.ListDeploymentGroupsRequest(), + parent="parent_value", + ) -def test_list_revisions_rest_required_fields(request_type=config.ListRevisionsRequest): - transport_class = transports.ConfigRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_revisions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_revisions._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "order_by", - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - +def test_list_deployment_groups_pager(transport_name: str = "grpc"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = config.ListRevisionsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ListRevisionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_revisions(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_list_revisions_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials + transport=transport_name, ) - unset_fields = transport.list_revisions._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "orderBy", - "pageSize", - "pageToken", - ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + config.DeploymentGroup(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[], + next_page_token="def", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + ], + ), + RuntimeError, ) - & set(("parent",)) - ) - - -def test_list_revisions_rest_flattened(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = config.ListRevisionsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/deployments/sample3" - } - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.ListRevisionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + pager = client.list_deployment_groups(request={}, retry=retry, timeout=timeout) - client.list_revisions(**mock_args) + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/deployments/*}/revisions" - % client.transport._host, - args[1], - ) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.DeploymentGroup) for i in results) -def test_list_revisions_rest_flattened_error(transport: str = "rest"): +def test_list_deployment_groups_pages(transport_name: str = "grpc"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport=transport_name, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_revisions( - config.ListRevisionsRequest(), - parent="parent_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + config.DeploymentGroup(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[], + next_page_token="def", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + ], + ), + RuntimeError, ) + pages = list(client.list_deployment_groups(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -def test_list_revisions_rest_pager(transport: str = "rest"): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_list_deployment_groups_async_pager(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - config.ListRevisionsResponse( - revisions=[ - config.Revision(), - config.Revision(), - config.Revision(), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + config.DeploymentGroup(), ], next_page_token="abc", ), - config.ListRevisionsResponse( - revisions=[], + config.ListDeploymentGroupsResponse( + deployment_groups=[], next_page_token="def", ), - config.ListRevisionsResponse( - revisions=[ - config.Revision(), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), ], next_page_token="ghi", ), - config.ListRevisionsResponse( - revisions=[ - config.Revision(), - config.Revision(), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), ], ), + RuntimeError, ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(config.ListRevisionsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = { - "parent": "projects/sample1/locations/sample2/deployments/sample3" - } - - pager = client.list_revisions(request=sample_request) + async_pager = await client.list_deployment_groups( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, config.Revision) for i in results) + assert len(responses) == 6 + assert all(isinstance(i, config.DeploymentGroup) for i in responses) - pages = list(client.list_revisions(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +@pytest.mark.asyncio +async def test_list_deployment_groups_async_pages(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) -def test_get_revision_rest_use_cached_wrapped_rpc(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + config.DeploymentGroup(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[], + next_page_token="def", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_deployment_groups(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + config.ProvisionDeploymentGroupRequest, + dict, + ], +) +def test_provision_deployment_group(request_type, transport: str = "grpc"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.provision_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.ProvisionDeploymentGroupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_provision_deployment_group_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.ProvisionDeploymentGroupRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.provision_deployment_group(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.ProvisionDeploymentGroupRequest( + name="name_value", + ) + + +def test_provision_deployment_group_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -13764,177 +14492,345 @@ def test_get_revision_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_revision in client._transport._wrapped_methods + assert ( + client._transport.provision_deployment_group + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_revision] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.provision_deployment_group + ] = mock_rpc request = {} - client.get_revision(request) + client.provision_deployment_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_revision(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.provision_deployment_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_revision_rest_required_fields(request_type=config.GetRevisionRequest): - transport_class = transports.ConfigRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) +@pytest.mark.asyncio +async def test_provision_deployment_group_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - # verify fields with default values are dropped + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_revision._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Ensure method has been cached + assert ( + client._client._transport.provision_deployment_group + in client._client._transport._wrapped_methods + ) - # verify required fields with default values are now present + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.provision_deployment_group + ] = mock_rpc - jsonified_request["name"] = "name_value" + request = {} + await client.provision_deployment_group(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_revision._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) + await client.provision_deployment_group(request) - # Designate an appropriate value for the returned response. - return_value = config.Revision() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.Revision.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) +@pytest.mark.asyncio +async def test_provision_deployment_group_async( + transport: str = "grpc_asyncio", request_type=config.ProvisionDeploymentGroupRequest +): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response = client.get_revision(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.provision_deployment_group(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.ProvisionDeploymentGroupRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -def test_get_revision_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - unset_fields = transport.get_revision._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) +@pytest.mark.asyncio +async def test_provision_deployment_group_async_from_dict(): + await test_provision_deployment_group_async(request_type=dict) -def test_get_revision_rest_flattened(): +def test_provision_deployment_group_field_headers(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = config.Revision() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.ProvisionDeploymentGroupRequest() - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" - } + request.name = "name_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.provision_deployment_group(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.Revision.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.get_revision(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_provision_deployment_group_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.ProvisionDeploymentGroupRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.provision_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_provision_deployment_group_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.provision_deployment_group( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/deployments/*/revisions/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_get_revision_rest_flattened_error(transport: str = "rest"): +def test_provision_deployment_group_flattened_error(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_revision( - config.GetRevisionRequest(), + client.provision_deployment_group( + config.ProvisionDeploymentGroupRequest(), name="name_value", ) -def test_get_resource_rest_use_cached_wrapped_rpc(): +@pytest.mark.asyncio +async def test_provision_deployment_group_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.provision_deployment_group( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_provision_deployment_group_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.provision_deployment_group( + config.ProvisionDeploymentGroupRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + config.DeprovisionDeploymentGroupRequest, + dict, + ], +) +def test_deprovision_deployment_group(request_type, transport: str = "grpc"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.deprovision_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.DeprovisionDeploymentGroupRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_deprovision_deployment_group_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.DeprovisionDeploymentGroupRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.deprovision_deployment_group(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.DeprovisionDeploymentGroupRequest( + name="name_value", + ) + + +def test_deprovision_deployment_group_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -13942,177 +14838,351 @@ def test_get_resource_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_resource in client._transport._wrapped_methods + assert ( + client._transport.deprovision_deployment_group + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_resource] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.deprovision_deployment_group + ] = mock_rpc request = {} - client.get_resource(request) + client.deprovision_deployment_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_resource(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.deprovision_deployment_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_resource_rest_required_fields(request_type=config.GetResourceRequest): - transport_class = transports.ConfigRestTransport +@pytest.mark.asyncio +async def test_deprovision_deployment_group_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.deprovision_deployment_group + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_resource._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.deprovision_deployment_group + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.deprovision_deployment_group(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_resource._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + await client.deprovision_deployment_group(request) - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_deprovision_deployment_group_async( + transport: str = "grpc_asyncio", + request_type=config.DeprovisionDeploymentGroupRequest, +): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = config.Resource() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.deprovision_deployment_group(request) - # Convert return value to protobuf type - return_value = config.Resource.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.DeprovisionDeploymentGroupRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) - response = client.get_resource(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_deprovision_deployment_group_async_from_dict(): + await test_deprovision_deployment_group_async(request_type=dict) -def test_get_resource_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_deprovision_deployment_group_field_headers(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.get_resource._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.DeprovisionDeploymentGroupRequest() + request.name = "name_value" -def test_get_resource_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.deprovision_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_deprovision_deployment_group_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.DeprovisionDeploymentGroupRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.deprovision_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_deprovision_deployment_group_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = config.Resource() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.deprovision_deployment_group( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4/resources/sample5" - } + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - # get truthy value for each flattened field - mock_args = dict( + +def test_deprovision_deployment_group_flattened_error(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.deprovision_deployment_group( + config.DeprovisionDeploymentGroupRequest(), name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.Resource.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_resource(**mock_args) +@pytest.mark.asyncio +async def test_deprovision_deployment_group_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.deprovision_deployment_group( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/deployments/*/revisions/*/resources/*}" - % client.transport._host, - args[1], + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_deprovision_deployment_group_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.deprovision_deployment_group( + config.DeprovisionDeploymentGroupRequest(), + name="name_value", ) -def test_get_resource_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + config.GetDeploymentGroupRevisionRequest, + dict, + ], +) +def test_get_deployment_group_revision(request_type, transport: str = "grpc"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_resource( - config.GetResourceRequest(), + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.DeploymentGroupRevision( name="name_value", + alternative_ids=["alternative_ids_value"], ) + response = client.get_deployment_group_revision(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.GetDeploymentGroupRevisionRequest() + assert args[0] == request -def test_list_resources_rest_use_cached_wrapped_rpc(): + # Establish that the response is the type that we expect. + assert isinstance(response, config.DeploymentGroupRevision) + assert response.name == "name_value" + assert response.alternative_ids == ["alternative_ids_value"] + + +def test_get_deployment_group_revision_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.GetDeploymentGroupRevisionRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_deployment_group_revision(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.GetDeploymentGroupRevisionRequest( + name="name_value", + ) + + +def test_get_deployment_group_revision_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -14120,259 +15190,348 @@ def test_list_resources_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_resources in client._transport._wrapped_methods + assert ( + client._transport.get_deployment_group_revision + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_resources] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.get_deployment_group_revision + ] = mock_rpc request = {} - client.list_resources(request) + client.get_deployment_group_revision(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_resources(request) + client.get_deployment_group_revision(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_resources_rest_required_fields(request_type=config.ListResourcesRequest): - transport_class = transports.ConfigRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) +@pytest.mark.asyncio +async def test_get_deployment_group_revision_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - # verify fields with default values are dropped + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_resources._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Ensure method has been cached + assert ( + client._client._transport.get_deployment_group_revision + in client._client._transport._wrapped_methods + ) - # verify required fields with default values are now present + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_deployment_group_revision + ] = mock_rpc - jsonified_request["parent"] = "parent_value" + request = {} + await client.get_deployment_group_revision(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_resources._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "order_by", - "page_size", - "page_token", - ) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_deployment_group_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_deployment_group_revision_async( + transport: str = "grpc_asyncio", + request_type=config.GetDeploymentGroupRevisionRequest, +): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.DeploymentGroupRevision( + name="name_value", + alternative_ids=["alternative_ids_value"], + ) + ) + response = await client.get_deployment_group_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.GetDeploymentGroupRevisionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, config.DeploymentGroupRevision) + assert response.name == "name_value" + assert response.alternative_ids == ["alternative_ids_value"] + + +@pytest.mark.asyncio +async def test_get_deployment_group_revision_async_from_dict(): + await test_get_deployment_group_revision_async(request_type=dict) + +def test_get_deployment_group_revision_field_headers(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = config.ListResourcesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.GetDeploymentGroupRevisionRequest() - # Convert return value to protobuf type - return_value = config.ListResourcesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + call.return_value = config.DeploymentGroupRevision() + client.get_deployment_group_revision(request) - response = client.list_resources(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -def test_list_resources_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_deployment_group_revision_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.list_resources._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "orderBy", - "pageSize", - "pageToken", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.GetDeploymentGroupRevisionRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.DeploymentGroupRevision() ) - & set(("parent",)) - ) + await client.get_deployment_group_revision(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request -def test_list_resources_rest_flattened(): + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_deployment_group_revision_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = config.ListResourcesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" - } - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.DeploymentGroupRevision() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_deployment_group_revision( + name="name_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.ListResourcesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_resources(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/deployments/*/revisions/*}/resources" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_list_resources_rest_flattened_error(transport: str = "rest"): +def test_get_deployment_group_revision_flattened_error(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_resources( - config.ListResourcesRequest(), - parent="parent_value", + client.get_deployment_group_revision( + config.GetDeploymentGroupRevisionRequest(), + name="name_value", ) -def test_list_resources_rest_pager(transport: str = "rest"): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_get_deployment_group_revision_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - config.ListResourcesResponse( - resources=[ - config.Resource(), - config.Resource(), - config.Resource(), - ], - next_page_token="abc", - ), - config.ListResourcesResponse( - resources=[], - next_page_token="def", - ), - config.ListResourcesResponse( - resources=[ - config.Resource(), - ], - next_page_token="ghi", - ), - config.ListResourcesResponse( - resources=[ - config.Resource(), - config.Resource(), - ], - ), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.DeploymentGroupRevision() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.DeploymentGroupRevision() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_deployment_group_revision( + name="name_value", ) - # Two responses for two calls - response = response + response - # Wrap the values into proper Response objs - response = tuple(config.ListResourcesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val - sample_request = { - "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" - } - pager = client.list_resources(request=sample_request) +@pytest.mark.asyncio +async def test_get_deployment_group_revision_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, config.Resource) for i in results) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_deployment_group_revision( + config.GetDeploymentGroupRevisionRequest(), + name="name_value", + ) - pages = list(client.list_resources(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +@pytest.mark.parametrize( + "request_type", + [ + config.ListDeploymentGroupRevisionsRequest, + dict, + ], +) +def test_list_deployment_group_revisions(request_type, transport: str = "grpc"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) -def test_export_deployment_statefile_rest_use_cached_wrapped_rpc(): + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.ListDeploymentGroupRevisionsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + response = client.list_deployment_group_revisions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = config.ListDeploymentGroupRevisionsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDeploymentGroupRevisionsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +def test_list_deployment_group_revisions_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = config.ListDeploymentGroupRevisionsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_deployment_group_revisions(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == config.ListDeploymentGroupRevisionsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + +def test_list_deployment_group_revisions_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -14381,7 +15540,7 @@ def test_export_deployment_statefile_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.export_deployment_statefile + client._transport.list_deployment_group_revisions in client._transport._wrapped_methods ) @@ -14391,114 +15550,31 @@ def test_export_deployment_statefile_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.export_deployment_statefile + client._transport.list_deployment_group_revisions ] = mock_rpc - request = {} - client.export_deployment_statefile(request) + client.list_deployment_group_revisions(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.export_deployment_statefile(request) + client.list_deployment_group_revisions(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_export_deployment_statefile_rest_required_fields( - request_type=config.ExportDeploymentStatefileRequest, +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ConfigRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_deployment_statefile._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_deployment_statefile._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = config.Statefile() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.Statefile.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.export_deployment_statefile(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_export_deployment_statefile_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.export_deployment_statefile._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) - - -def test_export_revision_statefile_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) # Should wrap all calls on client creation @@ -14507,315 +15583,430 @@ def test_export_revision_statefile_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.export_revision_statefile - in client._transport._wrapped_methods + client._client._transport.list_deployment_group_revisions + in client._client._transport._wrapped_methods ) # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.export_revision_statefile + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_deployment_group_revisions ] = mock_rpc request = {} - client.export_revision_statefile(request) + await client.list_deployment_group_revisions(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.export_revision_statefile(request) + await client.list_deployment_group_revisions(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_export_revision_statefile_rest_required_fields( - request_type=config.ExportRevisionStatefileRequest, +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_async( + transport: str = "grpc_asyncio", + request_type=config.ListDeploymentGroupRevisionsRequest, ): - transport_class = transports.ConfigRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_revision_statefile._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_revision_statefile._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentGroupRevisionsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + response = await client.list_deployment_group_revisions(request) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = config.ListDeploymentGroupRevisionsRequest() + assert args[0] == request - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDeploymentGroupRevisionsAsyncPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] - # Designate an appropriate value for the returned response. - return_value = config.Statefile() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_async_from_dict(): + await test_list_deployment_group_revisions_async(request_type=dict) - # Convert return value to protobuf type - return_value = config.Statefile.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} +def test_list_deployment_group_revisions_field_headers(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + ) - response = client.export_revision_statefile(request) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.ListDeploymentGroupRevisionsRequest() - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + request.parent = "parent_value" + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + call.return_value = config.ListDeploymentGroupRevisionsResponse() + client.list_deployment_group_revisions(request) -def test_export_revision_statefile_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - unset_fields = transport.export_revision_statefile._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_import_statefile_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_field_headers_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = config.ListDeploymentGroupRevisionsRequest() - # Ensure method has been cached - assert client._transport.import_statefile in client._transport._wrapped_methods + request.parent = "parent_value" - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.import_statefile] = ( - mock_rpc + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentGroupRevisionsResponse() ) - - request = {} - client.import_statefile(request) + await client.list_deployment_group_revisions(request) # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.import_statefile(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -def test_import_statefile_rest_required_fields( - request_type=config.ImportStatefileRequest, -): - transport_class = transports.ConfigRestTransport - request_init = {} - request_init["parent"] = "" - request_init["lock_id"] = 0 - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +def test_list_deployment_group_revisions_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), ) - # verify fields with default values are dropped + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.ListDeploymentGroupRevisionsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_deployment_group_revisions( + parent="parent_value", + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).import_statefile._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val - # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" - jsonified_request["lockId"] = 725 +def test_list_deployment_group_revisions_flattened_error(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).import_statefile._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_deployment_group_revisions( + config.ListDeploymentGroupRevisionsRequest(), + parent="parent_value", + ) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - assert "lockId" in jsonified_request - assert jsonified_request["lockId"] == 725 - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_flattened_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = config.Statefile() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = config.ListDeploymentGroupRevisionsResponse() - response_value = Response() - response_value.status_code = 200 + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentGroupRevisionsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_deployment_group_revisions( + parent="parent_value", + ) - # Convert return value to protobuf type - return_value = config.Statefile.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.import_statefile(request) +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_flattened_error_async(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_deployment_group_revisions( + config.ListDeploymentGroupRevisionsRequest(), + parent="parent_value", + ) -def test_import_statefile_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_list_deployment_group_revisions_pager(transport_name: str = "grpc"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, ) - unset_fields = transport.import_statefile._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "parent", - "lockId", - ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[], + next_page_token="def", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + ), + RuntimeError, ) - ) + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_deployment_group_revisions( + request={}, retry=retry, timeout=timeout + ) -def test_import_statefile_rest_flattened(): + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.DeploymentGroupRevision) for i in results) + + +def test_list_deployment_group_revisions_pages(transport_name: str = "grpc"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport_name, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = config.Statefile() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/deployments/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - lock_id=725, + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[], + next_page_token="def", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + ), + RuntimeError, ) - mock_args.update(sample_request) + pages = list(client.list_deployment_group_revisions(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.Statefile.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.import_statefile(**mock_args) +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_async_pager(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/deployments/*}:importState" - % client.transport._host, - args[1], + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[], + next_page_token="def", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_deployment_group_revisions( + request={}, ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + assert len(responses) == 6 + assert all(isinstance(i, config.DeploymentGroupRevision) for i in responses) -def test_import_statefile_rest_flattened_error(transport: str = "rest"): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_async_pages(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.import_statefile( - config.ImportStatefileRequest(), - parent="parent_value", - lock_id=725, + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[], + next_page_token="def", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + ), + RuntimeError, ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_deployment_group_revisions(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -def test_delete_statefile_rest_use_cached_wrapped_rpc(): +def test_list_deployments_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -14829,38 +16020,37 @@ def test_delete_statefile_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_statefile in client._transport._wrapped_methods + assert client._transport.list_deployments in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_statefile] = ( + client._transport._wrapped_methods[client._transport.list_deployments] = ( mock_rpc ) request = {} - client.delete_statefile(request) + client.list_deployments(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.delete_statefile(request) + client.list_deployments(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_statefile_rest_required_fields( - request_type=config.DeleteStatefileRequest, +def test_list_deployments_rest_required_fields( + request_type=config.ListDeploymentsRequest, ): transport_class = transports.ConfigRestTransport request_init = {} - request_init["name"] = "" - request_init["lock_id"] = 0 + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -14871,24 +16061,30 @@ def test_delete_statefile_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_statefile._get_unset_required_fields(jsonified_request) + ).list_deployments._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" - jsonified_request["lockId"] = 725 + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_statefile._get_unset_required_fields(jsonified_request) + ).list_deployments._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - assert "lockId" in jsonified_request - assert jsonified_request["lockId"] == 725 + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -14897,7 +16093,7 @@ def test_delete_statefile_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = None + return_value = config.ListDeploymentsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -14909,45 +16105,49 @@ def test_delete_statefile_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - json_return_value = "" + + # Convert return value to protobuf type + return_value = config.ListDeploymentsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_statefile(request) + response = client.list_deployments(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_statefile_rest_unset_required_fields(): +def test_list_deployments_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_statefile._get_unset_required_fields({}) + unset_fields = transport.list_deployments._get_unset_required_fields({}) assert set(unset_fields) == ( - set(()) - & set( + set( ( - "name", - "lockId", + "filter", + "orderBy", + "pageSize", + "pageToken", ) ) + & set(("parent",)) ) -def test_delete_statefile_rest_flattened(): +def test_list_deployments_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14956,41 +16156,41 @@ def test_delete_statefile_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = config.ListDeploymentsResponse() # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/deployments/sample3" - } + sample_request = {"parent": "projects/sample1/locations/sample2"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + # Convert return value to protobuf type + return_value = config.ListDeploymentsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_statefile(**mock_args) + client.list_deployments(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/deployments/*}:deleteState" + "%s/v1/{parent=projects/*/locations/*}/deployments" % client.transport._host, args[1], ) -def test_delete_statefile_rest_flattened_error(transport: str = "rest"): +def test_list_deployments_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -14999,14 +16199,75 @@ def test_delete_statefile_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_statefile( - config.DeleteStatefileRequest(), - name="name_value", + client.list_deployments( + config.ListDeploymentsRequest(), + parent="parent_value", ) -def test_lock_deployment_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, +def test_list_deployments_rest_pager(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + config.ListDeploymentsResponse( + deployments=[ + config.Deployment(), + config.Deployment(), + config.Deployment(), + ], + next_page_token="abc", + ), + config.ListDeploymentsResponse( + deployments=[], + next_page_token="def", + ), + config.ListDeploymentsResponse( + deployments=[ + config.Deployment(), + ], + next_page_token="ghi", + ), + config.ListDeploymentsResponse( + deployments=[ + config.Deployment(), + config.Deployment(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(config.ListDeploymentsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_deployments(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.Deployment) for i in results) + + pages = list(client.list_deployments(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_deployment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( @@ -15019,35 +16280,29 @@ def test_lock_deployment_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.lock_deployment in client._transport._wrapped_methods + assert client._transport.get_deployment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.lock_deployment] = mock_rpc + client._transport._wrapped_methods[client._transport.get_deployment] = mock_rpc request = {} - client.lock_deployment(request) + client.get_deployment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.lock_deployment(request) + client.get_deployment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_lock_deployment_rest_required_fields( - request_type=config.LockDeploymentRequest, -): +def test_get_deployment_rest_required_fields(request_type=config.GetDeploymentRequest): transport_class = transports.ConfigRestTransport request_init = {} @@ -15062,7 +16317,7 @@ def test_lock_deployment_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).lock_deployment._get_unset_required_fields(jsonified_request) + ).get_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -15071,7 +16326,7 @@ def test_lock_deployment_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).lock_deployment._get_unset_required_fields(jsonified_request) + ).get_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -15085,7 +16340,7 @@ def test_lock_deployment_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.Deployment() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -15097,37 +16352,39 @@ def test_lock_deployment_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.Deployment.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.lock_deployment(request) + response = client.get_deployment(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_lock_deployment_rest_unset_required_fields(): +def test_get_deployment_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.lock_deployment._get_unset_required_fields({}) + unset_fields = transport.get_deployment._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) -def test_lock_deployment_rest_flattened(): +def test_get_deployment_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -15136,7 +16393,7 @@ def test_lock_deployment_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.Deployment() # get arguments that satisfy an http rule for this method sample_request = { @@ -15152,25 +16409,27 @@ def test_lock_deployment_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.Deployment.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.lock_deployment(**mock_args) + client.get_deployment(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/deployments/*}:lock" + "%s/v1/{name=projects/*/locations/*/deployments/*}" % client.transport._host, args[1], ) -def test_lock_deployment_rest_flattened_error(transport: str = "rest"): +def test_get_deployment_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -15179,13 +16438,13 @@ def test_lock_deployment_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.lock_deployment( - config.LockDeploymentRequest(), + client.get_deployment( + config.GetDeploymentRequest(), name="name_value", ) -def test_unlock_deployment_rest_use_cached_wrapped_rpc(): +def test_create_deployment_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -15199,19 +16458,19 @@ def test_unlock_deployment_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.unlock_deployment in client._transport._wrapped_methods + assert client._transport.create_deployment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.unlock_deployment] = ( + client._transport._wrapped_methods[client._transport.create_deployment] = ( mock_rpc ) request = {} - client.unlock_deployment(request) + client.create_deployment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -15220,21 +16479,21 @@ def test_unlock_deployment_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.unlock_deployment(request) + client.create_deployment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_unlock_deployment_rest_required_fields( - request_type=config.UnlockDeploymentRequest, +def test_create_deployment_rest_required_fields( + request_type=config.CreateDeploymentRequest, ): transport_class = transports.ConfigRestTransport request_init = {} - request_init["name"] = "" - request_init["lock_id"] = 0 + request_init["parent"] = "" + request_init["deployment_id"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -15242,27 +16501,37 @@ def test_unlock_deployment_rest_required_fields( ) # verify fields with default values are dropped + assert "deploymentId" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).unlock_deployment._get_unset_required_fields(jsonified_request) + ).create_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + assert "deploymentId" in jsonified_request + assert jsonified_request["deploymentId"] == request_init["deployment_id"] - jsonified_request["name"] = "name_value" - jsonified_request["lockId"] = 725 + jsonified_request["parent"] = "parent_value" + jsonified_request["deploymentId"] = "deployment_id_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).unlock_deployment._get_unset_required_fields(jsonified_request) + ).create_deployment._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "deployment_id", + "request_id", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - assert "lockId" in jsonified_request - assert jsonified_request["lockId"] == 725 + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "deploymentId" in jsonified_request + assert jsonified_request["deploymentId"] == "deployment_id_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -15297,31 +16566,43 @@ def test_unlock_deployment_rest_required_fields( req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.unlock_deployment(request) + response = client.create_deployment(request) - expected_params = [("$alt", "json;enum-encoding=int")] + expected_params = [ + ( + "deploymentId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_unlock_deployment_rest_unset_required_fields(): +def test_create_deployment_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.unlock_deployment._get_unset_required_fields({}) + unset_fields = transport.create_deployment._get_unset_required_fields({}) assert set(unset_fields) == ( - set(()) + set( + ( + "deploymentId", + "requestId", + ) + ) & set( ( - "name", - "lockId", + "parent", + "deploymentId", + "deployment", ) ) ) -def test_unlock_deployment_rest_flattened(): +def test_create_deployment_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -15333,14 +16614,17 @@ def test_unlock_deployment_rest_flattened(): return_value = operations_pb2.Operation(name="operations/spam") # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/deployments/sample3" - } + sample_request = {"parent": "projects/sample1/locations/sample2"} # get truthy value for each flattened field mock_args = dict( - name="name_value", - lock_id=725, + parent="parent_value", + deployment=config.Deployment( + terraform_blueprint=config.TerraformBlueprint( + gcs_source="gcs_source_value" + ) + ), + deployment_id="deployment_id_value", ) mock_args.update(sample_request) @@ -15352,20 +16636,20 @@ def test_unlock_deployment_rest_flattened(): req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.unlock_deployment(**mock_args) + client.create_deployment(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/deployments/*}:unlock" + "%s/v1/{parent=projects/*/locations/*}/deployments" % client.transport._host, args[1], ) -def test_unlock_deployment_rest_flattened_error(transport: str = "rest"): +def test_create_deployment_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -15374,14 +16658,19 @@ def test_unlock_deployment_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.unlock_deployment( - config.UnlockDeploymentRequest(), - name="name_value", - lock_id=725, + client.create_deployment( + config.CreateDeploymentRequest(), + parent="parent_value", + deployment=config.Deployment( + terraform_blueprint=config.TerraformBlueprint( + gcs_source="gcs_source_value" + ) + ), + deployment_id="deployment_id_value", ) -def test_export_lock_info_rest_use_cached_wrapped_rpc(): +def test_update_deployment_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -15395,37 +16684,40 @@ def test_export_lock_info_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.export_lock_info in client._transport._wrapped_methods + assert client._transport.update_deployment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.export_lock_info] = ( + client._transport._wrapped_methods[client._transport.update_deployment] = ( mock_rpc ) request = {} - client.export_lock_info(request) + client.update_deployment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.export_lock_info(request) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_deployment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_export_lock_info_rest_required_fields( - request_type=config.ExportLockInfoRequest, +def test_update_deployment_rest_required_fields( + request_type=config.UpdateDeploymentRequest, ): transport_class = transports.ConfigRestTransport request_init = {} - request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -15436,21 +16728,24 @@ def test_export_lock_info_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).export_lock_info._get_unset_required_fields(jsonified_request) + ).update_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" - unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).export_lock_info._get_unset_required_fields(jsonified_request) + ).update_deployment._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "request_id", + "update_mask", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -15459,7 +16754,7 @@ def test_export_lock_info_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.LockInfo() + return_value = operations_pb2.Operation(name="operations/spam") # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -15471,39 +16766,45 @@ def test_export_lock_info_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "patch", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.LockInfo.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.export_lock_info(request) + response = client.update_deployment(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_export_lock_info_rest_unset_required_fields(): +def test_update_deployment_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.export_lock_info._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.update_deployment._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "requestId", + "updateMask", + ) + ) + & set(("deployment",)) + ) -def test_export_lock_info_rest_flattened(): +def test_update_deployment_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -15512,43 +16813,48 @@ def test_export_lock_info_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.LockInfo() + return_value = operations_pb2.Operation(name="operations/spam") # get arguments that satisfy an http rule for this method sample_request = { - "name": "projects/sample1/locations/sample2/deployments/sample3" + "deployment": { + "name": "projects/sample1/locations/sample2/deployments/sample3" + } } # get truthy value for each flattened field mock_args = dict( - name="name_value", + deployment=config.Deployment( + terraform_blueprint=config.TerraformBlueprint( + gcs_source="gcs_source_value" + ) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.LockInfo.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.export_lock_info(**mock_args) + client.update_deployment(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/deployments/*}:exportLock" + "%s/v1/{deployment.name=projects/*/locations/*/deployments/*}" % client.transport._host, args[1], ) -def test_export_lock_info_rest_flattened_error(transport: str = "rest"): +def test_update_deployment_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -15557,13 +16863,18 @@ def test_export_lock_info_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.export_lock_info( - config.ExportLockInfoRequest(), - name="name_value", + client.update_deployment( + config.UpdateDeploymentRequest(), + deployment=config.Deployment( + terraform_blueprint=config.TerraformBlueprint( + gcs_source="gcs_source_value" + ) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_create_preview_rest_use_cached_wrapped_rpc(): +def test_delete_deployment_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -15577,17 +16888,19 @@ def test_create_preview_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.create_preview in client._transport._wrapped_methods + assert client._transport.delete_deployment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.create_preview] = mock_rpc + client._transport._wrapped_methods[client._transport.delete_deployment] = ( + mock_rpc + ) request = {} - client.create_preview(request) + client.delete_deployment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -15596,18 +16909,20 @@ def test_create_preview_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.create_preview(request) + client.delete_deployment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_create_preview_rest_required_fields(request_type=config.CreatePreviewRequest): +def test_delete_deployment_rest_required_fields( + request_type=config.DeleteDeploymentRequest, +): transport_class = transports.ConfigRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -15618,28 +16933,29 @@ def test_create_preview_rest_required_fields(request_type=config.CreatePreviewRe unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_preview._get_unset_required_fields(jsonified_request) + ).delete_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).create_preview._get_unset_required_fields(jsonified_request) + ).delete_deployment._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set( ( - "preview_id", + "delete_policy", + "force", "request_id", ) ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -15660,10 +16976,9 @@ def test_create_preview_rest_required_fields(request_type=config.CreatePreviewRe pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "delete", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() @@ -15674,36 +16989,32 @@ def test_create_preview_rest_required_fields(request_type=config.CreatePreviewRe req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_preview(request) + response = client.delete_deployment(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_create_preview_rest_unset_required_fields(): +def test_delete_deployment_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.create_preview._get_unset_required_fields({}) + unset_fields = transport.delete_deployment._get_unset_required_fields({}) assert set(unset_fields) == ( set( ( - "previewId", + "deletePolicy", + "force", "requestId", ) ) - & set( - ( - "parent", - "preview", - ) - ) + & set(("name",)) ) -def test_create_preview_rest_flattened(): +def test_delete_deployment_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -15715,16 +17026,13 @@ def test_create_preview_rest_flattened(): return_value = operations_pb2.Operation(name="operations/spam") # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + sample_request = { + "name": "projects/sample1/locations/sample2/deployments/sample3" + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - preview=config.Preview( - terraform_blueprint=config.TerraformBlueprint( - gcs_source="gcs_source_value" - ) - ), + name="name_value", ) mock_args.update(sample_request) @@ -15736,19 +17044,20 @@ def test_create_preview_rest_flattened(): req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_preview(**mock_args) + client.delete_deployment(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/previews" % client.transport._host, + "%s/v1/{name=projects/*/locations/*/deployments/*}" + % client.transport._host, args[1], ) -def test_create_preview_rest_flattened_error(transport: str = "rest"): +def test_delete_deployment_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -15757,18 +17066,13 @@ def test_create_preview_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_preview( - config.CreatePreviewRequest(), - parent="parent_value", - preview=config.Preview( - terraform_blueprint=config.TerraformBlueprint( - gcs_source="gcs_source_value" - ) - ), + client.delete_deployment( + config.DeleteDeploymentRequest(), + name="name_value", ) -def test_get_preview_rest_use_cached_wrapped_rpc(): +def test_list_revisions_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -15782,33 +17086,33 @@ def test_get_preview_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_preview in client._transport._wrapped_methods + assert client._transport.list_revisions in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_preview] = mock_rpc + client._transport._wrapped_methods[client._transport.list_revisions] = mock_rpc request = {} - client.get_preview(request) + client.list_revisions(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_preview(request) + client.list_revisions(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_preview_rest_required_fields(request_type=config.GetPreviewRequest): +def test_list_revisions_rest_required_fields(request_type=config.ListRevisionsRequest): transport_class = transports.ConfigRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -15819,21 +17123,30 @@ def test_get_preview_rest_required_fields(request_type=config.GetPreviewRequest) unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_preview._get_unset_required_fields(jsonified_request) + ).list_revisions._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_preview._get_unset_required_fields(jsonified_request) + ).list_revisions._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -15842,7 +17155,7 @@ def test_get_preview_rest_required_fields(request_type=config.GetPreviewRequest) request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.Preview() + return_value = config.ListRevisionsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -15863,30 +17176,40 @@ def test_get_preview_rest_required_fields(request_type=config.GetPreviewRequest) response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.Preview.pb(return_value) + return_value = config.ListRevisionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_preview(request) + response = client.list_revisions(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_preview_rest_unset_required_fields(): +def test_list_revisions_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_preview._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.list_revisions._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) -def test_get_preview_rest_flattened(): +def test_list_revisions_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -15895,14 +17218,16 @@ def test_get_preview_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.Preview() + return_value = config.ListRevisionsResponse() # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/locations/sample2/previews/sample3"} + sample_request = { + "parent": "projects/sample1/locations/sample2/deployments/sample3" + } # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) @@ -15910,25 +17235,26 @@ def test_get_preview_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.Preview.pb(return_value) + return_value = config.ListRevisionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_preview(**mock_args) + client.list_revisions(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/previews/*}" % client.transport._host, + "%s/v1/{parent=projects/*/locations/*/deployments/*}/revisions" + % client.transport._host, args[1], ) -def test_get_preview_rest_flattened_error(transport: str = "rest"): +def test_list_revisions_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -15937,53 +17263,116 @@ def test_get_preview_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_preview( - config.GetPreviewRequest(), - name="name_value", - ) - - -def test_list_previews_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_previews in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.list_revisions( + config.ListRevisionsRequest(), + parent="parent_value", ) - client._transport._wrapped_methods[client._transport.list_previews] = mock_rpc - - request = {} - client.list_previews(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - client.list_previews(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +def test_list_revisions_rest_pager(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + config.ListRevisionsResponse( + revisions=[ + config.Revision(), + config.Revision(), + config.Revision(), + ], + next_page_token="abc", + ), + config.ListRevisionsResponse( + revisions=[], + next_page_token="def", + ), + config.ListRevisionsResponse( + revisions=[ + config.Revision(), + ], + next_page_token="ghi", + ), + config.ListRevisionsResponse( + revisions=[ + config.Revision(), + config.Revision(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(config.ListRevisionsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/deployments/sample3" + } + + pager = client.list_revisions(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.Revision) for i in results) + + pages = list(client.list_revisions(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_revision_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_revision in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_revision] = mock_rpc + + request = {} + client.get_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -def test_list_previews_rest_required_fields(request_type=config.ListPreviewsRequest): - transport_class = transports.ConfigRestTransport + +def test_get_revision_rest_required_fields(request_type=config.GetRevisionRequest): + transport_class = transports.ConfigRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -15994,30 +17383,21 @@ def test_list_previews_rest_required_fields(request_type=config.ListPreviewsRequ unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_previews._get_unset_required_fields(jsonified_request) + ).get_revision._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_previews._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "order_by", - "page_size", - "page_token", - ) - ) + ).get_revision._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -16026,7 +17406,7 @@ def test_list_previews_rest_required_fields(request_type=config.ListPreviewsRequ request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.ListPreviewsResponse() + return_value = config.Revision() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -16047,40 +17427,30 @@ def test_list_previews_rest_required_fields(request_type=config.ListPreviewsRequ response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ListPreviewsResponse.pb(return_value) + return_value = config.Revision.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_previews(request) + response = client.get_revision(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_previews_rest_unset_required_fields(): +def test_get_revision_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_previews._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "orderBy", - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.get_revision._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -def test_list_previews_rest_flattened(): +def test_get_revision_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -16089,14 +17459,16 @@ def test_list_previews_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListPreviewsResponse() + return_value = config.Revision() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + sample_request = { + "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" + } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", + name="name_value", ) mock_args.update(sample_request) @@ -16104,25 +17476,26 @@ def test_list_previews_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ListPreviewsResponse.pb(return_value) + return_value = config.Revision.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_previews(**mock_args) + client.get_revision(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/previews" % client.transport._host, + "%s/v1/{name=projects/*/locations/*/deployments/*/revisions/*}" + % client.transport._host, args[1], ) -def test_list_previews_rest_flattened_error(transport: str = "rest"): +def test_get_revision_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -16131,74 +17504,13 @@ def test_list_previews_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_previews( - config.ListPreviewsRequest(), - parent="parent_value", - ) - - -def test_list_previews_rest_pager(transport: str = "rest"): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - config.ListPreviewsResponse( - previews=[ - config.Preview(), - config.Preview(), - config.Preview(), - ], - next_page_token="abc", - ), - config.ListPreviewsResponse( - previews=[], - next_page_token="def", - ), - config.ListPreviewsResponse( - previews=[ - config.Preview(), - ], - next_page_token="ghi", - ), - config.ListPreviewsResponse( - previews=[ - config.Preview(), - config.Preview(), - ], - ), + client.get_revision( + config.GetRevisionRequest(), + name="name_value", ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(config.ListPreviewsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "projects/sample1/locations/sample2"} - - pager = client.list_previews(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, config.Preview) for i in results) - - pages = list(client.list_previews(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token -def test_delete_preview_rest_use_cached_wrapped_rpc(): +def test_get_resource_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -16212,33 +17524,29 @@ def test_delete_preview_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_preview in client._transport._wrapped_methods + assert client._transport.get_resource in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_preview] = mock_rpc + client._transport._wrapped_methods[client._transport.get_resource] = mock_rpc request = {} - client.delete_preview(request) + client.get_resource(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_preview(request) + client.get_resource(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_preview_rest_required_fields(request_type=config.DeletePreviewRequest): +def test_get_resource_rest_required_fields(request_type=config.GetResourceRequest): transport_class = transports.ConfigRestTransport request_init = {} @@ -16253,7 +17561,7 @@ def test_delete_preview_rest_required_fields(request_type=config.DeletePreviewRe unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_preview._get_unset_required_fields(jsonified_request) + ).get_resource._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -16262,9 +17570,7 @@ def test_delete_preview_rest_required_fields(request_type=config.DeletePreviewRe unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_preview._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("request_id",)) + ).get_resource._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -16278,7 +17584,7 @@ def test_delete_preview_rest_required_fields(request_type=config.DeletePreviewRe request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.Resource() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -16290,36 +17596,39 @@ def test_delete_preview_rest_required_fields(request_type=config.DeletePreviewRe pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "get", "query_params": pb_request, } transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.Resource.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_preview(request) + response = client.get_resource(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_preview_rest_unset_required_fields(): +def test_get_resource_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_preview._get_unset_required_fields({}) - assert set(unset_fields) == (set(("requestId",)) & set(("name",))) + unset_fields = transport.get_resource._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -def test_delete_preview_rest_flattened(): +def test_get_resource_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -16328,10 +17637,12 @@ def test_delete_preview_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.Resource() # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/locations/sample2/previews/sample3"} + sample_request = { + "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4/resources/sample5" + } # get truthy value for each flattened field mock_args = dict( @@ -16342,24 +17653,27 @@ def test_delete_preview_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.Resource.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_preview(**mock_args) + client.get_resource(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/previews/*}" % client.transport._host, + "%s/v1/{name=projects/*/locations/*/deployments/*/revisions/*/resources/*}" + % client.transport._host, args[1], ) -def test_delete_preview_rest_flattened_error(transport: str = "rest"): +def test_get_resource_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -16368,139 +17682,13 @@ def test_delete_preview_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_preview( - config.DeletePreviewRequest(), + client.get_resource( + config.GetResourceRequest(), name="name_value", ) -def test_export_preview_result_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.export_preview_result - in client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.export_preview_result] = ( - mock_rpc - ) - - request = {} - client.export_preview_result(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.export_preview_result(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_export_preview_result_rest_required_fields( - request_type=config.ExportPreviewResultRequest, -): - transport_class = transports.ConfigRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_preview_result._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).export_preview_result._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = config.ExportPreviewResultResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ExportPreviewResultResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.export_preview_result(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_export_preview_result_rest_unset_required_fields(): - transport = transports.ConfigRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.export_preview_result._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent",))) - - -def test_list_terraform_versions_rest_use_cached_wrapped_rpc(): +def test_list_resources_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -16514,36 +17702,29 @@ def test_list_terraform_versions_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.list_terraform_versions - in client._transport._wrapped_methods - ) + assert client._transport.list_resources in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.list_terraform_versions - ] = mock_rpc + client._transport._wrapped_methods[client._transport.list_resources] = mock_rpc request = {} - client.list_terraform_versions(request) + client.list_resources(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_terraform_versions(request) + client.list_resources(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_terraform_versions_rest_required_fields( - request_type=config.ListTerraformVersionsRequest, -): +def test_list_resources_rest_required_fields(request_type=config.ListResourcesRequest): transport_class = transports.ConfigRestTransport request_init = {} @@ -16558,7 +17739,7 @@ def test_list_terraform_versions_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_terraform_versions._get_unset_required_fields(jsonified_request) + ).list_resources._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -16567,7 +17748,7 @@ def test_list_terraform_versions_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_terraform_versions._get_unset_required_fields(jsonified_request) + ).list_resources._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set( ( @@ -16590,7 +17771,7 @@ def test_list_terraform_versions_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.ListTerraformVersionsResponse() + return_value = config.ListResourcesResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -16611,26 +17792,26 @@ def test_list_terraform_versions_rest_required_fields( response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ListTerraformVersionsResponse.pb(return_value) + return_value = config.ListResourcesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_terraform_versions(request) + response = client.list_resources(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_terraform_versions_rest_unset_required_fields(): +def test_list_resources_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_terraform_versions._get_unset_required_fields({}) + unset_fields = transport.list_resources._get_unset_required_fields({}) assert set(unset_fields) == ( set( ( @@ -16644,7 +17825,7 @@ def test_list_terraform_versions_rest_unset_required_fields(): ) -def test_list_terraform_versions_rest_flattened(): +def test_list_resources_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -16653,10 +17834,12 @@ def test_list_terraform_versions_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListTerraformVersionsResponse() + return_value = config.ListResourcesResponse() # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + sample_request = { + "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" + } # get truthy value for each flattened field mock_args = dict( @@ -16668,26 +17851,26 @@ def test_list_terraform_versions_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ListTerraformVersionsResponse.pb(return_value) + return_value = config.ListResourcesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_terraform_versions(**mock_args) + client.list_resources(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/terraformVersions" + "%s/v1/{parent=projects/*/locations/*/deployments/*/revisions/*}/resources" % client.transport._host, args[1], ) -def test_list_terraform_versions_rest_flattened_error(transport: str = "rest"): +def test_list_resources_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -16696,13 +17879,13 @@ def test_list_terraform_versions_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_terraform_versions( - config.ListTerraformVersionsRequest(), + client.list_resources( + config.ListResourcesRequest(), parent="parent_value", ) -def test_list_terraform_versions_rest_pager(transport: str = "rest"): +def test_list_resources_rest_pager(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -16714,28 +17897,28 @@ def test_list_terraform_versions_rest_pager(transport: str = "rest"): # with mock.patch.object(path_template, 'transcode') as transcode: # Set the response as a series of pages response = ( - config.ListTerraformVersionsResponse( - terraform_versions=[ - config.TerraformVersion(), - config.TerraformVersion(), - config.TerraformVersion(), + config.ListResourcesResponse( + resources=[ + config.Resource(), + config.Resource(), + config.Resource(), ], next_page_token="abc", ), - config.ListTerraformVersionsResponse( - terraform_versions=[], + config.ListResourcesResponse( + resources=[], next_page_token="def", ), - config.ListTerraformVersionsResponse( - terraform_versions=[ - config.TerraformVersion(), + config.ListResourcesResponse( + resources=[ + config.Resource(), ], next_page_token="ghi", ), - config.ListTerraformVersionsResponse( - terraform_versions=[ - config.TerraformVersion(), - config.TerraformVersion(), + config.ListResourcesResponse( + resources=[ + config.Resource(), + config.Resource(), ], ), ) @@ -16743,29 +17926,29 @@ def test_list_terraform_versions_rest_pager(transport: str = "rest"): response = response + response # Wrap the values into proper Response objs - response = tuple( - config.ListTerraformVersionsResponse.to_json(x) for x in response - ) + response = tuple(config.ListResourcesResponse.to_json(x) for x in response) return_values = tuple(Response() for i in response) for return_val, response_val in zip(return_values, response): return_val._content = response_val.encode("UTF-8") return_val.status_code = 200 req.side_effect = return_values - sample_request = {"parent": "projects/sample1/locations/sample2"} + sample_request = { + "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" + } - pager = client.list_terraform_versions(request=sample_request) + pager = client.list_resources(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, config.TerraformVersion) for i in results) + assert all(isinstance(i, config.Resource) for i in results) - pages = list(client.list_terraform_versions(request=sample_request).pages) + pages = list(client.list_resources(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_terraform_version_rest_use_cached_wrapped_rpc(): +def test_export_deployment_statefile_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -16780,7 +17963,7 @@ def test_get_terraform_version_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.get_terraform_version + client._transport.export_deployment_statefile in client._transport._wrapped_methods ) @@ -16789,30 +17972,30 @@ def test_get_terraform_version_rest_use_cached_wrapped_rpc(): mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_terraform_version] = ( - mock_rpc - ) + client._transport._wrapped_methods[ + client._transport.export_deployment_statefile + ] = mock_rpc request = {} - client.get_terraform_version(request) + client.export_deployment_statefile(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_terraform_version(request) + client.export_deployment_statefile(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_terraform_version_rest_required_fields( - request_type=config.GetTerraformVersionRequest, +def test_export_deployment_statefile_rest_required_fields( + request_type=config.ExportDeploymentStatefileRequest, ): transport_class = transports.ConfigRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -16823,21 +18006,21 @@ def test_get_terraform_version_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_terraform_version._get_unset_required_fields(jsonified_request) + ).export_deployment_statefile._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_terraform_version._get_unset_required_fields(jsonified_request) + ).export_deployment_statefile._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -16846,7 +18029,7 @@ def test_get_terraform_version_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.TerraformVersion() + return_value = config.Statefile() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -16858,99 +18041,166 @@ def test_get_terraform_version_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.TerraformVersion.pb(return_value) + return_value = config.Statefile.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_terraform_version(request) + response = client.export_deployment_statefile(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_terraform_version_rest_unset_required_fields(): +def test_export_deployment_statefile_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_terraform_version._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.export_deployment_statefile._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) -def test_get_terraform_version_rest_flattened(): +def test_export_revision_statefile_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.export_revision_statefile + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.export_revision_statefile + ] = mock_rpc + + request = {} + client.export_revision_statefile(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.export_revision_statefile(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_export_revision_statefile_rest_required_fields( + request_type=config.ExportRevisionStatefileRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_revision_statefile._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_revision_statefile._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) + request = request_type(**request_init) + # Designate an appropriate value for the returned response. + return_value = config.Statefile() # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = config.TerraformVersion() + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/terraformVersions/sample3" - } + response_value = Response() + response_value.status_code = 200 - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) + # Convert return value to protobuf type + return_value = config.Statefile.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.TerraformVersion.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_terraform_version(**mock_args) + response = client.export_revision_statefile(request) - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/terraformVersions/*}" - % client.transport._host, - args[1], - ) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params -def test_get_terraform_version_rest_flattened_error(transport: str = "rest"): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +def test_export_revision_statefile_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_terraform_version( - config.GetTerraformVersionRequest(), - name="name_value", - ) + unset_fields = transport.export_revision_statefile._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) -def test_list_resource_changes_rest_use_cached_wrapped_rpc(): +def test_import_statefile_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -16964,40 +18214,38 @@ def test_list_resource_changes_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.list_resource_changes - in client._transport._wrapped_methods - ) + assert client._transport.import_statefile in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_resource_changes] = ( + client._transport._wrapped_methods[client._transport.import_statefile] = ( mock_rpc ) request = {} - client.list_resource_changes(request) + client.import_statefile(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_resource_changes(request) + client.import_statefile(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_resource_changes_rest_required_fields( - request_type=config.ListResourceChangesRequest, +def test_import_statefile_rest_required_fields( + request_type=config.ImportStatefileRequest, ): transport_class = transports.ConfigRestTransport request_init = {} request_init["parent"] = "" + request_init["lock_id"] = 0 request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -17008,30 +18256,24 @@ def test_list_resource_changes_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_resource_changes._get_unset_required_fields(jsonified_request) + ).import_statefile._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present jsonified_request["parent"] = "parent_value" + jsonified_request["lockId"] = 725 unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_resource_changes._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "order_by", - "page_size", - "page_token", - ) - ) + ).import_statefile._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone assert "parent" in jsonified_request assert jsonified_request["parent"] == "parent_value" + assert "lockId" in jsonified_request + assert jsonified_request["lockId"] == 725 client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -17040,7 +18282,7 @@ def test_list_resource_changes_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.ListResourceChangesResponse() + return_value = config.Statefile() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -17052,49 +18294,48 @@ def test_list_resource_changes_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ListResourceChangesResponse.pb(return_value) + return_value = config.Statefile.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_resource_changes(request) + response = client.import_statefile(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_resource_changes_rest_unset_required_fields(): +def test_import_statefile_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_resource_changes._get_unset_required_fields({}) + unset_fields = transport.import_statefile._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(()) + & set( ( - "filter", - "orderBy", - "pageSize", - "pageToken", + "parent", + "lockId", ) ) - & set(("parent",)) ) -def test_list_resource_changes_rest_flattened(): +def test_import_statefile_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -17103,16 +18344,17 @@ def test_list_resource_changes_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListResourceChangesResponse() + return_value = config.Statefile() # get arguments that satisfy an http rule for this method sample_request = { - "parent": "projects/sample1/locations/sample2/previews/sample3" + "parent": "projects/sample1/locations/sample2/deployments/sample3" } # get truthy value for each flattened field mock_args = dict( parent="parent_value", + lock_id=725, ) mock_args.update(sample_request) @@ -17120,26 +18362,26 @@ def test_list_resource_changes_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ListResourceChangesResponse.pb(return_value) + return_value = config.Statefile.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_resource_changes(**mock_args) + client.import_statefile(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/previews/*}/resourceChanges" + "%s/v1/{parent=projects/*/locations/*/deployments/*}:importState" % client.transport._host, args[1], ) -def test_list_resource_changes_rest_flattened_error(transport: str = "rest"): +def test_import_statefile_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -17148,78 +18390,14 @@ def test_list_resource_changes_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_resource_changes( - config.ListResourceChangesRequest(), + client.import_statefile( + config.ImportStatefileRequest(), parent="parent_value", + lock_id=725, ) -def test_list_resource_changes_rest_pager(transport: str = "rest"): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - config.ListResourceChangesResponse( - resource_changes=[ - config.ResourceChange(), - config.ResourceChange(), - config.ResourceChange(), - ], - next_page_token="abc", - ), - config.ListResourceChangesResponse( - resource_changes=[], - next_page_token="def", - ), - config.ListResourceChangesResponse( - resource_changes=[ - config.ResourceChange(), - ], - next_page_token="ghi", - ), - config.ListResourceChangesResponse( - resource_changes=[ - config.ResourceChange(), - config.ResourceChange(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple( - config.ListResourceChangesResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = { - "parent": "projects/sample1/locations/sample2/previews/sample3" - } - - pager = client.list_resource_changes(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, config.ResourceChange) for i in results) - - pages = list(client.list_resource_changes(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_get_resource_change_rest_use_cached_wrapped_rpc(): +def test_delete_statefile_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -17233,39 +18411,38 @@ def test_get_resource_change_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.get_resource_change in client._transport._wrapped_methods - ) + assert client._transport.delete_statefile in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_resource_change] = ( + client._transport._wrapped_methods[client._transport.delete_statefile] = ( mock_rpc ) request = {} - client.get_resource_change(request) + client.delete_statefile(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_resource_change(request) + client.delete_statefile(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_resource_change_rest_required_fields( - request_type=config.GetResourceChangeRequest, +def test_delete_statefile_rest_required_fields( + request_type=config.DeleteStatefileRequest, ): transport_class = transports.ConfigRestTransport request_init = {} request_init["name"] = "" + request_init["lock_id"] = 0 request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -17276,21 +18453,24 @@ def test_get_resource_change_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_resource_change._get_unset_required_fields(jsonified_request) + ).delete_statefile._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present jsonified_request["name"] = "name_value" + jsonified_request["lockId"] = 725 unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_resource_change._get_unset_required_fields(jsonified_request) + ).delete_statefile._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone assert "name" in jsonified_request assert jsonified_request["name"] == "name_value" + assert "lockId" in jsonified_request + assert jsonified_request["lockId"] == 725 client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -17299,7 +18479,7 @@ def test_get_resource_change_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.ResourceChange() + return_value = None # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -17311,39 +18491,45 @@ def test_get_resource_change_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ResourceChange.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_resource_change(request) + response = client.delete_statefile(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_resource_change_rest_unset_required_fields(): +def test_delete_statefile_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_resource_change._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.delete_statefile._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "name", + "lockId", + ) + ) + ) -def test_get_resource_change_rest_flattened(): +def test_delete_statefile_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -17352,11 +18538,11 @@ def test_get_resource_change_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ResourceChange() + return_value = None # get arguments that satisfy an http rule for this method sample_request = { - "name": "projects/sample1/locations/sample2/previews/sample3/resourceChanges/sample4" + "name": "projects/sample1/locations/sample2/deployments/sample3" } # get truthy value for each flattened field @@ -17368,27 +18554,25 @@ def test_get_resource_change_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.ResourceChange.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_resource_change(**mock_args) + client.delete_statefile(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/previews/*/resourceChanges/*}" + "%s/v1/{name=projects/*/locations/*/deployments/*}:deleteState" % client.transport._host, args[1], ) -def test_get_resource_change_rest_flattened_error(transport: str = "rest"): +def test_delete_statefile_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -17397,13 +18581,13 @@ def test_get_resource_change_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_resource_change( - config.GetResourceChangeRequest(), + client.delete_statefile( + config.DeleteStatefileRequest(), name="name_value", ) -def test_list_resource_drifts_rest_use_cached_wrapped_rpc(): +def test_lock_deployment_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -17417,39 +18601,39 @@ def test_list_resource_drifts_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.list_resource_drifts in client._transport._wrapped_methods - ) + assert client._transport.lock_deployment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_resource_drifts] = ( - mock_rpc - ) + client._transport._wrapped_methods[client._transport.lock_deployment] = mock_rpc request = {} - client.list_resource_drifts(request) + client.lock_deployment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_resource_drifts(request) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.lock_deployment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_resource_drifts_rest_required_fields( - request_type=config.ListResourceDriftsRequest, +def test_lock_deployment_rest_required_fields( + request_type=config.LockDeploymentRequest, ): transport_class = transports.ConfigRestTransport request_init = {} - request_init["parent"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -17460,30 +18644,21 @@ def test_list_resource_drifts_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_resource_drifts._get_unset_required_fields(jsonified_request) + ).lock_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["parent"] = "parent_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_resource_drifts._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "order_by", - "page_size", - "page_token", - ) - ) + ).lock_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -17492,7 +18667,7 @@ def test_list_resource_drifts_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.ListResourceDriftsResponse() + return_value = operations_pb2.Operation(name="operations/spam") # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -17504,49 +18679,37 @@ def test_list_resource_drifts_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ListResourceDriftsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_resource_drifts(request) + response = client.lock_deployment(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_resource_drifts_rest_unset_required_fields(): +def test_lock_deployment_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_resource_drifts._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "orderBy", - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + unset_fields = transport.lock_deployment._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -def test_list_resource_drifts_rest_flattened(): +def test_lock_deployment_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -17555,43 +18718,41 @@ def test_list_resource_drifts_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListResourceDriftsResponse() + return_value = operations_pb2.Operation(name="operations/spam") # get arguments that satisfy an http rule for this method sample_request = { - "parent": "projects/sample1/locations/sample2/previews/sample3" + "name": "projects/sample1/locations/sample2/deployments/sample3" } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.ListResourceDriftsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_resource_drifts(**mock_args) + client.lock_deployment(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/previews/*}/resourceDrifts" + "%s/v1/{name=projects/*/locations/*/deployments/*}:lock" % client.transport._host, args[1], ) -def test_list_resource_drifts_rest_flattened_error(transport: str = "rest"): +def test_lock_deployment_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -17600,122 +18761,62 @@ def test_list_resource_drifts_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_resource_drifts( - config.ListResourceDriftsRequest(), - parent="parent_value", + client.lock_deployment( + config.LockDeploymentRequest(), + name="name_value", ) -def test_list_resource_drifts_rest_pager(transport: str = "rest"): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - config.ListResourceDriftsResponse( - resource_drifts=[ - config.ResourceDrift(), - config.ResourceDrift(), - config.ResourceDrift(), - ], - next_page_token="abc", - ), - config.ListResourceDriftsResponse( - resource_drifts=[], - next_page_token="def", - ), - config.ListResourceDriftsResponse( - resource_drifts=[ - config.ResourceDrift(), - ], - next_page_token="ghi", - ), - config.ListResourceDriftsResponse( - resource_drifts=[ - config.ResourceDrift(), - config.ResourceDrift(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(config.ListResourceDriftsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = { - "parent": "projects/sample1/locations/sample2/previews/sample3" - } - - pager = client.list_resource_drifts(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, config.ResourceDrift) for i in results) - - pages = list(client.list_resource_drifts(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -def test_get_resource_drift_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +def test_unlock_deployment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) # Should wrap all calls on client creation assert wrapper_fn.call_count > 0 wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.get_resource_drift in client._transport._wrapped_methods - ) + assert client._transport.unlock_deployment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_resource_drift] = ( + client._transport._wrapped_methods[client._transport.unlock_deployment] = ( mock_rpc ) request = {} - client.get_resource_drift(request) + client.unlock_deployment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_resource_drift(request) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.unlock_deployment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_resource_drift_rest_required_fields( - request_type=config.GetResourceDriftRequest, +def test_unlock_deployment_rest_required_fields( + request_type=config.UnlockDeploymentRequest, ): transport_class = transports.ConfigRestTransport request_init = {} request_init["name"] = "" + request_init["lock_id"] = 0 request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -17726,21 +18827,24 @@ def test_get_resource_drift_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_resource_drift._get_unset_required_fields(jsonified_request) + ).unlock_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present jsonified_request["name"] = "name_value" + jsonified_request["lockId"] = 725 unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_resource_drift._get_unset_required_fields(jsonified_request) + ).unlock_deployment._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone assert "name" in jsonified_request assert jsonified_request["name"] == "name_value" + assert "lockId" in jsonified_request + assert jsonified_request["lockId"] == 725 client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -17749,7 +18853,7 @@ def test_get_resource_drift_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.ResourceDrift() + return_value = operations_pb2.Operation(name="operations/spam") # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -17761,39 +18865,45 @@ def test_get_resource_drift_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ResourceDrift.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_resource_drift(request) + response = client.unlock_deployment(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_resource_drift_rest_unset_required_fields(): +def test_unlock_deployment_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_resource_drift._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.unlock_deployment._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "name", + "lockId", + ) + ) + ) -def test_get_resource_drift_rest_flattened(): +def test_unlock_deployment_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -17802,43 +18912,42 @@ def test_get_resource_drift_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ResourceDrift() + return_value = operations_pb2.Operation(name="operations/spam") # get arguments that satisfy an http rule for this method sample_request = { - "name": "projects/sample1/locations/sample2/previews/sample3/resourceDrifts/sample4" + "name": "projects/sample1/locations/sample2/deployments/sample3" } # get truthy value for each flattened field mock_args = dict( name="name_value", + lock_id=725, ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = config.ResourceDrift.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_resource_drift(**mock_args) + client.unlock_deployment(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/previews/*/resourceDrifts/*}" + "%s/v1/{name=projects/*/locations/*/deployments/*}:unlock" % client.transport._host, args[1], ) -def test_get_resource_drift_rest_flattened_error(transport: str = "rest"): +def test_unlock_deployment_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -17847,13 +18956,14 @@ def test_get_resource_drift_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_resource_drift( - config.GetResourceDriftRequest(), + client.unlock_deployment( + config.UnlockDeploymentRequest(), name="name_value", + lock_id=725, ) -def test_get_auto_migration_config_rest_use_cached_wrapped_rpc(): +def test_export_lock_info_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -17867,35 +18977,32 @@ def test_get_auto_migration_config_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.get_auto_migration_config - in client._transport._wrapped_methods - ) + assert client._transport.export_lock_info in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.get_auto_migration_config - ] = mock_rpc + client._transport._wrapped_methods[client._transport.export_lock_info] = ( + mock_rpc + ) request = {} - client.get_auto_migration_config(request) + client.export_lock_info(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_auto_migration_config(request) + client.export_lock_info(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_auto_migration_config_rest_required_fields( - request_type=config.GetAutoMigrationConfigRequest, +def test_export_lock_info_rest_required_fields( + request_type=config.ExportLockInfoRequest, ): transport_class = transports.ConfigRestTransport @@ -17911,7 +19018,7 @@ def test_get_auto_migration_config_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_auto_migration_config._get_unset_required_fields(jsonified_request) + ).export_lock_info._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -17920,7 +19027,7 @@ def test_get_auto_migration_config_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_auto_migration_config._get_unset_required_fields(jsonified_request) + ).export_lock_info._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -17934,7 +19041,7 @@ def test_get_auto_migration_config_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = config.AutoMigrationConfig() + return_value = config.LockInfo() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -17955,30 +19062,30 @@ def test_get_auto_migration_config_rest_required_fields( response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.AutoMigrationConfig.pb(return_value) + return_value = config.LockInfo.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_auto_migration_config(request) + response = client.export_lock_info(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_auto_migration_config_rest_unset_required_fields(): +def test_export_lock_info_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_auto_migration_config._get_unset_required_fields({}) + unset_fields = transport.export_lock_info._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) -def test_get_auto_migration_config_rest_flattened(): +def test_export_lock_info_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -17987,11 +19094,11 @@ def test_get_auto_migration_config_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.AutoMigrationConfig() + return_value = config.LockInfo() # get arguments that satisfy an http rule for this method sample_request = { - "name": "projects/sample1/locations/sample2/autoMigrationConfig" + "name": "projects/sample1/locations/sample2/deployments/sample3" } # get truthy value for each flattened field @@ -18004,26 +19111,26 @@ def test_get_auto_migration_config_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.AutoMigrationConfig.pb(return_value) + return_value = config.LockInfo.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_auto_migration_config(**mock_args) + client.export_lock_info(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/autoMigrationConfig}" + "%s/v1/{name=projects/*/locations/*/deployments/*}:exportLock" % client.transport._host, args[1], ) -def test_get_auto_migration_config_rest_flattened_error(transport: str = "rest"): +def test_export_lock_info_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -18032,13 +19139,13 @@ def test_get_auto_migration_config_rest_flattened_error(transport: str = "rest") # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_auto_migration_config( - config.GetAutoMigrationConfigRequest(), + client.export_lock_info( + config.ExportLockInfoRequest(), name="name_value", ) -def test_update_auto_migration_config_rest_use_cached_wrapped_rpc(): +def test_create_preview_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -18052,22 +19159,17 @@ def test_update_auto_migration_config_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.update_auto_migration_config - in client._transport._wrapped_methods - ) + assert client._transport.create_preview in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.update_auto_migration_config - ] = mock_rpc + client._transport._wrapped_methods[client._transport.create_preview] = mock_rpc request = {} - client.update_auto_migration_config(request) + client.create_preview(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -18076,19 +19178,18 @@ def test_update_auto_migration_config_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.update_auto_migration_config(request) + client.create_preview(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_auto_migration_config_rest_required_fields( - request_type=config.UpdateAutoMigrationConfigRequest, -): +def test_create_preview_rest_required_fields(request_type=config.CreatePreviewRequest): transport_class = transports.ConfigRestTransport request_init = {} + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -18099,19 +19200,28 @@ def test_update_auto_migration_config_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_auto_migration_config._get_unset_required_fields(jsonified_request) + ).create_preview._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_auto_migration_config._get_unset_required_fields(jsonified_request) + ).create_preview._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask",)) + assert not set(unset_fields) - set( + ( + "preview_id", + "request_id", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), @@ -18132,7 +19242,7 @@ def test_update_auto_migration_config_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "patch", + "method": "post", "query_params": pb_request, } transcode_result["body"] = pb_request @@ -18146,23 +19256,36 @@ def test_update_auto_migration_config_rest_required_fields( req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_auto_migration_config(request) + response = client.create_preview(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_auto_migration_config_rest_unset_required_fields(): +def test_create_preview_rest_unset_required_fields(): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_auto_migration_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask",)) & set(("autoMigrationConfig",))) + unset_fields = transport.create_preview._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "previewId", + "requestId", + ) + ) + & set( + ( + "parent", + "preview", + ) + ) + ) -def test_update_auto_migration_config_rest_flattened(): +def test_create_preview_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -18174,41 +19297,40 @@ def test_update_auto_migration_config_rest_flattened(): return_value = operations_pb2.Operation(name="operations/spam") # get arguments that satisfy an http rule for this method - sample_request = { - "auto_migration_config": { - "name": "projects/sample1/locations/sample2/autoMigrationConfig" - } - } + sample_request = {"parent": "projects/sample1/locations/sample2"} # get truthy value for each flattened field mock_args = dict( - auto_migration_config=config.AutoMigrationConfig(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() + parent="parent_value", + preview=config.Preview( + terraform_blueprint=config.TerraformBlueprint( + gcs_source="gcs_source_value" + ) + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() response_value.status_code = 200 json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_auto_migration_config(**mock_args) + client.create_preview(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{auto_migration_config.name=projects/*/locations/*/autoMigrationConfig}" - % client.transport._host, + "%s/v1/{parent=projects/*/locations/*}/previews" % client.transport._host, args[1], ) -def test_update_auto_migration_config_rest_flattened_error(transport: str = "rest"): +def test_create_preview_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -18217,1633 +19339,7633 @@ def test_update_auto_migration_config_rest_flattened_error(transport: str = "res # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_auto_migration_config( - config.UpdateAutoMigrationConfigRequest(), - auto_migration_config=config.AutoMigrationConfig(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.create_preview( + config.CreatePreviewRequest(), + parent="parent_value", + preview=config.Preview( + terraform_blueprint=config.TerraformBlueprint( + gcs_source="gcs_source_value" + ) + ), ) -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.ConfigGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): +def test_get_preview_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.ConfigGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ConfigClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, + transport="rest", ) - # It is an error to provide an api_key and a transport instance. - transport = transports.ConfigGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ConfigClient( - client_options=options, - transport=transport, - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ConfigClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) + # Ensure method has been cached + assert client._transport.get_preview in client._transport._wrapped_methods - # It is an error to provide scopes and a transport instance. - transport = transports.ConfigGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ConfigClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) + client._transport._wrapped_methods[client._transport.get_preview] = mock_rpc + request = {} + client.get_preview(request) -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.ConfigGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = ConfigClient(transport=transport) - assert client.transport is transport + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.get_preview(request) -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.ConfigGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - transport = transports.ConfigGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel +def test_get_preview_rest_required_fields(request_type=config.GetPreviewRequest): + transport_class = transports.ConfigRestTransport -@pytest.mark.parametrize( - "transport_class", - [ - transports.ConfigGrpcTransport, - transports.ConfigGrpcAsyncIOTransport, - transports.ConfigRestTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped -def test_transport_kind_grpc(): - transport = ConfigClient.get_transport_class("grpc")( + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" + ).get_preview._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with default values are now present -def test_initialize_client_w_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc" - ) - assert client is not None + jsonified_request["name"] = "name_value" + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_preview._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_deployments_empty_call_grpc(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_deployments), "__call__") as call: - call.return_value = config.ListDeploymentsResponse() - client.list_deployments(request=None) + # Designate an appropriate value for the returned response. + return_value = config.Preview() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListDeploymentsRequest() + response_value = Response() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = config.Preview.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_deployment_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + response = client.get_preview(request) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_deployment), "__call__") as call: - call.return_value = config.Deployment() - client.get_deployment(request=None) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetDeploymentRequest() - assert args[0] == request_msg +def test_get_preview_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + unset_fields = transport.get_preview._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_deployment_empty_call_grpc(): + +def test_get_preview_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_deployment), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_deployment(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.Preview() - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.CreateDeploymentRequest() + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/previews/sample3"} - assert args[0] == request_msg + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.Preview.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_deployment_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_deployment), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_deployment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.UpdateDeploymentRequest() + client.get_preview(**mock_args) - assert args[0] == request_msg + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/previews/*}" % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_deployment_empty_call_grpc(): +def test_get_preview_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_deployment), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_deployment(request=None) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_preview( + config.GetPreviewRequest(), + name="name_value", + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.DeleteDeploymentRequest() - assert args[0] == request_msg +def test_list_previews_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_revisions_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert client._transport.list_previews in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_revisions), "__call__") as call: - call.return_value = config.ListRevisionsResponse() - client.list_revisions(request=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_previews] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListRevisionsRequest() + request = {} + client.list_previews(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.list_previews(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_revision_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_revision), "__call__") as call: - call.return_value = config.Revision() - client.get_revision(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetRevisionRequest() +def test_list_previews_rest_required_fields(request_type=config.ListPreviewsRequest): + transport_class = transports.ConfigRestTransport - assert args[0] == request_msg + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_resource_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_previews._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_resource), "__call__") as call: - call.return_value = config.Resource() - client.get_resource(request=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceRequest() + jsonified_request["parent"] = "parent_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_previews._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_resources_empty_call_grpc(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_resources), "__call__") as call: - call.return_value = config.ListResourcesResponse() - client.list_resources(request=None) + # Designate an appropriate value for the returned response. + return_value = config.ListPreviewsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListResourcesRequest() + response_value = Response() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = config.ListPreviewsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_export_deployment_statefile_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + response = client.list_previews(request) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_deployment_statefile), "__call__" - ) as call: - call.return_value = config.Statefile() - client.export_deployment_statefile(request=None) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ExportDeploymentStatefileRequest() - assert args[0] == request_msg +def test_list_previews_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_previews._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_export_revision_statefile_empty_call_grpc(): +def test_list_previews_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_revision_statefile), "__call__" - ) as call: - call.return_value = config.Statefile() - client.export_revision_statefile(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ListPreviewsResponse() - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ExportRevisionStatefileRequest() + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} - assert args[0] == request_msg + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.ListPreviewsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_import_statefile_empty_call_grpc(): + client.list_previews(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/previews" % client.transport._host, + args[1], + ) + + +def test_list_previews_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.import_statefile), "__call__") as call: - call.return_value = config.Statefile() - client.import_statefile(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ImportStatefileRequest() - - assert args[0] == request_msg + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_previews( + config.ListPreviewsRequest(), + parent="parent_value", + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_statefile_empty_call_grpc(): +def test_list_previews_rest_pager(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_statefile), "__call__") as call: - call.return_value = None - client.delete_statefile(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.DeleteStatefileRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + config.ListPreviewsResponse( + previews=[ + config.Preview(), + config.Preview(), + config.Preview(), + ], + next_page_token="abc", + ), + config.ListPreviewsResponse( + previews=[], + next_page_token="def", + ), + config.ListPreviewsResponse( + previews=[ + config.Preview(), + ], + next_page_token="ghi", + ), + config.ListPreviewsResponse( + previews=[ + config.Preview(), + config.Preview(), + ], + ), + ) + # Two responses for two calls + response = response + response - assert args[0] == request_msg + # Wrap the values into proper Response objs + response = tuple(config.ListPreviewsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + sample_request = {"parent": "projects/sample1/locations/sample2"} -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_lock_deployment_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + pager = client.list_previews(request=sample_request) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.lock_deployment), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.lock_deployment(request=None) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.Preview) for i in results) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.LockDeploymentRequest() + pages = list(client.list_previews(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - assert args[0] == request_msg +def test_delete_preview_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_unlock_deployment_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.unlock_deployment), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.unlock_deployment(request=None) + # Ensure method has been cached + assert client._transport.delete_preview in client._transport._wrapped_methods - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.UnlockDeploymentRequest() + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_preview] = mock_rpc - assert args[0] == request_msg + request = {} + client.delete_preview(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_export_lock_info_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.export_lock_info), "__call__") as call: - call.return_value = config.LockInfo() - client.export_lock_info(request=None) + client.delete_preview(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ExportLockInfoRequest() + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - assert args[0] == request_msg +def test_delete_preview_rest_required_fields(request_type=config.DeletePreviewRequest): + transport_class = transports.ConfigRestTransport -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_preview_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_preview), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_preview(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.CreatePreviewRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_preview._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_preview._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_preview_empty_call_grpc(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_preview), "__call__") as call: - call.return_value = config.Preview() - client.get_preview(request=None) + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetPreviewRequest() + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) - assert args[0] == request_msg + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_preview(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_previews_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_previews), "__call__") as call: - call.return_value = config.ListPreviewsResponse() - client.list_previews(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListPreviewsRequest() +def test_delete_preview_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) - assert args[0] == request_msg + unset_fields = transport.delete_preview._get_unset_required_fields({}) + assert set(unset_fields) == (set(("requestId",)) & set(("name",))) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_preview_empty_call_grpc(): +def test_delete_preview_rest_flattened(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_preview), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_preview(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.DeletePreviewRequest() + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/previews/sample3"} - assert args[0] == request_msg + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_preview(**mock_args) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_export_preview_result_empty_call_grpc(): + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/previews/*}" % client.transport._host, + args[1], + ) + + +def test_delete_preview_rest_flattened_error(transport: str = "rest"): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_preview_result), "__call__" - ) as call: - call.return_value = config.ExportPreviewResultResponse() - client.export_preview_result(request=None) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_preview( + config.DeletePreviewRequest(), + name="name_value", + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ExportPreviewResultRequest() - assert args[0] == request_msg +def test_export_preview_result_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_terraform_versions_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert ( + client._transport.export_preview_result + in client._transport._wrapped_methods + ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_terraform_versions), "__call__" - ) as call: - call.return_value = config.ListTerraformVersionsResponse() - client.list_terraform_versions(request=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.export_preview_result] = ( + mock_rpc + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListTerraformVersionsRequest() + request = {} + client.export_preview_result(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.export_preview_result(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_terraform_version_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_terraform_version), "__call__" - ) as call: - call.return_value = config.TerraformVersion() - client.get_terraform_version(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetTerraformVersionRequest() +def test_export_preview_result_rest_required_fields( + request_type=config.ExportPreviewResultRequest, +): + transport_class = transports.ConfigRestTransport - assert args[0] == request_msg + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_resource_changes_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_preview_result._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_resource_changes), "__call__" - ) as call: - call.return_value = config.ListResourceChangesResponse() - client.list_resource_changes(request=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListResourceChangesRequest() + jsonified_request["parent"] = "parent_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_preview_result._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_resource_change_empty_call_grpc(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_resource_change), "__call__" - ) as call: - call.return_value = config.ResourceChange() - client.get_resource_change(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceChangeRequest() - - assert args[0] == request_msg + # Designate an appropriate value for the returned response. + return_value = config.ExportPreviewResultResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + response_value = Response() + response_value.status_code = 200 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_resource_drifts_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Convert return value to protobuf type + return_value = config.ExportPreviewResultResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_resource_drifts), "__call__" - ) as call: - call.return_value = config.ListResourceDriftsResponse() - client.list_resource_drifts(request=None) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListResourceDriftsRequest() + response = client.export_preview_result(request) - assert args[0] == request_msg + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_resource_drift_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", +def test_export_preview_result_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_resource_drift), "__call__" - ) as call: - call.return_value = config.ResourceDrift() - client.get_resource_drift(request=None) + unset_fields = transport.export_preview_result._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent",))) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceDriftRequest() - assert args[0] == request_msg +def test_list_terraform_versions_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_auto_migration_config_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert ( + client._transport.list_terraform_versions + in client._transport._wrapped_methods + ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_auto_migration_config), "__call__" - ) as call: - call.return_value = config.AutoMigrationConfig() - client.get_auto_migration_config(request=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_terraform_versions + ] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetAutoMigrationConfigRequest() + request = {} + client.list_terraform_versions(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.list_terraform_versions(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_auto_migration_config_empty_call_grpc(): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_terraform_versions_rest_required_fields( + request_type=config.ListTerraformVersionsRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_auto_migration_config), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_auto_migration_config(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.UpdateAutoMigrationConfigRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_terraform_versions._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" -def test_transport_kind_grpc_asyncio(): - transport = ConfigAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_terraform_versions._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) ) - assert transport.kind == "grpc_asyncio" + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" -def test_initialize_client_w_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), transport="grpc_asyncio" + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - assert client is not None + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.ListTerraformVersionsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + response_value = Response() + response_value.status_code = 200 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_deployments_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Convert return value to protobuf type + return_value = config.ListTerraformVersionsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_deployments), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ListDeploymentsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - ) - await client.list_deployments(request=None) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListDeploymentsRequest() + response = client.list_terraform_versions(request) - assert args[0] == request_msg + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_deployment_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_terraform_versions_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_deployment), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.Deployment( - name="name_value", - state=config.Deployment.State.CREATING, - latest_revision="latest_revision_value", - state_detail="state_detail_value", - error_code=config.Deployment.ErrorCode.REVISION_FAILED, - delete_build="delete_build_value", - delete_logs="delete_logs_value", - error_logs="error_logs_value", - artifacts_gcs_bucket="artifacts_gcs_bucket_value", - service_account="service_account_value", - import_existing_resources=True, - worker_pool="worker_pool_value", - lock_state=config.Deployment.LockState.LOCKED, - tf_version_constraint="tf_version_constraint_value", - tf_version="tf_version_value", - quota_validation=config.QuotaValidation.ENABLED, + unset_fields = transport.list_terraform_versions._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", ) ) - await client.get_deployment(request=None) + & set(("parent",)) + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetDeploymentRequest() - assert args[0] == request_msg +def test_list_terraform_versions_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ListTerraformVersionsResponse() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_deployment_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_deployment), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", ) - await client.create_deployment(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.CreateDeploymentRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.ListTerraformVersionsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - assert args[0] == request_msg + client.list_terraform_versions(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/terraformVersions" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_deployment_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_terraform_versions_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_deployment), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_terraform_versions( + config.ListTerraformVersionsRequest(), + parent="parent_value", ) - await client.update_deployment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.UpdateDeploymentRequest() - - assert args[0] == request_msg -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_deployment_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_terraform_versions_rest_pager(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_deployment), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + config.ListTerraformVersionsResponse( + terraform_versions=[ + config.TerraformVersion(), + config.TerraformVersion(), + config.TerraformVersion(), + ], + next_page_token="abc", + ), + config.ListTerraformVersionsResponse( + terraform_versions=[], + next_page_token="def", + ), + config.ListTerraformVersionsResponse( + terraform_versions=[ + config.TerraformVersion(), + ], + next_page_token="ghi", + ), + config.ListTerraformVersionsResponse( + terraform_versions=[ + config.TerraformVersion(), + config.TerraformVersion(), + ], + ), ) - await client.delete_deployment(request=None) + # Two responses for two calls + response = response + response - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.DeleteDeploymentRequest() + # Wrap the values into proper Response objs + response = tuple( + config.ListTerraformVersionsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values - assert args[0] == request_msg + sample_request = {"parent": "projects/sample1/locations/sample2"} + pager = client.list_terraform_versions(request=sample_request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_revisions_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.TerraformVersion) for i in results) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_revisions), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ListRevisionsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + pages = list(client.list_terraform_versions(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_terraform_version_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - await client.list_revisions(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListRevisionsRequest() + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - assert args[0] == request_msg + # Ensure method has been cached + assert ( + client._transport.get_terraform_version + in client._transport._wrapped_methods + ) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_terraform_version] = ( + mock_rpc + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_revision_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + request = {} + client.get_terraform_version(request) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_revision), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.Revision( - name="name_value", - action=config.Revision.Action.CREATE, - state=config.Revision.State.APPLYING, - state_detail="state_detail_value", - error_code=config.Revision.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED, - build="build_value", - logs="logs_value", - error_logs="error_logs_value", - service_account="service_account_value", - import_existing_resources=True, - worker_pool="worker_pool_value", - tf_version_constraint="tf_version_constraint_value", - tf_version="tf_version_value", - quota_validation_results="quota_validation_results_value", - quota_validation=config.QuotaValidation.ENABLED, - ) - ) - await client.get_revision(request=None) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetRevisionRequest() + client.get_terraform_version(request) - assert args[0] == request_msg + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_resource_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_terraform_version_rest_required_fields( + request_type=config.GetTerraformVersionRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_resource), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.Resource( - name="name_value", - intent=config.Resource.Intent.CREATE, - state=config.Resource.State.PLANNED, - ) - ) - await client.get_resource(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_terraform_version._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + jsonified_request["name"] = "name_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_resources_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_terraform_version._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_resources), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ListResourcesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - ) - await client.list_resources(request=None) + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListResourcesRequest() + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) - assert args[0] == request_msg + # Designate an appropriate value for the returned response. + return_value = config.TerraformVersion() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + response_value = Response() + response_value.status_code = 200 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_export_deployment_statefile_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Convert return value to protobuf type + return_value = config.TerraformVersion.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_deployment_statefile), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.Statefile( - signed_uri="signed_uri_value", - ) - ) - await client.export_deployment_statefile(request=None) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ExportDeploymentStatefileRequest() + response = client.get_terraform_version(request) - assert args[0] == request_msg + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_export_revision_statefile_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_terraform_version_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_revision_statefile), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.Statefile( - signed_uri="signed_uri_value", - ) - ) - await client.export_revision_statefile(request=None) + unset_fields = transport.get_terraform_version._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ExportRevisionStatefileRequest() - assert args[0] == request_msg +def test_get_terraform_version_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.TerraformVersion() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_import_statefile_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/terraformVersions/sample3" + } - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.import_statefile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.Statefile( - signed_uri="signed_uri_value", - ) + # get truthy value for each flattened field + mock_args = dict( + name="name_value", ) - await client.import_statefile(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ImportStatefileRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.TerraformVersion.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - assert args[0] == request_msg + client.get_terraform_version(**mock_args) + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/terraformVersions/*}" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_statefile_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +def test_get_terraform_version_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_statefile), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_statefile(request=None) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_terraform_version( + config.GetTerraformVersionRequest(), + name="name_value", + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.DeleteStatefileRequest() - assert args[0] == request_msg +def test_list_resource_changes_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_lock_deployment_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert ( + client._transport.list_resource_changes + in client._transport._wrapped_methods + ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.lock_deployment), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_resource_changes] = ( + mock_rpc ) - await client.lock_deployment(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.LockDeploymentRequest() + request = {} + client.list_resource_changes(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.list_resource_changes(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_unlock_deployment_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_resource_changes_rest_required_fields( + request_type=config.ListResourceChangesRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.unlock_deployment), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.unlock_deployment(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.UnlockDeploymentRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_resource_changes._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_export_lock_info_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_resource_changes._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) ) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.export_lock_info), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.LockInfo( - lock_id=725, - operation="operation_value", - info="info_value", - who="who_value", - version="version_value", - ) - ) - await client.export_lock_info(request=None) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ExportLockInfoRequest() + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) - assert args[0] == request_msg + # Designate an appropriate value for the returned response. + return_value = config.ListResourceChangesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + response_value = Response() + response_value.status_code = 200 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_preview_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Convert return value to protobuf type + return_value = config.ListResourceChangesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_preview), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.create_preview(request=None) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.CreatePreviewRequest() + response = client.list_resource_changes(request) - assert args[0] == request_msg + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_preview_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_resource_changes_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_preview), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.Preview( - name="name_value", - state=config.Preview.State.CREATING, - deployment="deployment_value", - preview_mode=config.Preview.PreviewMode.DEFAULT, - service_account="service_account_value", - artifacts_gcs_bucket="artifacts_gcs_bucket_value", - worker_pool="worker_pool_value", - error_code=config.Preview.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED, - build="build_value", - error_logs="error_logs_value", - logs="logs_value", - tf_version="tf_version_value", - tf_version_constraint="tf_version_constraint_value", + unset_fields = transport.list_resource_changes._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", ) ) - await client.get_preview(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetPreviewRequest() - - assert args[0] == request_msg + & set(("parent",)) + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_previews_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_resource_changes_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_previews), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ListPreviewsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - ) - await client.list_previews(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ListResourceChangesResponse() - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListPreviewsRequest() + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/previews/sample3" + } - assert args[0] == request_msg + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.ListResourceChangesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_preview_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + client.list_resource_changes(**mock_args) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_preview), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/previews/*}/resourceChanges" + % client.transport._host, + args[1], ) - await client.delete_preview(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.DeletePreviewRequest() - - assert args[0] == request_msg -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_export_preview_result_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_resource_changes_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_preview_result), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ExportPreviewResultResponse() + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_resource_changes( + config.ListResourceChangesRequest(), + parent="parent_value", ) - await client.export_preview_result(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ExportPreviewResultRequest() - - assert args[0] == request_msg -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_terraform_versions_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_resource_changes_rest_pager(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_terraform_versions), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ListTerraformVersionsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + config.ListResourceChangesResponse( + resource_changes=[ + config.ResourceChange(), + config.ResourceChange(), + config.ResourceChange(), + ], + next_page_token="abc", + ), + config.ListResourceChangesResponse( + resource_changes=[], + next_page_token="def", + ), + config.ListResourceChangesResponse( + resource_changes=[ + config.ResourceChange(), + ], + next_page_token="ghi", + ), + config.ListResourceChangesResponse( + resource_changes=[ + config.ResourceChange(), + config.ResourceChange(), + ], + ), ) - await client.list_terraform_versions(request=None) + # Two responses for two calls + response = response + response - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListTerraformVersionsRequest() + # Wrap the values into proper Response objs + response = tuple( + config.ListResourceChangesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values - assert args[0] == request_msg + sample_request = { + "parent": "projects/sample1/locations/sample2/previews/sample3" + } + pager = client.list_resource_changes(request=sample_request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_terraform_version_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.ResourceChange) for i in results) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_terraform_version), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.TerraformVersion( - name="name_value", - state=config.TerraformVersion.State.ACTIVE, - ) - ) - await client.get_terraform_version(request=None) + pages = list(client.list_resource_changes(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetTerraformVersionRequest() - assert args[0] == request_msg +def test_get_resource_change_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_resource_changes_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert ( + client._transport.get_resource_change in client._transport._wrapped_methods + ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_resource_changes), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ListResourceChangesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_resource_change] = ( + mock_rpc ) - await client.list_resource_changes(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListResourceChangesRequest() + request = {} + client.get_resource_change(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.get_resource_change(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_resource_change_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_resource_change_rest_required_fields( + request_type=config.GetResourceChangeRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_resource_change._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_resource_change._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.ResourceChange() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ResourceChange.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_resource_change(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_resource_change_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_resource_change._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_resource_change_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ResourceChange() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/previews/sample3/resourceChanges/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.ResourceChange.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_resource_change(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/previews/*/resourceChanges/*}" + % client.transport._host, + args[1], + ) + + +def test_get_resource_change_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_resource_change( + config.GetResourceChangeRequest(), + name="name_value", + ) + + +def test_list_resource_drifts_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_resource_drifts in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_resource_drifts] = ( + mock_rpc + ) + + request = {} + client.list_resource_drifts(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_resource_drifts(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_resource_drifts_rest_required_fields( + request_type=config.ListResourceDriftsRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_resource_drifts._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_resource_drifts._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.ListResourceDriftsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ListResourceDriftsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_resource_drifts(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_resource_drifts_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_resource_drifts._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_resource_drifts_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ListResourceDriftsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/previews/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.ListResourceDriftsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_resource_drifts(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/previews/*}/resourceDrifts" + % client.transport._host, + args[1], + ) + + +def test_list_resource_drifts_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_resource_drifts( + config.ListResourceDriftsRequest(), + parent="parent_value", + ) + + +def test_list_resource_drifts_rest_pager(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + config.ListResourceDriftsResponse( + resource_drifts=[ + config.ResourceDrift(), + config.ResourceDrift(), + config.ResourceDrift(), + ], + next_page_token="abc", + ), + config.ListResourceDriftsResponse( + resource_drifts=[], + next_page_token="def", + ), + config.ListResourceDriftsResponse( + resource_drifts=[ + config.ResourceDrift(), + ], + next_page_token="ghi", + ), + config.ListResourceDriftsResponse( + resource_drifts=[ + config.ResourceDrift(), + config.ResourceDrift(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(config.ListResourceDriftsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/previews/sample3" + } + + pager = client.list_resource_drifts(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.ResourceDrift) for i in results) + + pages = list(client.list_resource_drifts(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_resource_drift_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_resource_drift in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_resource_drift] = ( + mock_rpc + ) + + request = {} + client.get_resource_drift(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_resource_drift(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_resource_drift_rest_required_fields( + request_type=config.GetResourceDriftRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_resource_drift._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_resource_drift._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.ResourceDrift() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ResourceDrift.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_resource_drift(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_resource_drift_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_resource_drift._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_resource_drift_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ResourceDrift() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/previews/sample3/resourceDrifts/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.ResourceDrift.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_resource_drift(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/previews/*/resourceDrifts/*}" + % client.transport._host, + args[1], + ) + + +def test_get_resource_drift_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_resource_drift( + config.GetResourceDriftRequest(), + name="name_value", + ) + + +def test_get_auto_migration_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_auto_migration_config + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_auto_migration_config + ] = mock_rpc + + request = {} + client.get_auto_migration_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_auto_migration_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_auto_migration_config_rest_required_fields( + request_type=config.GetAutoMigrationConfigRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_auto_migration_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_auto_migration_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.AutoMigrationConfig() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.AutoMigrationConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_auto_migration_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_auto_migration_config_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_auto_migration_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_auto_migration_config_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.AutoMigrationConfig() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/autoMigrationConfig" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.AutoMigrationConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_auto_migration_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/autoMigrationConfig}" + % client.transport._host, + args[1], + ) + + +def test_get_auto_migration_config_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_auto_migration_config( + config.GetAutoMigrationConfigRequest(), + name="name_value", + ) + + +def test_update_auto_migration_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_auto_migration_config + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_auto_migration_config + ] = mock_rpc + + request = {} + client.update_auto_migration_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_auto_migration_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_auto_migration_config_rest_required_fields( + request_type=config.UpdateAutoMigrationConfigRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_auto_migration_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_auto_migration_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_auto_migration_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_auto_migration_config_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_auto_migration_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("autoMigrationConfig",))) + + +def test_update_auto_migration_config_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "auto_migration_config": { + "name": "projects/sample1/locations/sample2/autoMigrationConfig" + } + } + + # get truthy value for each flattened field + mock_args = dict( + auto_migration_config=config.AutoMigrationConfig(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_auto_migration_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{auto_migration_config.name=projects/*/locations/*/autoMigrationConfig}" + % client.transport._host, + args[1], + ) + + +def test_update_auto_migration_config_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_auto_migration_config( + config.UpdateAutoMigrationConfigRequest(), + auto_migration_config=config.AutoMigrationConfig(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_get_deployment_group_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_deployment_group in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_deployment_group] = ( + mock_rpc + ) + + request = {} + client.get_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_deployment_group(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_deployment_group_rest_required_fields( + request_type=config.GetDeploymentGroupRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.DeploymentGroup() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.DeploymentGroup.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_deployment_group(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_deployment_group_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_deployment_group._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_deployment_group_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.DeploymentGroup() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.DeploymentGroup.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_deployment_group(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/deploymentGroups/*}" + % client.transport._host, + args[1], + ) + + +def test_get_deployment_group_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_deployment_group( + config.GetDeploymentGroupRequest(), + name="name_value", + ) + + +def test_create_deployment_group_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_deployment_group + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_deployment_group + ] = mock_rpc + + request = {} + client.create_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_deployment_group(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_deployment_group_rest_required_fields( + request_type=config.CreateDeploymentGroupRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["deployment_group_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "deploymentGroupId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "deploymentGroupId" in jsonified_request + assert jsonified_request["deploymentGroupId"] == request_init["deployment_group_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["deploymentGroupId"] = "deployment_group_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_deployment_group._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "deployment_group_id", + "request_id", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "deploymentGroupId" in jsonified_request + assert jsonified_request["deploymentGroupId"] == "deployment_group_id_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_deployment_group(request) + + expected_params = [ + ( + "deploymentGroupId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_deployment_group_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_deployment_group._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "deploymentGroupId", + "requestId", + ) + ) + & set( + ( + "parent", + "deploymentGroupId", + "deploymentGroup", + ) + ) + ) + + +def test_create_deployment_group_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + deployment_group=config.DeploymentGroup(name="name_value"), + deployment_group_id="deployment_group_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_deployment_group(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/deploymentGroups" + % client.transport._host, + args[1], + ) + + +def test_create_deployment_group_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_deployment_group( + config.CreateDeploymentGroupRequest(), + parent="parent_value", + deployment_group=config.DeploymentGroup(name="name_value"), + deployment_group_id="deployment_group_id_value", + ) + + +def test_update_deployment_group_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_deployment_group + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_deployment_group + ] = mock_rpc + + request = {} + client.update_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_deployment_group(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_deployment_group_rest_required_fields( + request_type=config.UpdateDeploymentGroupRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_deployment_group._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "request_id", + "update_mask", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_deployment_group(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_deployment_group_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_deployment_group._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "requestId", + "updateMask", + ) + ) + & set(("deploymentGroup",)) + ) + + +def test_update_deployment_group_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "deployment_group": { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + deployment_group=config.DeploymentGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_deployment_group(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{deployment_group.name=projects/*/locations/*/deploymentGroups/*}" + % client.transport._host, + args[1], + ) + + +def test_update_deployment_group_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_deployment_group( + config.UpdateDeploymentGroupRequest(), + deployment_group=config.DeploymentGroup(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_deployment_group_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_deployment_group + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_deployment_group + ] = mock_rpc + + request = {} + client.delete_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_deployment_group(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_deployment_group_rest_required_fields( + request_type=config.DeleteDeploymentGroupRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_deployment_group._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "deployment_reference_policy", + "force", + "request_id", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_deployment_group(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_deployment_group_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_deployment_group._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "deploymentReferencePolicy", + "force", + "requestId", + ) + ) + & set(("name",)) + ) + + +def test_delete_deployment_group_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_deployment_group(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/deploymentGroups/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_deployment_group_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_deployment_group( + config.DeleteDeploymentGroupRequest(), + name="name_value", + ) + + +def test_list_deployment_groups_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_deployment_groups + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_deployment_groups] = ( + mock_rpc + ) + + request = {} + client.list_deployment_groups(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_deployment_groups(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_deployment_groups_rest_required_fields( + request_type=config.ListDeploymentGroupsRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_deployment_groups._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_deployment_groups._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.ListDeploymentGroupsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ListDeploymentGroupsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_deployment_groups(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_deployment_groups_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_deployment_groups._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_deployment_groups_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ListDeploymentGroupsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.ListDeploymentGroupsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_deployment_groups(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/deploymentGroups" + % client.transport._host, + args[1], + ) + + +def test_list_deployment_groups_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_deployment_groups( + config.ListDeploymentGroupsRequest(), + parent="parent_value", + ) + + +def test_list_deployment_groups_rest_pager(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + config.DeploymentGroup(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[], + next_page_token="def", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupsResponse( + deployment_groups=[ + config.DeploymentGroup(), + config.DeploymentGroup(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + config.ListDeploymentGroupsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_deployment_groups(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.DeploymentGroup) for i in results) + + pages = list(client.list_deployment_groups(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_provision_deployment_group_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.provision_deployment_group + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.provision_deployment_group + ] = mock_rpc + + request = {} + client.provision_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.provision_deployment_group(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_provision_deployment_group_rest_required_fields( + request_type=config.ProvisionDeploymentGroupRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).provision_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).provision_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.provision_deployment_group(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_provision_deployment_group_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.provision_deployment_group._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_provision_deployment_group_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.provision_deployment_group(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/deploymentGroups/*}:provision" + % client.transport._host, + args[1], + ) + + +def test_provision_deployment_group_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.provision_deployment_group( + config.ProvisionDeploymentGroupRequest(), + name="name_value", + ) + + +def test_deprovision_deployment_group_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.deprovision_deployment_group + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.deprovision_deployment_group + ] = mock_rpc + + request = {} + client.deprovision_deployment_group(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.deprovision_deployment_group(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_deprovision_deployment_group_rest_required_fields( + request_type=config.DeprovisionDeploymentGroupRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).deprovision_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).deprovision_deployment_group._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.deprovision_deployment_group(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_deprovision_deployment_group_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.deprovision_deployment_group._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_deprovision_deployment_group_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.deprovision_deployment_group(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/deploymentGroups/*}:deprovision" + % client.transport._host, + args[1], + ) + + +def test_deprovision_deployment_group_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.deprovision_deployment_group( + config.DeprovisionDeploymentGroupRequest(), + name="name_value", + ) + + +def test_get_deployment_group_revision_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_deployment_group_revision + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_deployment_group_revision + ] = mock_rpc + + request = {} + client.get_deployment_group_revision(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_deployment_group_revision(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_deployment_group_revision_rest_required_fields( + request_type=config.GetDeploymentGroupRevisionRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_deployment_group_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_deployment_group_revision._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.DeploymentGroupRevision() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.DeploymentGroupRevision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_deployment_group_revision(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_deployment_group_revision_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_deployment_group_revision._get_unset_required_fields( + {} + ) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_deployment_group_revision_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.DeploymentGroupRevision() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3/revisions/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.DeploymentGroupRevision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_deployment_group_revision(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/deploymentGroups/*/revisions/*}" + % client.transport._host, + args[1], + ) + + +def test_get_deployment_group_revision_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_deployment_group_revision( + config.GetDeploymentGroupRevisionRequest(), + name="name_value", + ) + + +def test_list_deployment_group_revisions_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_deployment_group_revisions + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_deployment_group_revisions + ] = mock_rpc + + request = {} + client.list_deployment_group_revisions(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_deployment_group_revisions(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_deployment_group_revisions_rest_required_fields( + request_type=config.ListDeploymentGroupRevisionsRequest, +): + transport_class = transports.ConfigRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_deployment_group_revisions._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_deployment_group_revisions._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = config.ListDeploymentGroupRevisionsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ListDeploymentGroupRevisionsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_deployment_group_revisions(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_deployment_group_revisions_rest_unset_required_fields(): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_deployment_group_revisions._get_unset_required_fields( + {} + ) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_deployment_group_revisions_rest_flattened(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ListDeploymentGroupRevisionsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = config.ListDeploymentGroupRevisionsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_deployment_group_revisions(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/deploymentGroups/*}/revisions" + % client.transport._host, + args[1], + ) + + +def test_list_deployment_group_revisions_rest_flattened_error(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_deployment_group_revisions( + config.ListDeploymentGroupRevisionsRequest(), + parent="parent_value", + ) + + +def test_list_deployment_group_revisions_rest_pager(transport: str = "rest"): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + next_page_token="abc", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[], + next_page_token="def", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + ], + next_page_token="ghi", + ), + config.ListDeploymentGroupRevisionsResponse( + deployment_group_revisions=[ + config.DeploymentGroupRevision(), + config.DeploymentGroupRevision(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + config.ListDeploymentGroupRevisionsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } + + pager = client.list_deployment_group_revisions(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, config.DeploymentGroupRevision) for i in results) + + pages = list( + client.list_deployment_group_revisions(request=sample_request).pages + ) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.ConfigGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.ConfigGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ConfigClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.ConfigGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ConfigClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ConfigClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.ConfigGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ConfigClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.ConfigGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = ConfigClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.ConfigGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.ConfigGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ConfigGrpcTransport, + transports.ConfigGrpcAsyncIOTransport, + transports.ConfigRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_kind_grpc(): + transport = ConfigClient.get_transport_class("grpc")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "grpc" + + +def test_initialize_client_w_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_deployments_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_deployments), "__call__") as call: + call.return_value = config.ListDeploymentsResponse() + client.list_deployments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListDeploymentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_deployment_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_deployment), "__call__") as call: + call.return_value = config.Deployment() + client.get_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_deployment_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.CreateDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_deployment_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UpdateDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_deployment_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeleteDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_revisions_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_revisions), "__call__") as call: + call.return_value = config.ListRevisionsResponse() + client.list_revisions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListRevisionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_revision_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_revision), "__call__") as call: + call.return_value = config.Revision() + client.get_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_resource_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_resource), "__call__") as call: + call.return_value = config.Resource() + client.get_resource(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetResourceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_resources_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_resources), "__call__") as call: + call.return_value = config.ListResourcesResponse() + client.list_resources(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListResourcesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_deployment_statefile_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_deployment_statefile), "__call__" + ) as call: + call.return_value = config.Statefile() + client.export_deployment_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportDeploymentStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_revision_statefile_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_revision_statefile), "__call__" + ) as call: + call.return_value = config.Statefile() + client.export_revision_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportRevisionStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_import_statefile_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.import_statefile), "__call__") as call: + call.return_value = config.Statefile() + client.import_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ImportStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_statefile_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_statefile), "__call__") as call: + call.return_value = None + client.delete_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeleteStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_lock_deployment_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.lock_deployment), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.lock_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.LockDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_unlock_deployment_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.unlock_deployment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.unlock_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UnlockDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_lock_info_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.export_lock_info), "__call__") as call: + call.return_value = config.LockInfo() + client.export_lock_info(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportLockInfoRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_preview_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_preview), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_preview(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.CreatePreviewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_preview_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_preview), "__call__") as call: + call.return_value = config.Preview() + client.get_preview(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetPreviewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_previews_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_previews), "__call__") as call: + call.return_value = config.ListPreviewsResponse() + client.list_previews(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListPreviewsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_preview_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_preview), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_preview(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeletePreviewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_preview_result_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_preview_result), "__call__" + ) as call: + call.return_value = config.ExportPreviewResultResponse() + client.export_preview_result(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportPreviewResultRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_terraform_versions_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_terraform_versions), "__call__" + ) as call: + call.return_value = config.ListTerraformVersionsResponse() + client.list_terraform_versions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListTerraformVersionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_terraform_version_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_terraform_version), "__call__" + ) as call: + call.return_value = config.TerraformVersion() + client.get_terraform_version(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetTerraformVersionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_resource_changes_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_resource_changes), "__call__" + ) as call: + call.return_value = config.ListResourceChangesResponse() + client.list_resource_changes(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListResourceChangesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_resource_change_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_resource_change), "__call__" + ) as call: + call.return_value = config.ResourceChange() + client.get_resource_change(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetResourceChangeRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_resource_drifts_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_resource_drifts), "__call__" + ) as call: + call.return_value = config.ListResourceDriftsResponse() + client.list_resource_drifts(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListResourceDriftsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_resource_drift_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_resource_drift), "__call__" + ) as call: + call.return_value = config.ResourceDrift() + client.get_resource_drift(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetResourceDriftRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_auto_migration_config_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_auto_migration_config), "__call__" + ) as call: + call.return_value = config.AutoMigrationConfig() + client.get_auto_migration_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetAutoMigrationConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_auto_migration_config_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_auto_migration_config), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_auto_migration_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UpdateAutoMigrationConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_deployment_group_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + call.return_value = config.DeploymentGroup() + client.get_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_deployment_group_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.CreateDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_deployment_group_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UpdateDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_deployment_group_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeleteDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_deployment_groups_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + call.return_value = config.ListDeploymentGroupsResponse() + client.list_deployment_groups(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListDeploymentGroupsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_provision_deployment_group_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.provision_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ProvisionDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_deprovision_deployment_group_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.deprovision_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeprovisionDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_deployment_group_revision_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + call.return_value = config.DeploymentGroupRevision() + client.get_deployment_group_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetDeploymentGroupRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_deployment_group_revisions_empty_call_grpc(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + call.return_value = config.ListDeploymentGroupRevisionsResponse() + client.list_deployment_group_revisions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListDeploymentGroupRevisionsRequest() + + assert args[0] == request_msg + + +def test_transport_kind_grpc_asyncio(): + transport = ConfigAsyncClient.get_transport_class("grpc_asyncio")( + credentials=async_anonymous_credentials() + ) + assert transport.kind == "grpc_asyncio" + + +def test_initialize_client_w_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), transport="grpc_asyncio" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_deployments_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_deployments), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_deployments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListDeploymentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_deployment_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_deployment), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.Deployment( + name="name_value", + state=config.Deployment.State.CREATING, + latest_revision="latest_revision_value", + state_detail="state_detail_value", + error_code=config.Deployment.ErrorCode.REVISION_FAILED, + delete_build="delete_build_value", + delete_logs="delete_logs_value", + error_logs="error_logs_value", + artifacts_gcs_bucket="artifacts_gcs_bucket_value", + service_account="service_account_value", + import_existing_resources=True, + worker_pool="worker_pool_value", + lock_state=config.Deployment.LockState.LOCKED, + tf_version_constraint="tf_version_constraint_value", + tf_version="tf_version_value", + quota_validation=config.QuotaValidation.ENABLED, + ) + ) + await client.get_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_deployment_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.CreateDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_deployment_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UpdateDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_deployment_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeleteDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_revisions_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_revisions), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListRevisionsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_revisions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListRevisionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_revision_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_revision), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.Revision( + name="name_value", + action=config.Revision.Action.CREATE, + state=config.Revision.State.APPLYING, + state_detail="state_detail_value", + error_code=config.Revision.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED, + build="build_value", + logs="logs_value", + error_logs="error_logs_value", + service_account="service_account_value", + import_existing_resources=True, + worker_pool="worker_pool_value", + tf_version_constraint="tf_version_constraint_value", + tf_version="tf_version_value", + quota_validation_results="quota_validation_results_value", + quota_validation=config.QuotaValidation.ENABLED, + ) + ) + await client.get_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_resource_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_resource), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.Resource( + name="name_value", + intent=config.Resource.Intent.CREATE, + state=config.Resource.State.PLANNED, + ) + ) + await client.get_resource(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetResourceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_resources_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_resources), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListResourcesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_resources(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListResourcesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_export_deployment_statefile_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_deployment_statefile), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.Statefile( + signed_uri="signed_uri_value", + ) + ) + await client.export_deployment_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportDeploymentStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_export_revision_statefile_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_revision_statefile), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.Statefile( + signed_uri="signed_uri_value", + ) + ) + await client.export_revision_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportRevisionStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_import_statefile_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.import_statefile), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.Statefile( + signed_uri="signed_uri_value", + ) + ) + await client.import_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ImportStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_statefile_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_statefile), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeleteStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_lock_deployment_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.lock_deployment), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.lock_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.LockDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_unlock_deployment_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.unlock_deployment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.unlock_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UnlockDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_export_lock_info_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.export_lock_info), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.LockInfo( + lock_id=725, + operation="operation_value", + info="info_value", + who="who_value", + version="version_value", + ) + ) + await client.export_lock_info(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportLockInfoRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_preview_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_preview), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_preview(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.CreatePreviewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_preview_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_preview), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.Preview( + name="name_value", + state=config.Preview.State.CREATING, + deployment="deployment_value", + preview_mode=config.Preview.PreviewMode.DEFAULT, + service_account="service_account_value", + artifacts_gcs_bucket="artifacts_gcs_bucket_value", + worker_pool="worker_pool_value", + error_code=config.Preview.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED, + build="build_value", + error_logs="error_logs_value", + logs="logs_value", + tf_version="tf_version_value", + tf_version_constraint="tf_version_constraint_value", + ) + ) + await client.get_preview(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetPreviewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_previews_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_previews), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListPreviewsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_previews(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListPreviewsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_preview_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_preview), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_preview(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeletePreviewRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_export_preview_result_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_preview_result), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ExportPreviewResultResponse() + ) + await client.export_preview_result(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportPreviewResultRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_terraform_versions_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_terraform_versions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListTerraformVersionsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_terraform_versions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListTerraformVersionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_terraform_version_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_terraform_version), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.TerraformVersion( + name="name_value", + state=config.TerraformVersion.State.ACTIVE, + ) + ) + await client.get_terraform_version(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetTerraformVersionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_resource_changes_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_resource_changes), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListResourceChangesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_resource_changes(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListResourceChangesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_resource_change_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_resource_change), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ResourceChange( + name="name_value", + intent=config.ResourceChange.Intent.CREATE, + ) + ) + await client.get_resource_change(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetResourceChangeRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_resource_drifts_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_resource_drifts), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListResourceDriftsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_resource_drifts(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListResourceDriftsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_resource_drift_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_resource_drift), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ResourceDrift( + name="name_value", + ) + ) + await client.get_resource_drift(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetResourceDriftRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_auto_migration_config_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_auto_migration_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.AutoMigrationConfig( + name="name_value", + auto_migration_enabled=True, + ) + ) + await client.get_auto_migration_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetAutoMigrationConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_auto_migration_config_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_auto_migration_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_auto_migration_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UpdateAutoMigrationConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_deployment_group_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.DeploymentGroup( + name="name_value", + state=config.DeploymentGroup.State.CREATING, + state_description="state_description_value", + provisioning_state=config.DeploymentGroup.ProvisioningState.PROVISIONING, + provisioning_state_description="provisioning_state_description_value", + ) + ) + await client.get_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_deployment_group_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.CreateDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_deployment_group_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UpdateDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_deployment_group_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeleteDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_deployment_groups_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_groups), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentGroupsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_deployment_groups(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListDeploymentGroupsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_provision_deployment_group_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.provision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.provision_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ProvisionDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_deprovision_deployment_group_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( credentials=async_anonymous_credentials(), transport="grpc_asyncio", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_resource_change), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ResourceChange( - name="name_value", - intent=config.ResourceChange.Intent.CREATE, - ) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.deprovision_deployment_group), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.deprovision_deployment_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeprovisionDeploymentGroupRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_deployment_group_revision_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_deployment_group_revision), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.DeploymentGroupRevision( + name="name_value", + alternative_ids=["alternative_ids_value"], + ) + ) + await client.get_deployment_group_revision(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.GetDeploymentGroupRevisionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_deployment_group_revisions_empty_call_grpc_asyncio(): + client = ConfigAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_deployment_group_revisions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + config.ListDeploymentGroupRevisionsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_deployment_group_revisions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListDeploymentGroupRevisionsRequest() + + assert args[0] == request_msg + + +def test_transport_kind_rest(): + transport = ConfigClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_list_deployments_rest_bad_request(request_type=config.ListDeploymentsRequest): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_deployments(request) + + +@pytest.mark.parametrize( + "request_type", + [ + config.ListDeploymentsRequest, + dict, + ], +) +def test_list_deployments_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ListDeploymentsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ListDeploymentsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_deployments(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDeploymentsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_deployments_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), + ) + client = ConfigClient(transport=transport) + + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object( + transports.ConfigRestInterceptor, "post_list_deployments" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_list_deployments_with_metadata" + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_list_deployments" + ) as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.ListDeploymentsRequest.pb(config.ListDeploymentsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = config.ListDeploymentsResponse.to_json( + config.ListDeploymentsResponse() + ) + req.return_value.content = return_value + + request = config.ListDeploymentsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = config.ListDeploymentsResponse() + post_with_metadata.return_value = config.ListDeploymentsResponse(), metadata + + client.list_deployments( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_deployment_rest_bad_request(request_type=config.GetDeploymentRequest): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_deployment(request) + + +@pytest.mark.parametrize( + "request_type", + [ + config.GetDeploymentRequest, + dict, + ], +) +def test_get_deployment_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.Deployment( + name="name_value", + state=config.Deployment.State.CREATING, + latest_revision="latest_revision_value", + state_detail="state_detail_value", + error_code=config.Deployment.ErrorCode.REVISION_FAILED, + delete_build="delete_build_value", + delete_logs="delete_logs_value", + error_logs="error_logs_value", + artifacts_gcs_bucket="artifacts_gcs_bucket_value", + service_account="service_account_value", + import_existing_resources=True, + worker_pool="worker_pool_value", + lock_state=config.Deployment.LockState.LOCKED, + tf_version_constraint="tf_version_constraint_value", + tf_version="tf_version_value", + quota_validation=config.QuotaValidation.ENABLED, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.Deployment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_deployment(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, config.Deployment) + assert response.name == "name_value" + assert response.state == config.Deployment.State.CREATING + assert response.latest_revision == "latest_revision_value" + assert response.state_detail == "state_detail_value" + assert response.error_code == config.Deployment.ErrorCode.REVISION_FAILED + assert response.delete_build == "delete_build_value" + assert response.delete_logs == "delete_logs_value" + assert response.error_logs == "error_logs_value" + assert response.artifacts_gcs_bucket == "artifacts_gcs_bucket_value" + assert response.service_account == "service_account_value" + assert response.import_existing_resources is True + assert response.worker_pool == "worker_pool_value" + assert response.lock_state == config.Deployment.LockState.LOCKED + assert response.tf_version_constraint == "tf_version_constraint_value" + assert response.tf_version == "tf_version_value" + assert response.quota_validation == config.QuotaValidation.ENABLED + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_deployment_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), + ) + client = ConfigClient(transport=transport) + + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object( + transports.ConfigRestInterceptor, "post_get_deployment" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_get_deployment_with_metadata" + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_get_deployment" + ) as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.GetDeploymentRequest.pb(config.GetDeploymentRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = config.Deployment.to_json(config.Deployment()) + req.return_value.content = return_value + + request = config.GetDeploymentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = config.Deployment() + post_with_metadata.return_value = config.Deployment(), metadata + + client.get_deployment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_deployment_rest_bad_request( + request_type=config.CreateDeploymentRequest, +): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_deployment(request) + + +@pytest.mark.parametrize( + "request_type", + [ + config.CreateDeploymentRequest, + dict, + ], +) +def test_create_deployment_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["deployment"] = { + "terraform_blueprint": { + "gcs_source": "gcs_source_value", + "git_source": { + "repo": "repo_value", + "directory": "directory_value", + "ref": "ref_value", + }, + "input_values": {}, + "external_values": {}, + }, + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "state": 1, + "latest_revision": "latest_revision_value", + "state_detail": "state_detail_value", + "error_code": 1, + "delete_results": { + "content": "content_value", + "artifacts": "artifacts_value", + "outputs": {}, + }, + "delete_build": "delete_build_value", + "delete_logs": "delete_logs_value", + "tf_errors": [ + { + "resource_address": "resource_address_value", + "http_response_code": 1928, + "error_description": "error_description_value", + "error": { + "code": 411, + "message": "message_value", + "details": [ + { + "type_url": "type.googleapis.com/google.protobuf.Duration", + "value": b"\x08\x0c\x10\xdb\x07", + } + ], + }, + } + ], + "error_logs": "error_logs_value", + "artifacts_gcs_bucket": "artifacts_gcs_bucket_value", + "service_account": "service_account_value", + "import_existing_resources": True, + "worker_pool": "worker_pool_value", + "lock_state": 1, + "tf_version_constraint": "tf_version_constraint_value", + "tf_version": "tf_version_value", + "quota_validation": 1, + "annotations": {}, + "provider_config": {"source_type": 1}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = config.CreateDeploymentRequest.meta.fields["deployment"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["deployment"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["deployment"][field])): + del request_init["deployment"][field][i][subfield] + else: + del request_init["deployment"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_deployment(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_deployment_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), + ) + client = ConfigClient(transport=transport) + + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), + mock.patch.object( + transports.ConfigRestInterceptor, "post_create_deployment" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_create_deployment_with_metadata" + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_create_deployment" + ) as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.CreateDeploymentRequest.pb(config.CreateDeploymentRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = config.CreateDeploymentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_deployment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_deployment_rest_bad_request( + request_type=config.UpdateDeploymentRequest, +): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "deployment": {"name": "projects/sample1/locations/sample2/deployments/sample3"} + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_deployment(request) + + +@pytest.mark.parametrize( + "request_type", + [ + config.UpdateDeploymentRequest, + dict, + ], +) +def test_update_deployment_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "deployment": {"name": "projects/sample1/locations/sample2/deployments/sample3"} + } + request_init["deployment"] = { + "terraform_blueprint": { + "gcs_source": "gcs_source_value", + "git_source": { + "repo": "repo_value", + "directory": "directory_value", + "ref": "ref_value", + }, + "input_values": {}, + "external_values": {}, + }, + "name": "projects/sample1/locations/sample2/deployments/sample3", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "state": 1, + "latest_revision": "latest_revision_value", + "state_detail": "state_detail_value", + "error_code": 1, + "delete_results": { + "content": "content_value", + "artifacts": "artifacts_value", + "outputs": {}, + }, + "delete_build": "delete_build_value", + "delete_logs": "delete_logs_value", + "tf_errors": [ + { + "resource_address": "resource_address_value", + "http_response_code": 1928, + "error_description": "error_description_value", + "error": { + "code": 411, + "message": "message_value", + "details": [ + { + "type_url": "type.googleapis.com/google.protobuf.Duration", + "value": b"\x08\x0c\x10\xdb\x07", + } + ], + }, + } + ], + "error_logs": "error_logs_value", + "artifacts_gcs_bucket": "artifacts_gcs_bucket_value", + "service_account": "service_account_value", + "import_existing_resources": True, + "worker_pool": "worker_pool_value", + "lock_state": 1, + "tf_version_constraint": "tf_version_constraint_value", + "tf_version": "tf_version_value", + "quota_validation": 1, + "annotations": {}, + "provider_config": {"source_type": 1}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = config.UpdateDeploymentRequest.meta.fields["deployment"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["deployment"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["deployment"][field])): + del request_init["deployment"][field][i][subfield] + else: + del request_init["deployment"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_deployment(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_deployment_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), + ) + client = ConfigClient(transport=transport) + + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), + mock.patch.object( + transports.ConfigRestInterceptor, "post_update_deployment" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_update_deployment_with_metadata" + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_update_deployment" + ) as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.UpdateDeploymentRequest.pb(config.UpdateDeploymentRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = config.UpdateDeploymentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_deployment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_deployment_rest_bad_request( + request_type=config.DeleteDeploymentRequest, +): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_deployment(request) + + +@pytest.mark.parametrize( + "request_type", + [ + config.DeleteDeploymentRequest, + dict, + ], +) +def test_delete_deployment_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_deployment(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_deployment_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), + ) + client = ConfigClient(transport=transport) + + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), + mock.patch.object( + transports.ConfigRestInterceptor, "post_delete_deployment" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_delete_deployment_with_metadata" + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_delete_deployment" + ) as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.DeleteDeploymentRequest.pb(config.DeleteDeploymentRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = config.DeleteDeploymentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_deployment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - await client.get_resource_change(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceChangeRequest() + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - assert args[0] == request_msg +def test_list_revisions_rest_bad_request(request_type=config.ListRevisionsRequest): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request = request_type(**request_init) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_resource_drifts_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_revisions(request) + + +@pytest.mark.parametrize( + "request_type", + [ + config.ListRevisionsRequest, + dict, + ], +) +def test_list_revisions_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_resource_drifts), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ListResourceDriftsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ListRevisionsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) - await client.list_resource_drifts(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.ListResourceDriftsRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = config.ListRevisionsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_revisions(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListRevisionsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_revisions_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), + ) + client = ConfigClient(transport=transport) + + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object( + transports.ConfigRestInterceptor, "post_list_revisions" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_list_revisions_with_metadata" + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_list_revisions" + ) as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.ListRevisionsRequest.pb(config.ListRevisionsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = config.ListRevisionsResponse.to_json( + config.ListRevisionsResponse() + ) + req.return_value.content = return_value -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_resource_drift_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + request = config.ListRevisionsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = config.ListRevisionsResponse() + post_with_metadata.return_value = config.ListRevisionsResponse(), metadata - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_resource_drift), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.ResourceDrift( - name="name_value", - ) + client.list_revisions( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - await client.get_resource_drift(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceDriftRequest() + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - assert args[0] == request_msg +def test_get_revision_rest_bad_request(request_type=config.GetRevisionRequest): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" + } + request = request_type(**request_init) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_auto_migration_config_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_revision(request) + + +@pytest.mark.parametrize( + "request_type", + [ + config.GetRevisionRequest, + dict, + ], +) +def test_get_revision_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_auto_migration_config), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - config.AutoMigrationConfig( - name="name_value", - auto_migration_enabled=True, - ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.Revision( + name="name_value", + action=config.Revision.Action.CREATE, + state=config.Revision.State.APPLYING, + state_detail="state_detail_value", + error_code=config.Revision.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED, + build="build_value", + logs="logs_value", + error_logs="error_logs_value", + service_account="service_account_value", + import_existing_resources=True, + worker_pool="worker_pool_value", + tf_version_constraint="tf_version_constraint_value", + tf_version="tf_version_value", + quota_validation_results="quota_validation_results_value", + quota_validation=config.QuotaValidation.ENABLED, ) - await client.get_auto_migration_config(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.GetAutoMigrationConfigRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = config.Revision.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_revision(request) + # Establish that the response is the type that we expect. + assert isinstance(response, config.Revision) + assert response.name == "name_value" + assert response.action == config.Revision.Action.CREATE + assert response.state == config.Revision.State.APPLYING + assert response.state_detail == "state_detail_value" + assert ( + response.error_code == config.Revision.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED + ) + assert response.build == "build_value" + assert response.logs == "logs_value" + assert response.error_logs == "error_logs_value" + assert response.service_account == "service_account_value" + assert response.import_existing_resources is True + assert response.worker_pool == "worker_pool_value" + assert response.tf_version_constraint == "tf_version_constraint_value" + assert response.tf_version == "tf_version_value" + assert response.quota_validation_results == "quota_validation_results_value" + assert response.quota_validation == config.QuotaValidation.ENABLED -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_auto_migration_config_empty_call_grpc_asyncio(): - client = ConfigAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_revision_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), ) + client = ConfigClient(transport=transport) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_auto_migration_config), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.update_auto_migration_config(request=None) + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object( + transports.ConfigRestInterceptor, "post_get_revision" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_get_revision_with_metadata" + ) as post_with_metadata, + mock.patch.object(transports.ConfigRestInterceptor, "pre_get_revision") as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.GetRevisionRequest.pb(config.GetRevisionRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = config.UpdateAutoMigrationConfigRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = config.Revision.to_json(config.Revision()) + req.return_value.content = return_value - assert args[0] == request_msg + request = config.GetRevisionRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = config.Revision() + post_with_metadata.return_value = config.Revision(), metadata + client.get_revision( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -def test_transport_kind_rest(): - transport = ConfigClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_list_deployments_rest_bad_request(request_type=config.ListDeploymentsRequest): +def test_get_resource_rest_bad_request(request_type=config.GetResourceRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4/resources/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -19859,31 +26981,34 @@ def test_list_deployments_rest_bad_request(request_type=config.ListDeploymentsRe response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_deployments(request) + client.get_resource(request) @pytest.mark.parametrize( "request_type", [ - config.ListDeploymentsRequest, + config.GetResourceRequest, dict, ], ) -def test_list_deployments_rest_call_success(request_type): +def test_get_resource_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4/resources/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListDeploymentsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], + return_value = config.Resource( + name="name_value", + intent=config.Resource.Intent.CREATE, + state=config.Resource.State.PLANNED, ) # Wrap the value into a proper Response obj @@ -19891,21 +27016,22 @@ def test_list_deployments_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ListDeploymentsResponse.pb(return_value) + return_value = config.Resource.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_deployments(request) + response = client.get_resource(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDeploymentsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + assert isinstance(response, config.Resource) + assert response.name == "name_value" + assert response.intent == config.Resource.Intent.CREATE + assert response.state == config.Resource.State.PLANNED @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_deployments_rest_interceptors(null_interceptor): +def test_get_resource_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -19916,19 +27042,17 @@ def test_list_deployments_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_list_deployments" + transports.ConfigRestInterceptor, "post_get_resource" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_list_deployments_with_metadata" + transports.ConfigRestInterceptor, "post_get_resource_with_metadata" ) as post_with_metadata, - mock.patch.object( - transports.ConfigRestInterceptor, "pre_list_deployments" - ) as pre, + mock.patch.object(transports.ConfigRestInterceptor, "pre_get_resource") as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ListDeploymentsRequest.pb(config.ListDeploymentsRequest()) + pb_message = config.GetResourceRequest.pb(config.GetResourceRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -19939,21 +27063,19 @@ def test_list_deployments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ListDeploymentsResponse.to_json( - config.ListDeploymentsResponse() - ) + return_value = config.Resource.to_json(config.Resource()) req.return_value.content = return_value - request = config.ListDeploymentsRequest() + request = config.GetResourceRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ListDeploymentsResponse() - post_with_metadata.return_value = config.ListDeploymentsResponse(), metadata + post.return_value = config.Resource() + post_with_metadata.return_value = config.Resource(), metadata - client.list_deployments( + client.get_resource( request, metadata=[ ("key", "val"), @@ -19966,12 +27088,14 @@ def test_list_deployments_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_deployment_rest_bad_request(request_type=config.GetDeploymentRequest): +def test_list_resources_rest_bad_request(request_type=config.ListResourcesRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -19987,45 +27111,33 @@ def test_get_deployment_rest_bad_request(request_type=config.GetDeploymentReques response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_deployment(request) + client.list_resources(request) @pytest.mark.parametrize( "request_type", [ - config.GetDeploymentRequest, + config.ListResourcesRequest, dict, ], ) -def test_get_deployment_rest_call_success(request_type): +def test_list_resources_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.Deployment( - name="name_value", - state=config.Deployment.State.CREATING, - latest_revision="latest_revision_value", - state_detail="state_detail_value", - error_code=config.Deployment.ErrorCode.REVISION_FAILED, - delete_build="delete_build_value", - delete_logs="delete_logs_value", - error_logs="error_logs_value", - artifacts_gcs_bucket="artifacts_gcs_bucket_value", - service_account="service_account_value", - import_existing_resources=True, - worker_pool="worker_pool_value", - lock_state=config.Deployment.LockState.LOCKED, - tf_version_constraint="tf_version_constraint_value", - tf_version="tf_version_value", - quota_validation=config.QuotaValidation.ENABLED, + return_value = config.ListResourcesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) # Wrap the value into a proper Response obj @@ -20033,35 +27145,21 @@ def test_get_deployment_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.Deployment.pb(return_value) + return_value = config.ListResourcesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_deployment(request) + response = client.list_resources(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.Deployment) - assert response.name == "name_value" - assert response.state == config.Deployment.State.CREATING - assert response.latest_revision == "latest_revision_value" - assert response.state_detail == "state_detail_value" - assert response.error_code == config.Deployment.ErrorCode.REVISION_FAILED - assert response.delete_build == "delete_build_value" - assert response.delete_logs == "delete_logs_value" - assert response.error_logs == "error_logs_value" - assert response.artifacts_gcs_bucket == "artifacts_gcs_bucket_value" - assert response.service_account == "service_account_value" - assert response.import_existing_resources is True - assert response.worker_pool == "worker_pool_value" - assert response.lock_state == config.Deployment.LockState.LOCKED - assert response.tf_version_constraint == "tf_version_constraint_value" - assert response.tf_version == "tf_version_value" - assert response.quota_validation == config.QuotaValidation.ENABLED + assert isinstance(response, pagers.ListResourcesPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_deployment_rest_interceptors(null_interceptor): +def test_list_resources_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -20072,19 +27170,19 @@ def test_get_deployment_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_deployment" + transports.ConfigRestInterceptor, "post_list_resources" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_deployment_with_metadata" + transports.ConfigRestInterceptor, "post_list_resources_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_get_deployment" + transports.ConfigRestInterceptor, "pre_list_resources" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.GetDeploymentRequest.pb(config.GetDeploymentRequest()) + pb_message = config.ListResourcesRequest.pb(config.ListResourcesRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -20095,19 +27193,21 @@ def test_get_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.Deployment.to_json(config.Deployment()) + return_value = config.ListResourcesResponse.to_json( + config.ListResourcesResponse() + ) req.return_value.content = return_value - request = config.GetDeploymentRequest() + request = config.ListResourcesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.Deployment() - post_with_metadata.return_value = config.Deployment(), metadata + post.return_value = config.ListResourcesResponse() + post_with_metadata.return_value = config.ListResourcesResponse(), metadata - client.get_deployment( + client.list_resources( request, metadata=[ ("key", "val"), @@ -20120,14 +27220,14 @@ def test_get_deployment_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_create_deployment_rest_bad_request( - request_type=config.CreateDeploymentRequest, +def test_export_deployment_statefile_rest_bad_request( + request_type=config.ExportDeploymentStatefileRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -20138,171 +27238,56 @@ def test_create_deployment_rest_bad_request( # Wrap the value into a proper Response obj response_value = mock.Mock() json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_deployment(request) - - -@pytest.mark.parametrize( - "request_type", - [ - config.CreateDeploymentRequest, - dict, - ], -) -def test_create_deployment_rest_call_success(request_type): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["deployment"] = { - "terraform_blueprint": { - "gcs_source": "gcs_source_value", - "git_source": { - "repo": "repo_value", - "directory": "directory_value", - "ref": "ref_value", - }, - "input_values": {}, - }, - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "state": 1, - "latest_revision": "latest_revision_value", - "state_detail": "state_detail_value", - "error_code": 1, - "delete_results": { - "content": "content_value", - "artifacts": "artifacts_value", - "outputs": {}, - }, - "delete_build": "delete_build_value", - "delete_logs": "delete_logs_value", - "tf_errors": [ - { - "resource_address": "resource_address_value", - "http_response_code": 1928, - "error_description": "error_description_value", - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - } - ], - "error_logs": "error_logs_value", - "artifacts_gcs_bucket": "artifacts_gcs_bucket_value", - "service_account": "service_account_value", - "import_existing_resources": True, - "worker_pool": "worker_pool_value", - "lock_state": 1, - "tf_version_constraint": "tf_version_constraint_value", - "tf_version": "tf_version_value", - "quota_validation": 1, - "annotations": {}, - "provider_config": {"source_type": 1}, - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = config.CreateDeploymentRequest.meta.fields["deployment"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["deployment"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.export_deployment_statefile(request) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["deployment"][field])): - del request_init["deployment"][field][i][subfield] - else: - del request_init["deployment"][field][subfield] + +@pytest.mark.parametrize( + "request_type", + [ + config.ExportDeploymentStatefileRequest, + dict, + ], +) +def test_export_deployment_statefile_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.Statefile( + signed_uri="signed_uri_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.Statefile.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_deployment(request) + response = client.export_deployment_statefile(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, config.Statefile) + assert response.signed_uri == "signed_uri_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_deployment_rest_interceptors(null_interceptor): +def test_export_deployment_statefile_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -20312,21 +27297,23 @@ def test_create_deployment_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, - mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_create_deployment" + transports.ConfigRestInterceptor, "post_export_deployment_statefile" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_create_deployment_with_metadata" + transports.ConfigRestInterceptor, + "post_export_deployment_statefile_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_create_deployment" + transports.ConfigRestInterceptor, "pre_export_deployment_statefile" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.CreateDeploymentRequest.pb(config.CreateDeploymentRequest()) + pb_message = config.ExportDeploymentStatefileRequest.pb( + config.ExportDeploymentStatefileRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -20337,19 +27324,19 @@ def test_create_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = config.Statefile.to_json(config.Statefile()) req.return_value.content = return_value - request = config.CreateDeploymentRequest() + request = config.ExportDeploymentStatefileRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + post.return_value = config.Statefile() + post_with_metadata.return_value = config.Statefile(), metadata - client.create_deployment( + client.export_deployment_statefile( request, metadata=[ ("key", "val"), @@ -20362,15 +27349,15 @@ def test_create_deployment_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_update_deployment_rest_bad_request( - request_type=config.UpdateDeploymentRequest, +def test_export_revision_statefile_rest_bad_request( + request_type=config.ExportRevisionStatefileRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "deployment": {"name": "projects/sample1/locations/sample2/deployments/sample3"} + "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" } request = request_type(**request_init) @@ -20387,168 +27374,180 @@ def test_update_deployment_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_deployment(request) + client.export_revision_statefile(request) @pytest.mark.parametrize( "request_type", [ - config.UpdateDeploymentRequest, + config.ExportRevisionStatefileRequest, dict, ], ) -def test_update_deployment_rest_call_success(request_type): +def test_export_revision_statefile_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "deployment": {"name": "projects/sample1/locations/sample2/deployments/sample3"} - } - request_init["deployment"] = { - "terraform_blueprint": { - "gcs_source": "gcs_source_value", - "git_source": { - "repo": "repo_value", - "directory": "directory_value", - "ref": "ref_value", - }, - "input_values": {}, - }, - "name": "projects/sample1/locations/sample2/deployments/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "state": 1, - "latest_revision": "latest_revision_value", - "state_detail": "state_detail_value", - "error_code": 1, - "delete_results": { - "content": "content_value", - "artifacts": "artifacts_value", - "outputs": {}, - }, - "delete_build": "delete_build_value", - "delete_logs": "delete_logs_value", - "tf_errors": [ - { - "resource_address": "resource_address_value", - "http_response_code": 1928, - "error_description": "error_description_value", - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - } - ], - "error_logs": "error_logs_value", - "artifacts_gcs_bucket": "artifacts_gcs_bucket_value", - "service_account": "service_account_value", - "import_existing_resources": True, - "worker_pool": "worker_pool_value", - "lock_state": 1, - "tf_version_constraint": "tf_version_constraint_value", - "tf_version": "tf_version_value", - "quota_validation": 1, - "annotations": {}, - "provider_config": {"source_type": 1}, + "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 + request = request_type(**request_init) - # Determine if the message type is proto-plus or protobuf - test_field = config.UpdateDeploymentRequest.meta.fields["deployment"] + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.Statefile( + signed_uri="signed_uri_value", + ) - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + # Convert return value to protobuf type + return_value = config.Statefile.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.export_revision_statefile(request) - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields + # Establish that the response is the type that we expect. + assert isinstance(response, config.Statefile) + assert response.signed_uri == "signed_uri_value" - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - subfields_not_in_runtime = [] +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_export_revision_statefile_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), + ) + client = ConfigClient(transport=transport) + + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object( + transports.ConfigRestInterceptor, "post_export_revision_statefile" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, + "post_export_revision_statefile_with_metadata", + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_export_revision_statefile" + ) as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.ExportRevisionStatefileRequest.pb( + config.ExportRevisionStatefileRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = config.Statefile.to_json(config.Statefile()) + req.return_value.content = return_value + + request = config.ExportRevisionStatefileRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = config.Statefile() + post_with_metadata.return_value = config.Statefile(), metadata + + client.export_revision_statefile( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_import_statefile_rest_bad_request(request_type=config.ImportStatefileRequest): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.import_statefile(request) - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["deployment"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) +@pytest.mark.parametrize( + "request_type", + [ + config.ImportStatefileRequest, + dict, + ], +) +def test_import_statefile_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["deployment"][field])): - del request_init["deployment"][field][i][subfield] - else: - del request_init["deployment"][field][subfield] + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.Statefile( + signed_uri="signed_uri_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.Statefile.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_deployment(request) + response = client.import_statefile(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, config.Statefile) + assert response.signed_uri == "signed_uri_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_deployment_rest_interceptors(null_interceptor): +def test_import_statefile_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -20558,21 +27557,20 @@ def test_update_deployment_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, - mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_update_deployment" + transports.ConfigRestInterceptor, "post_import_statefile" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_update_deployment_with_metadata" + transports.ConfigRestInterceptor, "post_import_statefile_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_update_deployment" + transports.ConfigRestInterceptor, "pre_import_statefile" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.UpdateDeploymentRequest.pb(config.UpdateDeploymentRequest()) + pb_message = config.ImportStatefileRequest.pb(config.ImportStatefileRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -20583,19 +27581,19 @@ def test_update_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = config.Statefile.to_json(config.Statefile()) req.return_value.content = return_value - request = config.UpdateDeploymentRequest() + request = config.ImportStatefileRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + post.return_value = config.Statefile() + post_with_metadata.return_value = config.Statefile(), metadata - client.update_deployment( + client.import_statefile( request, metadata=[ ("key", "val"), @@ -20608,9 +27606,7 @@ def test_update_deployment_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_delete_deployment_rest_bad_request( - request_type=config.DeleteDeploymentRequest, -): +def test_delete_statefile_rest_bad_request(request_type=config.DeleteStatefileRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -20631,17 +27627,17 @@ def test_delete_deployment_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_deployment(request) + client.delete_statefile(request) @pytest.mark.parametrize( "request_type", [ - config.DeleteDeploymentRequest, + config.DeleteStatefileRequest, dict, ], ) -def test_delete_deployment_rest_call_success(request_type): +def test_delete_statefile_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -20653,23 +27649,23 @@ def test_delete_deployment_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = None # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_deployment(request) + response = client.delete_statefile(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert response is None @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_deployment_rest_interceptors(null_interceptor): +def test_delete_statefile_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -20679,21 +27675,12 @@ def test_delete_deployment_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, - mock.patch.object(operation.Operation, "_set_result_from_operation"), - mock.patch.object( - transports.ConfigRestInterceptor, "post_delete_deployment" - ) as post, - mock.patch.object( - transports.ConfigRestInterceptor, "post_delete_deployment_with_metadata" - ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_delete_deployment" + transports.ConfigRestInterceptor, "pre_delete_statefile" ) as pre, ): pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = config.DeleteDeploymentRequest.pb(config.DeleteDeploymentRequest()) + pb_message = config.DeleteStatefileRequest.pb(config.DeleteStatefileRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -20704,19 +27691,15 @@ def test_delete_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - request = config.DeleteDeploymentRequest() + request = config.DeleteStatefileRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.delete_deployment( + client.delete_statefile( request, metadata=[ ("key", "val"), @@ -20725,16 +27708,14 @@ def test_delete_deployment_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() -def test_list_revisions_rest_bad_request(request_type=config.ListRevisionsRequest): +def test_lock_deployment_rest_bad_request(request_type=config.LockDeploymentRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -20750,53 +27731,45 @@ def test_list_revisions_rest_bad_request(request_type=config.ListRevisionsReques response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_revisions(request) + client.lock_deployment(request) @pytest.mark.parametrize( "request_type", [ - config.ListRevisionsRequest, + config.LockDeploymentRequest, dict, ], ) -def test_list_revisions_rest_call_success(request_type): +def test_lock_deployment_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListRevisionsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ListRevisionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_revisions(request) + response = client.lock_deployment(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRevisionsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_revisions_rest_interceptors(null_interceptor): +def test_lock_deployment_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -20806,20 +27779,21 @@ def test_list_revisions_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_list_revisions" + transports.ConfigRestInterceptor, "post_lock_deployment" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_list_revisions_with_metadata" + transports.ConfigRestInterceptor, "post_lock_deployment_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_list_revisions" + transports.ConfigRestInterceptor, "pre_lock_deployment" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ListRevisionsRequest.pb(config.ListRevisionsRequest()) + pb_message = config.LockDeploymentRequest.pb(config.LockDeploymentRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -20830,21 +27804,19 @@ def test_list_revisions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ListRevisionsResponse.to_json( - config.ListRevisionsResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.ListRevisionsRequest() + request = config.LockDeploymentRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ListRevisionsResponse() - post_with_metadata.return_value = config.ListRevisionsResponse(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.list_revisions( + client.lock_deployment( request, metadata=[ ("key", "val"), @@ -20857,14 +27829,14 @@ def test_list_revisions_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_revision_rest_bad_request(request_type=config.GetRevisionRequest): +def test_unlock_deployment_rest_bad_request( + request_type=config.UnlockDeploymentRequest, +): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" - } + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -20880,83 +27852,45 @@ def test_get_revision_rest_bad_request(request_type=config.GetRevisionRequest): response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_revision(request) + client.unlock_deployment(request) @pytest.mark.parametrize( "request_type", [ - config.GetRevisionRequest, + config.UnlockDeploymentRequest, dict, ], ) -def test_get_revision_rest_call_success(request_type): +def test_unlock_deployment_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" - } + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.Revision( - name="name_value", - action=config.Revision.Action.CREATE, - state=config.Revision.State.APPLYING, - state_detail="state_detail_value", - error_code=config.Revision.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED, - build="build_value", - logs="logs_value", - error_logs="error_logs_value", - service_account="service_account_value", - import_existing_resources=True, - worker_pool="worker_pool_value", - tf_version_constraint="tf_version_constraint_value", - tf_version="tf_version_value", - quota_validation_results="quota_validation_results_value", - quota_validation=config.QuotaValidation.ENABLED, - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.Revision.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_revision(request) + response = client.unlock_deployment(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.Revision) - assert response.name == "name_value" - assert response.action == config.Revision.Action.CREATE - assert response.state == config.Revision.State.APPLYING - assert response.state_detail == "state_detail_value" - assert ( - response.error_code == config.Revision.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED - ) - assert response.build == "build_value" - assert response.logs == "logs_value" - assert response.error_logs == "error_logs_value" - assert response.service_account == "service_account_value" - assert response.import_existing_resources is True - assert response.worker_pool == "worker_pool_value" - assert response.tf_version_constraint == "tf_version_constraint_value" - assert response.tf_version == "tf_version_value" - assert response.quota_validation_results == "quota_validation_results_value" - assert response.quota_validation == config.QuotaValidation.ENABLED + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_revision_rest_interceptors(null_interceptor): +def test_unlock_deployment_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -20966,18 +27900,21 @@ def test_get_revision_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_get_revision" + transports.ConfigRestInterceptor, "post_unlock_deployment" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_revision_with_metadata" + transports.ConfigRestInterceptor, "post_unlock_deployment_with_metadata" ) as post_with_metadata, - mock.patch.object(transports.ConfigRestInterceptor, "pre_get_revision") as pre, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_unlock_deployment" + ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.GetRevisionRequest.pb(config.GetRevisionRequest()) + pb_message = config.UnlockDeploymentRequest.pb(config.UnlockDeploymentRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -20988,19 +27925,19 @@ def test_get_revision_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.Revision.to_json(config.Revision()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.GetRevisionRequest() + request = config.UnlockDeploymentRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.Revision() - post_with_metadata.return_value = config.Revision(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.get_revision( + client.unlock_deployment( request, metadata=[ ("key", "val"), @@ -21013,14 +27950,12 @@ def test_get_revision_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_resource_rest_bad_request(request_type=config.GetResourceRequest): +def test_export_lock_info_rest_bad_request(request_type=config.ExportLockInfoRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4/resources/sample5" - } + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21036,34 +27971,34 @@ def test_get_resource_rest_bad_request(request_type=config.GetResourceRequest): response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_resource(request) + client.export_lock_info(request) @pytest.mark.parametrize( "request_type", [ - config.GetResourceRequest, + config.ExportLockInfoRequest, dict, ], ) -def test_get_resource_rest_call_success(request_type): +def test_export_lock_info_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4/resources/sample5" - } + request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.Resource( - name="name_value", - intent=config.Resource.Intent.CREATE, - state=config.Resource.State.PLANNED, + return_value = config.LockInfo( + lock_id=725, + operation="operation_value", + info="info_value", + who="who_value", + version="version_value", ) # Wrap the value into a proper Response obj @@ -21071,22 +28006,24 @@ def test_get_resource_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.Resource.pb(return_value) + return_value = config.LockInfo.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_resource(request) + response = client.export_lock_info(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.Resource) - assert response.name == "name_value" - assert response.intent == config.Resource.Intent.CREATE - assert response.state == config.Resource.State.PLANNED + assert isinstance(response, config.LockInfo) + assert response.lock_id == 725 + assert response.operation == "operation_value" + assert response.info == "info_value" + assert response.who == "who_value" + assert response.version == "version_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_resource_rest_interceptors(null_interceptor): +def test_export_lock_info_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -21097,17 +28034,19 @@ def test_get_resource_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_resource" + transports.ConfigRestInterceptor, "post_export_lock_info" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_resource_with_metadata" + transports.ConfigRestInterceptor, "post_export_lock_info_with_metadata" ) as post_with_metadata, - mock.patch.object(transports.ConfigRestInterceptor, "pre_get_resource") as pre, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_export_lock_info" + ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.GetResourceRequest.pb(config.GetResourceRequest()) + pb_message = config.ExportLockInfoRequest.pb(config.ExportLockInfoRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -21118,19 +28057,19 @@ def test_get_resource_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.Resource.to_json(config.Resource()) + return_value = config.LockInfo.to_json(config.LockInfo()) req.return_value.content = return_value - request = config.GetResourceRequest() + request = config.ExportLockInfoRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.Resource() - post_with_metadata.return_value = config.Resource(), metadata + post.return_value = config.LockInfo() + post_with_metadata.return_value = config.LockInfo(), metadata - client.get_resource( + client.export_lock_info( request, metadata=[ ("key", "val"), @@ -21143,14 +28082,12 @@ def test_get_resource_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_list_resources_rest_bad_request(request_type=config.ListResourcesRequest): +def test_create_preview_rest_bad_request(request_type=config.CreatePreviewRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21166,55 +28103,163 @@ def test_list_resources_rest_bad_request(request_type=config.ListResourcesReques response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_resources(request) + client.create_preview(request) @pytest.mark.parametrize( "request_type", [ - config.ListResourcesRequest, + config.CreatePreviewRequest, dict, ], ) -def test_list_resources_rest_call_success(request_type): +def test_create_preview_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["preview"] = { + "terraform_blueprint": { + "gcs_source": "gcs_source_value", + "git_source": { + "repo": "repo_value", + "directory": "directory_value", + "ref": "ref_value", + }, + "input_values": {}, + "external_values": {}, + }, + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "labels": {}, + "state": 1, + "deployment": "deployment_value", + "preview_mode": 1, + "service_account": "service_account_value", + "artifacts_gcs_bucket": "artifacts_gcs_bucket_value", + "worker_pool": "worker_pool_value", + "error_code": 1, + "error_status": { + "code": 411, + "message": "message_value", + "details": [ + { + "type_url": "type.googleapis.com/google.protobuf.Duration", + "value": b"\x08\x0c\x10\xdb\x07", + } + ], + }, + "build": "build_value", + "tf_errors": [ + { + "resource_address": "resource_address_value", + "http_response_code": 1928, + "error_description": "error_description_value", + "error": {}, + } + ], + "error_logs": "error_logs_value", + "preview_artifacts": { + "content": "content_value", + "artifacts": "artifacts_value", + }, + "logs": "logs_value", + "tf_version": "tf_version_value", + "tf_version_constraint": "tf_version_constraint_value", + "annotations": {}, + "provider_config": {"source_type": 1}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = config.CreatePreviewRequest.meta.fields["preview"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["preview"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["preview"][field])): + del request_init["preview"][field][i][subfield] + else: + del request_init["preview"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListResourcesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ListResourcesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_resources(request) + response = client.create_preview(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListResourcesPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_resources_rest_interceptors(null_interceptor): +def test_create_preview_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -21224,20 +28269,21 @@ def test_list_resources_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_list_resources" + transports.ConfigRestInterceptor, "post_create_preview" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_list_resources_with_metadata" + transports.ConfigRestInterceptor, "post_create_preview_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_list_resources" + transports.ConfigRestInterceptor, "pre_create_preview" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ListResourcesRequest.pb(config.ListResourcesRequest()) + pb_message = config.CreatePreviewRequest.pb(config.CreatePreviewRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -21248,21 +28294,19 @@ def test_list_resources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ListResourcesResponse.to_json( - config.ListResourcesResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.ListResourcesRequest() + request = config.CreatePreviewRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ListResourcesResponse() - post_with_metadata.return_value = config.ListResourcesResponse(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.list_resources( + client.create_preview( request, metadata=[ ("key", "val"), @@ -21275,14 +28319,12 @@ def test_list_resources_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_export_deployment_statefile_rest_bad_request( - request_type=config.ExportDeploymentStatefileRequest, -): +def test_get_preview_rest_bad_request(request_type=config.GetPreviewRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21298,30 +28340,42 @@ def test_export_deployment_statefile_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.export_deployment_statefile(request) + client.get_preview(request) @pytest.mark.parametrize( "request_type", [ - config.ExportDeploymentStatefileRequest, + config.GetPreviewRequest, dict, ], ) -def test_export_deployment_statefile_rest_call_success(request_type): +def test_get_preview_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.Statefile( - signed_uri="signed_uri_value", + return_value = config.Preview( + name="name_value", + state=config.Preview.State.CREATING, + deployment="deployment_value", + preview_mode=config.Preview.PreviewMode.DEFAULT, + service_account="service_account_value", + artifacts_gcs_bucket="artifacts_gcs_bucket_value", + worker_pool="worker_pool_value", + error_code=config.Preview.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED, + build="build_value", + error_logs="error_logs_value", + logs="logs_value", + tf_version="tf_version_value", + tf_version_constraint="tf_version_constraint_value", ) # Wrap the value into a proper Response obj @@ -21329,20 +28383,32 @@ def test_export_deployment_statefile_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.Statefile.pb(return_value) + return_value = config.Preview.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.export_deployment_statefile(request) + response = client.get_preview(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.Statefile) - assert response.signed_uri == "signed_uri_value" + assert isinstance(response, config.Preview) + assert response.name == "name_value" + assert response.state == config.Preview.State.CREATING + assert response.deployment == "deployment_value" + assert response.preview_mode == config.Preview.PreviewMode.DEFAULT + assert response.service_account == "service_account_value" + assert response.artifacts_gcs_bucket == "artifacts_gcs_bucket_value" + assert response.worker_pool == "worker_pool_value" + assert response.error_code == config.Preview.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED + assert response.build == "build_value" + assert response.error_logs == "error_logs_value" + assert response.logs == "logs_value" + assert response.tf_version == "tf_version_value" + assert response.tf_version_constraint == "tf_version_constraint_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_export_deployment_statefile_rest_interceptors(null_interceptor): +def test_get_preview_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -21352,23 +28418,16 @@ def test_export_deployment_statefile_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(transports.ConfigRestInterceptor, "post_get_preview") as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_export_deployment_statefile" - ) as post, - mock.patch.object( - transports.ConfigRestInterceptor, - "post_export_deployment_statefile_with_metadata", + transports.ConfigRestInterceptor, "post_get_preview_with_metadata" ) as post_with_metadata, - mock.patch.object( - transports.ConfigRestInterceptor, "pre_export_deployment_statefile" - ) as pre, + mock.patch.object(transports.ConfigRestInterceptor, "pre_get_preview") as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ExportDeploymentStatefileRequest.pb( - config.ExportDeploymentStatefileRequest() - ) + pb_message = config.GetPreviewRequest.pb(config.GetPreviewRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -21379,19 +28438,19 @@ def test_export_deployment_statefile_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.Statefile.to_json(config.Statefile()) + return_value = config.Preview.to_json(config.Preview()) req.return_value.content = return_value - request = config.ExportDeploymentStatefileRequest() + request = config.GetPreviewRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.Statefile() - post_with_metadata.return_value = config.Statefile(), metadata + post.return_value = config.Preview() + post_with_metadata.return_value = config.Preview(), metadata - client.export_deployment_statefile( + client.get_preview( request, metadata=[ ("key", "val"), @@ -21404,16 +28463,12 @@ def test_export_deployment_statefile_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_export_revision_statefile_rest_bad_request( - request_type=config.ExportRevisionStatefileRequest, -): +def test_list_previews_rest_bad_request(request_type=config.ListPreviewsRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21429,32 +28484,31 @@ def test_export_revision_statefile_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.export_revision_statefile(request) + client.list_previews(request) @pytest.mark.parametrize( "request_type", [ - config.ExportRevisionStatefileRequest, + config.ListPreviewsRequest, dict, ], ) -def test_export_revision_statefile_rest_call_success(request_type): +def test_list_previews_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/deployments/sample3/revisions/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.Statefile( - signed_uri="signed_uri_value", + return_value = config.ListPreviewsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) # Wrap the value into a proper Response obj @@ -21462,20 +28516,21 @@ def test_export_revision_statefile_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.Statefile.pb(return_value) + return_value = config.ListPreviewsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.export_revision_statefile(request) + response = client.list_previews(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.Statefile) - assert response.signed_uri == "signed_uri_value" + assert isinstance(response, pagers.ListPreviewsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_export_revision_statefile_rest_interceptors(null_interceptor): +def test_list_previews_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -21486,22 +28541,17 @@ def test_export_revision_statefile_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_export_revision_statefile" + transports.ConfigRestInterceptor, "post_list_previews" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, - "post_export_revision_statefile_with_metadata", + transports.ConfigRestInterceptor, "post_list_previews_with_metadata" ) as post_with_metadata, - mock.patch.object( - transports.ConfigRestInterceptor, "pre_export_revision_statefile" - ) as pre, + mock.patch.object(transports.ConfigRestInterceptor, "pre_list_previews") as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ExportRevisionStatefileRequest.pb( - config.ExportRevisionStatefileRequest() - ) + pb_message = config.ListPreviewsRequest.pb(config.ListPreviewsRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -21512,19 +28562,21 @@ def test_export_revision_statefile_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.Statefile.to_json(config.Statefile()) + return_value = config.ListPreviewsResponse.to_json( + config.ListPreviewsResponse() + ) req.return_value.content = return_value - request = config.ExportRevisionStatefileRequest() + request = config.ListPreviewsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.Statefile() - post_with_metadata.return_value = config.Statefile(), metadata + post.return_value = config.ListPreviewsResponse() + post_with_metadata.return_value = config.ListPreviewsResponse(), metadata - client.export_revision_statefile( + client.list_previews( request, metadata=[ ("key", "val"), @@ -21537,12 +28589,12 @@ def test_export_revision_statefile_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_import_statefile_rest_bad_request(request_type=config.ImportStatefileRequest): +def test_delete_preview_rest_bad_request(request_type=config.DeletePreviewRequest): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21558,51 +28610,45 @@ def test_import_statefile_rest_bad_request(request_type=config.ImportStatefileRe response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.import_statefile(request) + client.delete_preview(request) @pytest.mark.parametrize( "request_type", [ - config.ImportStatefileRequest, + config.DeletePreviewRequest, dict, ], ) -def test_import_statefile_rest_call_success(request_type): +def test_delete_preview_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.Statefile( - signed_uri="signed_uri_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.Statefile.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.import_statefile(request) + response = client.delete_preview(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.Statefile) - assert response.signed_uri == "signed_uri_value" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_import_statefile_rest_interceptors(null_interceptor): +def test_delete_preview_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -21612,20 +28658,21 @@ def test_import_statefile_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_import_statefile" + transports.ConfigRestInterceptor, "post_delete_preview" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_import_statefile_with_metadata" + transports.ConfigRestInterceptor, "post_delete_preview_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_import_statefile" + transports.ConfigRestInterceptor, "pre_delete_preview" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ImportStatefileRequest.pb(config.ImportStatefileRequest()) + pb_message = config.DeletePreviewRequest.pb(config.DeletePreviewRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -21636,19 +28683,19 @@ def test_import_statefile_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.Statefile.to_json(config.Statefile()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.ImportStatefileRequest() + request = config.DeletePreviewRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.Statefile() - post_with_metadata.return_value = config.Statefile(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.import_statefile( + client.delete_preview( request, metadata=[ ("key", "val"), @@ -21661,12 +28708,14 @@ def test_import_statefile_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_delete_statefile_rest_bad_request(request_type=config.DeleteStatefileRequest): +def test_export_preview_result_rest_bad_request( + request_type=config.ExportPreviewResultRequest, +): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21682,45 +28731,48 @@ def test_delete_statefile_rest_bad_request(request_type=config.DeleteStatefileRe response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_statefile(request) + client.export_preview_result(request) @pytest.mark.parametrize( "request_type", [ - config.DeleteStatefileRequest, + config.ExportPreviewResultRequest, dict, ], ) -def test_delete_statefile_rest_call_success(request_type): +def test_export_preview_result_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = config.ExportPreviewResultResponse() # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - json_return_value = "" + + # Convert return value to protobuf type + return_value = config.ExportPreviewResultResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_statefile(request) + response = client.export_preview_result(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, config.ExportPreviewResultResponse) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_statefile_rest_interceptors(null_interceptor): +def test_export_preview_result_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -21731,11 +28783,21 @@ def test_delete_statefile_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "pre_delete_statefile" + transports.ConfigRestInterceptor, "post_export_preview_result" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_export_preview_result_with_metadata" + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_export_preview_result" ) as pre, ): pre.assert_not_called() - pb_message = config.DeleteStatefileRequest.pb(config.DeleteStatefileRequest()) + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.ExportPreviewResultRequest.pb( + config.ExportPreviewResultRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -21746,15 +28808,21 @@ def test_delete_statefile_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = config.ExportPreviewResultResponse.to_json( + config.ExportPreviewResultResponse() + ) + req.return_value.content = return_value - request = config.DeleteStatefileRequest() + request = config.ExportPreviewResultRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = config.ExportPreviewResultResponse() + post_with_metadata.return_value = config.ExportPreviewResultResponse(), metadata - client.delete_statefile( + client.export_preview_result( request, metadata=[ ("key", "val"), @@ -21763,14 +28831,18 @@ def test_delete_statefile_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_lock_deployment_rest_bad_request(request_type=config.LockDeploymentRequest): +def test_list_terraform_versions_rest_bad_request( + request_type=config.ListTerraformVersionsRequest, +): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21786,45 +28858,53 @@ def test_lock_deployment_rest_bad_request(request_type=config.LockDeploymentRequ response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.lock_deployment(request) + client.list_terraform_versions(request) @pytest.mark.parametrize( "request_type", [ - config.LockDeploymentRequest, + config.ListTerraformVersionsRequest, dict, ], ) -def test_lock_deployment_rest_call_success(request_type): +def test_list_terraform_versions_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.ListTerraformVersionsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ListTerraformVersionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.lock_deployment(request) + response = client.list_terraform_versions(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, pagers.ListTerraformVersionsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_lock_deployment_rest_interceptors(null_interceptor): +def test_list_terraform_versions_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -21834,21 +28914,23 @@ def test_lock_deployment_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, - mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_lock_deployment" + transports.ConfigRestInterceptor, "post_list_terraform_versions" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_lock_deployment_with_metadata" + transports.ConfigRestInterceptor, + "post_list_terraform_versions_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_lock_deployment" + transports.ConfigRestInterceptor, "pre_list_terraform_versions" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.LockDeploymentRequest.pb(config.LockDeploymentRequest()) + pb_message = config.ListTerraformVersionsRequest.pb( + config.ListTerraformVersionsRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -21859,19 +28941,24 @@ def test_lock_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = config.ListTerraformVersionsResponse.to_json( + config.ListTerraformVersionsResponse() + ) req.return_value.content = return_value - request = config.LockDeploymentRequest() + request = config.ListTerraformVersionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + post.return_value = config.ListTerraformVersionsResponse() + post_with_metadata.return_value = ( + config.ListTerraformVersionsResponse(), + metadata, + ) - client.lock_deployment( + client.list_terraform_versions( request, metadata=[ ("key", "val"), @@ -21884,14 +28971,16 @@ def test_lock_deployment_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_unlock_deployment_rest_bad_request( - request_type=config.UnlockDeploymentRequest, +def test_get_terraform_version_rest_bad_request( + request_type=config.GetTerraformVersionRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/terraformVersions/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21907,45 +28996,55 @@ def test_unlock_deployment_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.unlock_deployment(request) + client.get_terraform_version(request) @pytest.mark.parametrize( "request_type", [ - config.UnlockDeploymentRequest, + config.GetTerraformVersionRequest, dict, ], ) -def test_unlock_deployment_rest_call_success(request_type): +def test_get_terraform_version_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/terraformVersions/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.TerraformVersion( + name="name_value", + state=config.TerraformVersion.State.ACTIVE, + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.TerraformVersion.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.unlock_deployment(request) + response = client.get_terraform_version(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, config.TerraformVersion) + assert response.name == "name_value" + assert response.state == config.TerraformVersion.State.ACTIVE @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_unlock_deployment_rest_interceptors(null_interceptor): +def test_get_terraform_version_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -21955,21 +29054,22 @@ def test_unlock_deployment_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, - mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_unlock_deployment" + transports.ConfigRestInterceptor, "post_get_terraform_version" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_unlock_deployment_with_metadata" + transports.ConfigRestInterceptor, "post_get_terraform_version_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_unlock_deployment" + transports.ConfigRestInterceptor, "pre_get_terraform_version" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.UnlockDeploymentRequest.pb(config.UnlockDeploymentRequest()) + pb_message = config.GetTerraformVersionRequest.pb( + config.GetTerraformVersionRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -21980,19 +29080,19 @@ def test_unlock_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = config.TerraformVersion.to_json(config.TerraformVersion()) req.return_value.content = return_value - request = config.UnlockDeploymentRequest() + request = config.GetTerraformVersionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + post.return_value = config.TerraformVersion() + post_with_metadata.return_value = config.TerraformVersion(), metadata - client.unlock_deployment( + client.get_terraform_version( request, metadata=[ ("key", "val"), @@ -22005,12 +29105,14 @@ def test_unlock_deployment_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_export_lock_info_rest_bad_request(request_type=config.ExportLockInfoRequest): +def test_list_resource_changes_rest_bad_request( + request_type=config.ListResourceChangesRequest, +): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22026,34 +29128,31 @@ def test_export_lock_info_rest_bad_request(request_type=config.ExportLockInfoReq response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.export_lock_info(request) + client.list_resource_changes(request) @pytest.mark.parametrize( "request_type", [ - config.ExportLockInfoRequest, + config.ListResourceChangesRequest, dict, ], ) -def test_export_lock_info_rest_call_success(request_type): +def test_list_resource_changes_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/deployments/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.LockInfo( - lock_id=725, - operation="operation_value", - info="info_value", - who="who_value", - version="version_value", + return_value = config.ListResourceChangesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) # Wrap the value into a proper Response obj @@ -22061,24 +29160,21 @@ def test_export_lock_info_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.LockInfo.pb(return_value) + return_value = config.ListResourceChangesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.export_lock_info(request) + response = client.list_resource_changes(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.LockInfo) - assert response.lock_id == 725 - assert response.operation == "operation_value" - assert response.info == "info_value" - assert response.who == "who_value" - assert response.version == "version_value" + assert isinstance(response, pagers.ListResourceChangesPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_export_lock_info_rest_interceptors(null_interceptor): +def test_list_resource_changes_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -22089,19 +29185,21 @@ def test_export_lock_info_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_export_lock_info" + transports.ConfigRestInterceptor, "post_list_resource_changes" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_export_lock_info_with_metadata" + transports.ConfigRestInterceptor, "post_list_resource_changes_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_export_lock_info" + transports.ConfigRestInterceptor, "pre_list_resource_changes" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ExportLockInfoRequest.pb(config.ExportLockInfoRequest()) + pb_message = config.ListResourceChangesRequest.pb( + config.ListResourceChangesRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -22112,19 +29210,21 @@ def test_export_lock_info_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.LockInfo.to_json(config.LockInfo()) + return_value = config.ListResourceChangesResponse.to_json( + config.ListResourceChangesResponse() + ) req.return_value.content = return_value - request = config.ExportLockInfoRequest() + request = config.ListResourceChangesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.LockInfo() - post_with_metadata.return_value = config.LockInfo(), metadata + post.return_value = config.ListResourceChangesResponse() + post_with_metadata.return_value = config.ListResourceChangesResponse(), metadata - client.export_lock_info( + client.list_resource_changes( request, metadata=[ ("key", "val"), @@ -22137,12 +29237,16 @@ def test_export_lock_info_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_create_preview_rest_bad_request(request_type=config.CreatePreviewRequest): +def test_get_resource_change_rest_bad_request( + request_type=config.GetResourceChangeRequest, +): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/previews/sample3/resourceChanges/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22158,162 +29262,185 @@ def test_create_preview_rest_bad_request(request_type=config.CreatePreviewReques response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_preview(request) + client.get_resource_change(request) @pytest.mark.parametrize( "request_type", [ - config.CreatePreviewRequest, + config.GetResourceChangeRequest, dict, ], ) -def test_create_preview_rest_call_success(request_type): +def test_get_resource_change_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["preview"] = { - "terraform_blueprint": { - "gcs_source": "gcs_source_value", - "git_source": { - "repo": "repo_value", - "directory": "directory_value", - "ref": "ref_value", - }, - "input_values": {}, - }, - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "labels": {}, - "state": 1, - "deployment": "deployment_value", - "preview_mode": 1, - "service_account": "service_account_value", - "artifacts_gcs_bucket": "artifacts_gcs_bucket_value", - "worker_pool": "worker_pool_value", - "error_code": 1, - "error_status": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "build": "build_value", - "tf_errors": [ - { - "resource_address": "resource_address_value", - "http_response_code": 1928, - "error_description": "error_description_value", - "error": {}, - } - ], - "error_logs": "error_logs_value", - "preview_artifacts": { - "content": "content_value", - "artifacts": "artifacts_value", - }, - "logs": "logs_value", - "tf_version": "tf_version_value", - "tf_version_constraint": "tf_version_constraint_value", - "annotations": {}, - "provider_config": {"source_type": 1}, + request_init = { + "name": "projects/sample1/locations/sample2/previews/sample3/resourceChanges/sample4" } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = config.ResourceChange( + name="name_value", + intent=config.ResourceChange.Intent.CREATE, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ResourceChange.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_resource_change(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, config.ResourceChange) + assert response.name == "name_value" + assert response.intent == config.ResourceChange.Intent.CREATE + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_resource_change_rest_interceptors(null_interceptor): + transport = transports.ConfigRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), + ) + client = ConfigClient(transport=transport) + + with ( + mock.patch.object(type(client.transport._session), "request") as req, + mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object( + transports.ConfigRestInterceptor, "post_get_resource_change" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_get_resource_change_with_metadata" + ) as post_with_metadata, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_get_resource_change" + ) as pre, + ): + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = config.GetResourceChangeRequest.pb( + config.GetResourceChangeRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Determine if the message type is proto-plus or protobuf - test_field = config.CreatePreviewRequest.meta.fields["preview"] + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = config.ResourceChange.to_json(config.ResourceChange()) + req.return_value.content = return_value - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] + request = config.GetResourceChangeRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = config.ResourceChange() + post_with_metadata.return_value = config.ResourceChange(), metadata - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + client.get_resource_change( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - subfields_not_in_runtime = [] +def test_list_resource_drifts_rest_bad_request( + request_type=config.ListResourceDriftsRequest, +): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} + request = request_type(**request_init) - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["preview"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_resource_drifts(request) - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["preview"][field])): - del request_init["preview"][field][i][subfield] - else: - del request_init["preview"][field][subfield] +@pytest.mark.parametrize( + "request_type", + [ + config.ListResourceDriftsRequest, + dict, + ], +) +def test_list_resource_drifts_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.ListResourceDriftsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ListResourceDriftsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_preview(request) + response = client.list_resource_drifts(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, pagers.ListResourceDriftsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_preview_rest_interceptors(null_interceptor): +def test_list_resource_drifts_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -22323,21 +29450,22 @@ def test_create_preview_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, - mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_create_preview" + transports.ConfigRestInterceptor, "post_list_resource_drifts" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_create_preview_with_metadata" + transports.ConfigRestInterceptor, "post_list_resource_drifts_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_create_preview" + transports.ConfigRestInterceptor, "pre_list_resource_drifts" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.CreatePreviewRequest.pb(config.CreatePreviewRequest()) + pb_message = config.ListResourceDriftsRequest.pb( + config.ListResourceDriftsRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -22348,19 +29476,21 @@ def test_create_preview_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = config.ListResourceDriftsResponse.to_json( + config.ListResourceDriftsResponse() + ) req.return_value.content = return_value - request = config.CreatePreviewRequest() + request = config.ListResourceDriftsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + post.return_value = config.ListResourceDriftsResponse() + post_with_metadata.return_value = config.ListResourceDriftsResponse(), metadata - client.create_preview( + client.list_resource_drifts( request, metadata=[ ("key", "val"), @@ -22373,12 +29503,16 @@ def test_create_preview_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_preview_rest_bad_request(request_type=config.GetPreviewRequest): +def test_get_resource_drift_rest_bad_request( + request_type=config.GetResourceDriftRequest, +): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/previews/sample3/resourceDrifts/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22394,42 +29528,32 @@ def test_get_preview_rest_bad_request(request_type=config.GetPreviewRequest): response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_preview(request) + client.get_resource_drift(request) @pytest.mark.parametrize( "request_type", [ - config.GetPreviewRequest, + config.GetResourceDriftRequest, dict, ], ) -def test_get_preview_rest_call_success(request_type): +def test_get_resource_drift_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/previews/sample3/resourceDrifts/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.Preview( + return_value = config.ResourceDrift( name="name_value", - state=config.Preview.State.CREATING, - deployment="deployment_value", - preview_mode=config.Preview.PreviewMode.DEFAULT, - service_account="service_account_value", - artifacts_gcs_bucket="artifacts_gcs_bucket_value", - worker_pool="worker_pool_value", - error_code=config.Preview.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED, - build="build_value", - error_logs="error_logs_value", - logs="logs_value", - tf_version="tf_version_value", - tf_version_constraint="tf_version_constraint_value", ) # Wrap the value into a proper Response obj @@ -22437,32 +29561,20 @@ def test_get_preview_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.Preview.pb(return_value) + return_value = config.ResourceDrift.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_preview(request) + response = client.get_resource_drift(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.Preview) + assert isinstance(response, config.ResourceDrift) assert response.name == "name_value" - assert response.state == config.Preview.State.CREATING - assert response.deployment == "deployment_value" - assert response.preview_mode == config.Preview.PreviewMode.DEFAULT - assert response.service_account == "service_account_value" - assert response.artifacts_gcs_bucket == "artifacts_gcs_bucket_value" - assert response.worker_pool == "worker_pool_value" - assert response.error_code == config.Preview.ErrorCode.CLOUD_BUILD_PERMISSION_DENIED - assert response.build == "build_value" - assert response.error_logs == "error_logs_value" - assert response.logs == "logs_value" - assert response.tf_version == "tf_version_value" - assert response.tf_version_constraint == "tf_version_constraint_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_preview_rest_interceptors(null_interceptor): +def test_get_resource_drift_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -22472,16 +29584,20 @@ def test_get_preview_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, - mock.patch.object(transports.ConfigRestInterceptor, "post_get_preview") as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_preview_with_metadata" + transports.ConfigRestInterceptor, "post_get_resource_drift" + ) as post, + mock.patch.object( + transports.ConfigRestInterceptor, "post_get_resource_drift_with_metadata" ) as post_with_metadata, - mock.patch.object(transports.ConfigRestInterceptor, "pre_get_preview") as pre, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_get_resource_drift" + ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.GetPreviewRequest.pb(config.GetPreviewRequest()) + pb_message = config.GetResourceDriftRequest.pb(config.GetResourceDriftRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -22492,19 +29608,19 @@ def test_get_preview_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.Preview.to_json(config.Preview()) + return_value = config.ResourceDrift.to_json(config.ResourceDrift()) req.return_value.content = return_value - request = config.GetPreviewRequest() + request = config.GetResourceDriftRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.Preview() - post_with_metadata.return_value = config.Preview(), metadata + post.return_value = config.ResourceDrift() + post_with_metadata.return_value = config.ResourceDrift(), metadata - client.get_preview( + client.get_resource_drift( request, metadata=[ ("key", "val"), @@ -22517,12 +29633,14 @@ def test_get_preview_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_list_previews_rest_bad_request(request_type=config.ListPreviewsRequest): +def test_get_auto_migration_config_rest_bad_request( + request_type=config.GetAutoMigrationConfigRequest, +): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"name": "projects/sample1/locations/sample2/autoMigrationConfig"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22538,31 +29656,31 @@ def test_list_previews_rest_bad_request(request_type=config.ListPreviewsRequest) response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_previews(request) + client.get_auto_migration_config(request) @pytest.mark.parametrize( "request_type", [ - config.ListPreviewsRequest, + config.GetAutoMigrationConfigRequest, dict, ], ) -def test_list_previews_rest_call_success(request_type): +def test_get_auto_migration_config_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = {"name": "projects/sample1/locations/sample2/autoMigrationConfig"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListPreviewsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], + return_value = config.AutoMigrationConfig( + name="name_value", + auto_migration_enabled=True, ) # Wrap the value into a proper Response obj @@ -22570,21 +29688,21 @@ def test_list_previews_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ListPreviewsResponse.pb(return_value) + return_value = config.AutoMigrationConfig.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_previews(request) + response = client.get_auto_migration_config(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPreviewsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + assert isinstance(response, config.AutoMigrationConfig) + assert response.name == "name_value" + assert response.auto_migration_enabled is True @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_previews_rest_interceptors(null_interceptor): +def test_get_auto_migration_config_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -22595,17 +29713,22 @@ def test_list_previews_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_list_previews" + transports.ConfigRestInterceptor, "post_get_auto_migration_config" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_list_previews_with_metadata" + transports.ConfigRestInterceptor, + "post_get_auto_migration_config_with_metadata", ) as post_with_metadata, - mock.patch.object(transports.ConfigRestInterceptor, "pre_list_previews") as pre, + mock.patch.object( + transports.ConfigRestInterceptor, "pre_get_auto_migration_config" + ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ListPreviewsRequest.pb(config.ListPreviewsRequest()) + pb_message = config.GetAutoMigrationConfigRequest.pb( + config.GetAutoMigrationConfigRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -22616,21 +29739,19 @@ def test_list_previews_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ListPreviewsResponse.to_json( - config.ListPreviewsResponse() - ) + return_value = config.AutoMigrationConfig.to_json(config.AutoMigrationConfig()) req.return_value.content = return_value - request = config.ListPreviewsRequest() + request = config.GetAutoMigrationConfigRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ListPreviewsResponse() - post_with_metadata.return_value = config.ListPreviewsResponse(), metadata + post.return_value = config.AutoMigrationConfig() + post_with_metadata.return_value = config.AutoMigrationConfig(), metadata - client.list_previews( + client.get_auto_migration_config( request, metadata=[ ("key", "val"), @@ -22643,12 +29764,18 @@ def test_list_previews_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_delete_preview_rest_bad_request(request_type=config.DeletePreviewRequest): +def test_update_auto_migration_config_rest_bad_request( + request_type=config.UpdateAutoMigrationConfigRequest, +): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "auto_migration_config": { + "name": "projects/sample1/locations/sample2/autoMigrationConfig" + } + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22664,23 +29791,103 @@ def test_delete_preview_rest_bad_request(request_type=config.DeletePreviewReques response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_preview(request) + client.update_auto_migration_config(request) @pytest.mark.parametrize( "request_type", [ - config.DeletePreviewRequest, + config.UpdateAutoMigrationConfigRequest, dict, ], ) -def test_delete_preview_rest_call_success(request_type): +def test_update_auto_migration_config_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "auto_migration_config": { + "name": "projects/sample1/locations/sample2/autoMigrationConfig" + } + } + request_init["auto_migration_config"] = { + "name": "projects/sample1/locations/sample2/autoMigrationConfig", + "update_time": {"seconds": 751, "nanos": 543}, + "auto_migration_enabled": True, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = config.UpdateAutoMigrationConfigRequest.meta.fields[ + "auto_migration_config" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "auto_migration_config" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["auto_migration_config"][field])): + del request_init["auto_migration_config"][field][i][subfield] + else: + del request_init["auto_migration_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -22695,14 +29902,14 @@ def test_delete_preview_rest_call_success(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_preview(request) + response = client.update_auto_migration_config(request) # Establish that the response is the type that we expect. json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_preview_rest_interceptors(null_interceptor): +def test_update_auto_migration_config_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -22714,19 +29921,22 @@ def test_delete_preview_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_delete_preview" + transports.ConfigRestInterceptor, "post_update_auto_migration_config" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_delete_preview_with_metadata" + transports.ConfigRestInterceptor, + "post_update_auto_migration_config_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_delete_preview" + transports.ConfigRestInterceptor, "pre_update_auto_migration_config" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.DeletePreviewRequest.pb(config.DeletePreviewRequest()) + pb_message = config.UpdateAutoMigrationConfigRequest.pb( + config.UpdateAutoMigrationConfigRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -22740,7 +29950,7 @@ def test_delete_preview_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.DeletePreviewRequest() + request = config.UpdateAutoMigrationConfigRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -22749,7 +29959,7 @@ def test_delete_preview_rest_interceptors(null_interceptor): post.return_value = operations_pb2.Operation() post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.delete_preview( + client.update_auto_migration_config( request, metadata=[ ("key", "val"), @@ -22762,14 +29972,16 @@ def test_delete_preview_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_export_preview_result_rest_bad_request( - request_type=config.ExportPreviewResultRequest, +def test_get_deployment_group_rest_bad_request( + request_type=config.GetDeploymentGroupRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22785,48 +29997,67 @@ def test_export_preview_result_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.export_preview_result(request) + client.get_deployment_group(request) @pytest.mark.parametrize( "request_type", [ - config.ExportPreviewResultRequest, + config.GetDeploymentGroupRequest, dict, ], ) -def test_export_preview_result_rest_call_success(request_type): +def test_get_deployment_group_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ExportPreviewResultResponse() + return_value = config.DeploymentGroup( + name="name_value", + state=config.DeploymentGroup.State.CREATING, + state_description="state_description_value", + provisioning_state=config.DeploymentGroup.ProvisioningState.PROVISIONING, + provisioning_state_description="provisioning_state_description_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ExportPreviewResultResponse.pb(return_value) + return_value = config.DeploymentGroup.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.export_preview_result(request) + response = client.get_deployment_group(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.ExportPreviewResultResponse) + assert isinstance(response, config.DeploymentGroup) + assert response.name == "name_value" + assert response.state == config.DeploymentGroup.State.CREATING + assert response.state_description == "state_description_value" + assert ( + response.provisioning_state + == config.DeploymentGroup.ProvisioningState.PROVISIONING + ) + assert ( + response.provisioning_state_description + == "provisioning_state_description_value" + ) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_export_preview_result_rest_interceptors(null_interceptor): +def test_get_deployment_group_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -22837,20 +30068,20 @@ def test_export_preview_result_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_export_preview_result" + transports.ConfigRestInterceptor, "post_get_deployment_group" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_export_preview_result_with_metadata" + transports.ConfigRestInterceptor, "post_get_deployment_group_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_export_preview_result" + transports.ConfigRestInterceptor, "pre_get_deployment_group" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ExportPreviewResultRequest.pb( - config.ExportPreviewResultRequest() + pb_message = config.GetDeploymentGroupRequest.pb( + config.GetDeploymentGroupRequest() ) transcode.return_value = { "method": "post", @@ -22862,21 +30093,19 @@ def test_export_preview_result_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ExportPreviewResultResponse.to_json( - config.ExportPreviewResultResponse() - ) + return_value = config.DeploymentGroup.to_json(config.DeploymentGroup()) req.return_value.content = return_value - request = config.ExportPreviewResultRequest() + request = config.GetDeploymentGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ExportPreviewResultResponse() - post_with_metadata.return_value = config.ExportPreviewResultResponse(), metadata + post.return_value = config.DeploymentGroup() + post_with_metadata.return_value = config.DeploymentGroup(), metadata - client.export_preview_result( + client.get_deployment_group( request, metadata=[ ("key", "val"), @@ -22889,76 +30118,163 @@ def test_export_preview_result_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_list_terraform_versions_rest_bad_request( - request_type=config.ListTerraformVersionsRequest, -): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request = request_type(**request_init) +def test_create_deployment_group_rest_bad_request( + request_type=config.CreateDeploymentGroupRequest, +): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with ( + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_deployment_group(request) + + +@pytest.mark.parametrize( + "request_type", + [ + config.CreateDeploymentGroupRequest, + dict, + ], +) +def test_create_deployment_group_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["deployment_group"] = { + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "annotations": {}, + "state": 1, + "state_description": "state_description_value", + "deployment_units": [ + { + "id": "id_value", + "deployment": "deployment_value", + "dependencies": ["dependencies_value1", "dependencies_value2"], + } + ], + "provisioning_state": 1, + "provisioning_state_description": "provisioning_state_description_value", + "provisioning_error": { + "code": 411, + "message": "message_value", + "details": [ + { + "type_url": "type.googleapis.com/google.protobuf.Duration", + "value": b"\x08\x0c\x10\xdb\x07", + } + ], + }, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = config.CreateDeploymentGroupRequest.meta.fields["deployment_group"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] - # Mock the http request call within the method and fake a BadRequest error. - with ( - mock.patch.object(Session, "request") as req, - pytest.raises(core_exceptions.BadRequest), - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_terraform_versions(request) + subfields_not_in_runtime = [] + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["deployment_group"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value -@pytest.mark.parametrize( - "request_type", - [ - config.ListTerraformVersionsRequest, - dict, - ], -) -def test_list_terraform_versions_rest_call_success(request_type): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["deployment_group"][field])): + del request_init["deployment_group"][field][i][subfield] + else: + del request_init["deployment_group"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListTerraformVersionsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ListTerraformVersionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_terraform_versions(request) + response = client.create_deployment_group(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTerraformVersionsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_terraform_versions_rest_interceptors(null_interceptor): +def test_create_deployment_group_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -22968,22 +30284,23 @@ def test_list_terraform_versions_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_list_terraform_versions" + transports.ConfigRestInterceptor, "post_create_deployment_group" ) as post, mock.patch.object( transports.ConfigRestInterceptor, - "post_list_terraform_versions_with_metadata", + "post_create_deployment_group_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_list_terraform_versions" + transports.ConfigRestInterceptor, "pre_create_deployment_group" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ListTerraformVersionsRequest.pb( - config.ListTerraformVersionsRequest() + pb_message = config.CreateDeploymentGroupRequest.pb( + config.CreateDeploymentGroupRequest() ) transcode.return_value = { "method": "post", @@ -22995,24 +30312,19 @@ def test_list_terraform_versions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ListTerraformVersionsResponse.to_json( - config.ListTerraformVersionsResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.ListTerraformVersionsRequest() + request = config.CreateDeploymentGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ListTerraformVersionsResponse() - post_with_metadata.return_value = ( - config.ListTerraformVersionsResponse(), - metadata, - ) + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.list_terraform_versions( + client.create_deployment_group( request, metadata=[ ("key", "val"), @@ -23025,15 +30337,17 @@ def test_list_terraform_versions_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_terraform_version_rest_bad_request( - request_type=config.GetTerraformVersionRequest, +def test_update_deployment_group_rest_bad_request( + request_type=config.UpdateDeploymentGroupRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/terraformVersions/sample3" + "deployment_group": { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } } request = request_type(**request_init) @@ -23050,55 +30364,144 @@ def test_get_terraform_version_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_terraform_version(request) + client.update_deployment_group(request) @pytest.mark.parametrize( "request_type", [ - config.GetTerraformVersionRequest, + config.UpdateDeploymentGroupRequest, dict, ], ) -def test_get_terraform_version_rest_call_success(request_type): +def test_update_deployment_group_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/terraformVersions/sample3" + "deployment_group": { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } + } + request_init["deployment_group"] = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "annotations": {}, + "state": 1, + "state_description": "state_description_value", + "deployment_units": [ + { + "id": "id_value", + "deployment": "deployment_value", + "dependencies": ["dependencies_value1", "dependencies_value2"], + } + ], + "provisioning_state": 1, + "provisioning_state_description": "provisioning_state_description_value", + "provisioning_error": { + "code": 411, + "message": "message_value", + "details": [ + { + "type_url": "type.googleapis.com/google.protobuf.Duration", + "value": b"\x08\x0c\x10\xdb\x07", + } + ], + }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = config.UpdateDeploymentGroupRequest.meta.fields["deployment_group"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["deployment_group"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["deployment_group"][field])): + del request_init["deployment_group"][field][i][subfield] + else: + del request_init["deployment_group"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.TerraformVersion( - name="name_value", - state=config.TerraformVersion.State.ACTIVE, - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.TerraformVersion.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_terraform_version(request) + response = client.update_deployment_group(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.TerraformVersion) - assert response.name == "name_value" - assert response.state == config.TerraformVersion.State.ACTIVE + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_terraform_version_rest_interceptors(null_interceptor): +def test_update_deployment_group_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -23108,21 +30511,23 @@ def test_get_terraform_version_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_get_terraform_version" + transports.ConfigRestInterceptor, "post_update_deployment_group" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_terraform_version_with_metadata" + transports.ConfigRestInterceptor, + "post_update_deployment_group_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_get_terraform_version" + transports.ConfigRestInterceptor, "pre_update_deployment_group" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.GetTerraformVersionRequest.pb( - config.GetTerraformVersionRequest() + pb_message = config.UpdateDeploymentGroupRequest.pb( + config.UpdateDeploymentGroupRequest() ) transcode.return_value = { "method": "post", @@ -23134,19 +30539,19 @@ def test_get_terraform_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.TerraformVersion.to_json(config.TerraformVersion()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.GetTerraformVersionRequest() + request = config.UpdateDeploymentGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.TerraformVersion() - post_with_metadata.return_value = config.TerraformVersion(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.get_terraform_version( + client.update_deployment_group( request, metadata=[ ("key", "val"), @@ -23159,14 +30564,16 @@ def test_get_terraform_version_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_list_resource_changes_rest_bad_request( - request_type=config.ListResourceChangesRequest, +def test_delete_deployment_group_rest_bad_request( + request_type=config.DeleteDeploymentGroupRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23182,53 +30589,47 @@ def test_list_resource_changes_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_resource_changes(request) + client.delete_deployment_group(request) @pytest.mark.parametrize( "request_type", [ - config.ListResourceChangesRequest, + config.DeleteDeploymentGroupRequest, dict, ], ) -def test_list_resource_changes_rest_call_success(request_type): +def test_delete_deployment_group_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListResourceChangesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ListResourceChangesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_resource_changes(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListResourceChangesPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + response = client.delete_deployment_group(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_resource_changes_rest_interceptors(null_interceptor): +def test_delete_deployment_group_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -23238,21 +30639,23 @@ def test_list_resource_changes_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_list_resource_changes" + transports.ConfigRestInterceptor, "post_delete_deployment_group" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_list_resource_changes_with_metadata" + transports.ConfigRestInterceptor, + "post_delete_deployment_group_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_list_resource_changes" + transports.ConfigRestInterceptor, "pre_delete_deployment_group" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ListResourceChangesRequest.pb( - config.ListResourceChangesRequest() + pb_message = config.DeleteDeploymentGroupRequest.pb( + config.DeleteDeploymentGroupRequest() ) transcode.return_value = { "method": "post", @@ -23264,21 +30667,19 @@ def test_list_resource_changes_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ListResourceChangesResponse.to_json( - config.ListResourceChangesResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.ListResourceChangesRequest() + request = config.DeleteDeploymentGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ListResourceChangesResponse() - post_with_metadata.return_value = config.ListResourceChangesResponse(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.list_resource_changes( + client.delete_deployment_group( request, metadata=[ ("key", "val"), @@ -23291,16 +30692,14 @@ def test_list_resource_changes_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_resource_change_rest_bad_request( - request_type=config.GetResourceChangeRequest, +def test_list_deployment_groups_rest_bad_request( + request_type=config.ListDeploymentGroupsRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/previews/sample3/resourceChanges/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23316,33 +30715,31 @@ def test_get_resource_change_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_resource_change(request) + client.list_deployment_groups(request) @pytest.mark.parametrize( "request_type", [ - config.GetResourceChangeRequest, + config.ListDeploymentGroupsRequest, dict, ], ) -def test_get_resource_change_rest_call_success(request_type): +def test_list_deployment_groups_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/previews/sample3/resourceChanges/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ResourceChange( - name="name_value", - intent=config.ResourceChange.Intent.CREATE, + return_value = config.ListDeploymentGroupsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) # Wrap the value into a proper Response obj @@ -23350,21 +30747,21 @@ def test_get_resource_change_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.ResourceChange.pb(return_value) + return_value = config.ListDeploymentGroupsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_resource_change(request) + response = client.list_deployment_groups(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.ResourceChange) - assert response.name == "name_value" - assert response.intent == config.ResourceChange.Intent.CREATE + assert isinstance(response, pagers.ListDeploymentGroupsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_resource_change_rest_interceptors(null_interceptor): +def test_list_deployment_groups_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -23375,20 +30772,21 @@ def test_get_resource_change_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_resource_change" + transports.ConfigRestInterceptor, "post_list_deployment_groups" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_resource_change_with_metadata" + transports.ConfigRestInterceptor, + "post_list_deployment_groups_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_get_resource_change" + transports.ConfigRestInterceptor, "pre_list_deployment_groups" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.GetResourceChangeRequest.pb( - config.GetResourceChangeRequest() + pb_message = config.ListDeploymentGroupsRequest.pb( + config.ListDeploymentGroupsRequest() ) transcode.return_value = { "method": "post", @@ -23400,19 +30798,24 @@ def test_get_resource_change_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ResourceChange.to_json(config.ResourceChange()) + return_value = config.ListDeploymentGroupsResponse.to_json( + config.ListDeploymentGroupsResponse() + ) req.return_value.content = return_value - request = config.GetResourceChangeRequest() + request = config.ListDeploymentGroupsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ResourceChange() - post_with_metadata.return_value = config.ResourceChange(), metadata + post.return_value = config.ListDeploymentGroupsResponse() + post_with_metadata.return_value = ( + config.ListDeploymentGroupsResponse(), + metadata, + ) - client.get_resource_change( + client.list_deployment_groups( request, metadata=[ ("key", "val"), @@ -23425,14 +30828,16 @@ def test_get_resource_change_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_list_resource_drifts_rest_bad_request( - request_type=config.ListResourceDriftsRequest, +def test_provision_deployment_group_rest_bad_request( + request_type=config.ProvisionDeploymentGroupRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23448,53 +30853,47 @@ def test_list_resource_drifts_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_resource_drifts(request) + client.provision_deployment_group(request) @pytest.mark.parametrize( "request_type", [ - config.ListResourceDriftsRequest, + config.ProvisionDeploymentGroupRequest, dict, ], ) -def test_list_resource_drifts_rest_call_success(request_type): +def test_provision_deployment_group_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/previews/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ListResourceDriftsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ListResourceDriftsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_resource_drifts(request) + response = client.provision_deployment_group(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListResourceDriftsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_resource_drifts_rest_interceptors(null_interceptor): +def test_provision_deployment_group_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -23504,21 +30903,23 @@ def test_list_resource_drifts_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_list_resource_drifts" + transports.ConfigRestInterceptor, "post_provision_deployment_group" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_list_resource_drifts_with_metadata" + transports.ConfigRestInterceptor, + "post_provision_deployment_group_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_list_resource_drifts" + transports.ConfigRestInterceptor, "pre_provision_deployment_group" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.ListResourceDriftsRequest.pb( - config.ListResourceDriftsRequest() + pb_message = config.ProvisionDeploymentGroupRequest.pb( + config.ProvisionDeploymentGroupRequest() ) transcode.return_value = { "method": "post", @@ -23530,21 +30931,19 @@ def test_list_resource_drifts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ListResourceDriftsResponse.to_json( - config.ListResourceDriftsResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.ListResourceDriftsRequest() + request = config.ProvisionDeploymentGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ListResourceDriftsResponse() - post_with_metadata.return_value = config.ListResourceDriftsResponse(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.list_resource_drifts( + client.provision_deployment_group( request, metadata=[ ("key", "val"), @@ -23557,15 +30956,15 @@ def test_list_resource_drifts_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_resource_drift_rest_bad_request( - request_type=config.GetResourceDriftRequest, +def test_deprovision_deployment_group_rest_bad_request( + request_type=config.DeprovisionDeploymentGroupRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/previews/sample3/resourceDrifts/sample4" + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" } request = request_type(**request_init) @@ -23582,53 +30981,47 @@ def test_get_resource_drift_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_resource_drift(request) + client.deprovision_deployment_group(request) @pytest.mark.parametrize( "request_type", [ - config.GetResourceDriftRequest, + config.DeprovisionDeploymentGroupRequest, dict, ], ) -def test_get_resource_drift_rest_call_success(request_type): +def test_deprovision_deployment_group_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/previews/sample3/resourceDrifts/sample4" + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.ResourceDrift( - name="name_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = config.ResourceDrift.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_resource_drift(request) + response = client.deprovision_deployment_group(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.ResourceDrift) - assert response.name == "name_value" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_resource_drift_rest_interceptors(null_interceptor): +def test_deprovision_deployment_group_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -23638,20 +31031,24 @@ def test_get_resource_drift_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, + mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_get_resource_drift" + transports.ConfigRestInterceptor, "post_deprovision_deployment_group" ) as post, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_resource_drift_with_metadata" + transports.ConfigRestInterceptor, + "post_deprovision_deployment_group_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_get_resource_drift" + transports.ConfigRestInterceptor, "pre_deprovision_deployment_group" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.GetResourceDriftRequest.pb(config.GetResourceDriftRequest()) + pb_message = config.DeprovisionDeploymentGroupRequest.pb( + config.DeprovisionDeploymentGroupRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -23662,19 +31059,19 @@ def test_get_resource_drift_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.ResourceDrift.to_json(config.ResourceDrift()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = config.GetResourceDriftRequest() + request = config.DeprovisionDeploymentGroupRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.ResourceDrift() - post_with_metadata.return_value = config.ResourceDrift(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.get_resource_drift( + client.deprovision_deployment_group( request, metadata=[ ("key", "val"), @@ -23687,14 +31084,16 @@ def test_get_resource_drift_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_auto_migration_config_rest_bad_request( - request_type=config.GetAutoMigrationConfigRequest, +def test_get_deployment_group_revision_rest_bad_request( + request_type=config.GetDeploymentGroupRevisionRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/autoMigrationConfig"} + request_init = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23710,31 +31109,33 @@ def test_get_auto_migration_config_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_auto_migration_config(request) + client.get_deployment_group_revision(request) @pytest.mark.parametrize( "request_type", [ - config.GetAutoMigrationConfigRequest, + config.GetDeploymentGroupRevisionRequest, dict, ], ) -def test_get_auto_migration_config_rest_call_success(request_type): +def test_get_deployment_group_revision_rest_call_success(request_type): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/autoMigrationConfig"} + request_init = { + "name": "projects/sample1/locations/sample2/deploymentGroups/sample3/revisions/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = config.AutoMigrationConfig( + return_value = config.DeploymentGroupRevision( name="name_value", - auto_migration_enabled=True, + alternative_ids=["alternative_ids_value"], ) # Wrap the value into a proper Response obj @@ -23742,21 +31143,21 @@ def test_get_auto_migration_config_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = config.AutoMigrationConfig.pb(return_value) + return_value = config.DeploymentGroupRevision.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_auto_migration_config(request) + response = client.get_deployment_group_revision(request) # Establish that the response is the type that we expect. - assert isinstance(response, config.AutoMigrationConfig) + assert isinstance(response, config.DeploymentGroupRevision) assert response.name == "name_value" - assert response.auto_migration_enabled is True + assert response.alternative_ids == ["alternative_ids_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_auto_migration_config_rest_interceptors(null_interceptor): +def test_get_deployment_group_revision_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -23767,21 +31168,21 @@ def test_get_auto_migration_config_rest_interceptors(null_interceptor): mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, mock.patch.object( - transports.ConfigRestInterceptor, "post_get_auto_migration_config" + transports.ConfigRestInterceptor, "post_get_deployment_group_revision" ) as post, mock.patch.object( transports.ConfigRestInterceptor, - "post_get_auto_migration_config_with_metadata", + "post_get_deployment_group_revision_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_get_auto_migration_config" + transports.ConfigRestInterceptor, "pre_get_deployment_group_revision" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.GetAutoMigrationConfigRequest.pb( - config.GetAutoMigrationConfigRequest() + pb_message = config.GetDeploymentGroupRevisionRequest.pb( + config.GetDeploymentGroupRevisionRequest() ) transcode.return_value = { "method": "post", @@ -23793,19 +31194,21 @@ def test_get_auto_migration_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = config.AutoMigrationConfig.to_json(config.AutoMigrationConfig()) + return_value = config.DeploymentGroupRevision.to_json( + config.DeploymentGroupRevision() + ) req.return_value.content = return_value - request = config.GetAutoMigrationConfigRequest() + request = config.GetDeploymentGroupRevisionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = config.AutoMigrationConfig() - post_with_metadata.return_value = config.AutoMigrationConfig(), metadata + post.return_value = config.DeploymentGroupRevision() + post_with_metadata.return_value = config.DeploymentGroupRevision(), metadata - client.get_auto_migration_config( + client.get_deployment_group_revision( request, metadata=[ ("key", "val"), @@ -23818,152 +31221,80 @@ def test_get_auto_migration_config_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_update_auto_migration_config_rest_bad_request( - request_type=config.UpdateAutoMigrationConfigRequest, +def test_list_deployment_group_revisions_rest_bad_request( + request_type=config.ListDeploymentGroupRevisionsRequest, ): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "auto_migration_config": { - "name": "projects/sample1/locations/sample2/autoMigrationConfig" - } + "parent": "projects/sample1/locations/sample2/deploymentGroups/sample3" } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. with ( - mock.patch.object(Session, "request") as req, - pytest.raises(core_exceptions.BadRequest), - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_auto_migration_config(request) - - -@pytest.mark.parametrize( - "request_type", - [ - config.UpdateAutoMigrationConfigRequest, - dict, - ], -) -def test_update_auto_migration_config_rest_call_success(request_type): - client = ConfigClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = { - "auto_migration_config": { - "name": "projects/sample1/locations/sample2/autoMigrationConfig" - } - } - request_init["auto_migration_config"] = { - "name": "projects/sample1/locations/sample2/autoMigrationConfig", - "update_time": {"seconds": 751, "nanos": 543}, - "auto_migration_enabled": True, - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = config.UpdateAutoMigrationConfigRequest.meta.fields[ - "auto_migration_config" - ] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init[ - "auto_migration_config" - ].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value + mock.patch.object(Session, "request") as req, + pytest.raises(core_exceptions.BadRequest), + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_deployment_group_revisions(request) - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["auto_migration_config"][field])): - del request_init["auto_migration_config"][field][i][subfield] - else: - del request_init["auto_migration_config"][field][subfield] +@pytest.mark.parametrize( + "request_type", + [ + config.ListDeploymentGroupRevisionsRequest, + dict, + ], +) +def test_list_deployment_group_revisions_rest_call_success(request_type): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/deploymentGroups/sample3" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = config.ListDeploymentGroupRevisionsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = config.ListDeploymentGroupRevisionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_auto_migration_config(request) + response = client.list_deployment_group_revisions(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, pagers.ListDeploymentGroupRevisionsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_auto_migration_config_rest_interceptors(null_interceptor): +def test_list_deployment_group_revisions_rest_interceptors(null_interceptor): transport = transports.ConfigRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None if null_interceptor else transports.ConfigRestInterceptor(), @@ -23973,23 +31304,22 @@ def test_update_auto_migration_config_rest_interceptors(null_interceptor): with ( mock.patch.object(type(client.transport._session), "request") as req, mock.patch.object(path_template, "transcode") as transcode, - mock.patch.object(operation.Operation, "_set_result_from_operation"), mock.patch.object( - transports.ConfigRestInterceptor, "post_update_auto_migration_config" + transports.ConfigRestInterceptor, "post_list_deployment_group_revisions" ) as post, mock.patch.object( transports.ConfigRestInterceptor, - "post_update_auto_migration_config_with_metadata", + "post_list_deployment_group_revisions_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.ConfigRestInterceptor, "pre_update_auto_migration_config" + transports.ConfigRestInterceptor, "pre_list_deployment_group_revisions" ) as pre, ): pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = config.UpdateAutoMigrationConfigRequest.pb( - config.UpdateAutoMigrationConfigRequest() + pb_message = config.ListDeploymentGroupRevisionsRequest.pb( + config.ListDeploymentGroupRevisionsRequest() ) transcode.return_value = { "method": "post", @@ -24001,19 +31331,24 @@ def test_update_auto_migration_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = config.ListDeploymentGroupRevisionsResponse.to_json( + config.ListDeploymentGroupRevisionsResponse() + ) req.return_value.content = return_value - request = config.UpdateAutoMigrationConfigRequest() + request = config.ListDeploymentGroupRevisionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + post.return_value = config.ListDeploymentGroupRevisionsResponse() + post_with_metadata.return_value = ( + config.ListDeploymentGroupRevisionsResponse(), + metadata, + ) - client.update_auto_migration_config( + client.list_deployment_group_revisions( request, metadata=[ ("key", "val"), @@ -24763,138 +32098,326 @@ def test_get_resource_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceRequest() + request_msg = config.GetResourceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_resources_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_resources), "__call__") as call: + client.list_resources(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ListResourcesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_deployment_statefile_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_deployment_statefile), "__call__" + ) as call: + client.export_deployment_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportDeploymentStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_revision_statefile_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_revision_statefile), "__call__" + ) as call: + client.export_revision_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportRevisionStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_import_statefile_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.import_statefile), "__call__") as call: + client.import_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ImportStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_statefile_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_statefile), "__call__") as call: + client.delete_statefile(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.DeleteStatefileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_lock_deployment_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.lock_deployment), "__call__") as call: + client.lock_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.LockDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_unlock_deployment_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.unlock_deployment), "__call__" + ) as call: + client.unlock_deployment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.UnlockDeploymentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_export_lock_info_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.export_lock_info), "__call__") as call: + client.export_lock_info(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.ExportLockInfoRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_preview_empty_call_rest(): + client = ConfigClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_preview), "__call__") as call: + client.create_preview(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = config.CreatePreviewRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_resources_empty_call_rest(): +def test_get_preview_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_resources), "__call__") as call: - client.list_resources(request=None) + with mock.patch.object(type(client.transport.get_preview), "__call__") as call: + client.get_preview(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ListResourcesRequest() + request_msg = config.GetPreviewRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_export_deployment_statefile_empty_call_rest(): +def test_list_previews_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_deployment_statefile), "__call__" - ) as call: - client.export_deployment_statefile(request=None) + with mock.patch.object(type(client.transport.list_previews), "__call__") as call: + client.list_previews(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ExportDeploymentStatefileRequest() + request_msg = config.ListPreviewsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_export_revision_statefile_empty_call_rest(): +def test_delete_preview_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.export_revision_statefile), "__call__" - ) as call: - client.export_revision_statefile(request=None) + with mock.patch.object(type(client.transport.delete_preview), "__call__") as call: + client.delete_preview(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ExportRevisionStatefileRequest() + request_msg = config.DeletePreviewRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_import_statefile_empty_call_rest(): +def test_export_preview_result_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.import_statefile), "__call__") as call: - client.import_statefile(request=None) + with mock.patch.object( + type(client.transport.export_preview_result), "__call__" + ) as call: + client.export_preview_result(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ImportStatefileRequest() + request_msg = config.ExportPreviewResultRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_statefile_empty_call_rest(): +def test_list_terraform_versions_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_statefile), "__call__") as call: - client.delete_statefile(request=None) + with mock.patch.object( + type(client.transport.list_terraform_versions), "__call__" + ) as call: + client.list_terraform_versions(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.DeleteStatefileRequest() + request_msg = config.ListTerraformVersionsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_lock_deployment_empty_call_rest(): +def test_get_terraform_version_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.lock_deployment), "__call__") as call: - client.lock_deployment(request=None) + with mock.patch.object( + type(client.transport.get_terraform_version), "__call__" + ) as call: + client.get_terraform_version(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.LockDeploymentRequest() + request_msg = config.GetTerraformVersionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_unlock_deployment_empty_call_rest(): +def test_list_resource_changes_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -24902,121 +32425,131 @@ def test_unlock_deployment_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.unlock_deployment), "__call__" + type(client.transport.list_resource_changes), "__call__" ) as call: - client.unlock_deployment(request=None) + client.list_resource_changes(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.UnlockDeploymentRequest() + request_msg = config.ListResourceChangesRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_export_lock_info_empty_call_rest(): +def test_get_resource_change_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.export_lock_info), "__call__") as call: - client.export_lock_info(request=None) + with mock.patch.object( + type(client.transport.get_resource_change), "__call__" + ) as call: + client.get_resource_change(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ExportLockInfoRequest() + request_msg = config.GetResourceChangeRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_preview_empty_call_rest(): +def test_list_resource_drifts_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_preview), "__call__") as call: - client.create_preview(request=None) + with mock.patch.object( + type(client.transport.list_resource_drifts), "__call__" + ) as call: + client.list_resource_drifts(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.CreatePreviewRequest() + request_msg = config.ListResourceDriftsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_preview_empty_call_rest(): +def test_get_resource_drift_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_preview), "__call__") as call: - client.get_preview(request=None) + with mock.patch.object( + type(client.transport.get_resource_drift), "__call__" + ) as call: + client.get_resource_drift(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.GetPreviewRequest() + request_msg = config.GetResourceDriftRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_previews_empty_call_rest(): +def test_get_auto_migration_config_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_previews), "__call__") as call: - client.list_previews(request=None) + with mock.patch.object( + type(client.transport.get_auto_migration_config), "__call__" + ) as call: + client.get_auto_migration_config(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ListPreviewsRequest() + request_msg = config.GetAutoMigrationConfigRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_preview_empty_call_rest(): +def test_update_auto_migration_config_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_preview), "__call__") as call: - client.delete_preview(request=None) + with mock.patch.object( + type(client.transport.update_auto_migration_config), "__call__" + ) as call: + client.update_auto_migration_config(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.DeletePreviewRequest() + request_msg = config.UpdateAutoMigrationConfigRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_export_preview_result_empty_call_rest(): +def test_get_deployment_group_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25024,21 +32557,21 @@ def test_export_preview_result_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.export_preview_result), "__call__" + type(client.transport.get_deployment_group), "__call__" ) as call: - client.export_preview_result(request=None) + client.get_deployment_group(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ExportPreviewResultRequest() + request_msg = config.GetDeploymentGroupRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_terraform_versions_empty_call_rest(): +def test_create_deployment_group_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25046,21 +32579,21 @@ def test_list_terraform_versions_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_terraform_versions), "__call__" + type(client.transport.create_deployment_group), "__call__" ) as call: - client.list_terraform_versions(request=None) + client.create_deployment_group(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ListTerraformVersionsRequest() + request_msg = config.CreateDeploymentGroupRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_terraform_version_empty_call_rest(): +def test_update_deployment_group_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25068,21 +32601,21 @@ def test_get_terraform_version_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_terraform_version), "__call__" + type(client.transport.update_deployment_group), "__call__" ) as call: - client.get_terraform_version(request=None) + client.update_deployment_group(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.GetTerraformVersionRequest() + request_msg = config.UpdateDeploymentGroupRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_resource_changes_empty_call_rest(): +def test_delete_deployment_group_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25090,21 +32623,21 @@ def test_list_resource_changes_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_resource_changes), "__call__" + type(client.transport.delete_deployment_group), "__call__" ) as call: - client.list_resource_changes(request=None) + client.delete_deployment_group(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ListResourceChangesRequest() + request_msg = config.DeleteDeploymentGroupRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_resource_change_empty_call_rest(): +def test_list_deployment_groups_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25112,21 +32645,21 @@ def test_get_resource_change_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_resource_change), "__call__" + type(client.transport.list_deployment_groups), "__call__" ) as call: - client.get_resource_change(request=None) + client.list_deployment_groups(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceChangeRequest() + request_msg = config.ListDeploymentGroupsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_resource_drifts_empty_call_rest(): +def test_provision_deployment_group_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25134,21 +32667,21 @@ def test_list_resource_drifts_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_resource_drifts), "__call__" + type(client.transport.provision_deployment_group), "__call__" ) as call: - client.list_resource_drifts(request=None) + client.provision_deployment_group(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.ListResourceDriftsRequest() + request_msg = config.ProvisionDeploymentGroupRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_resource_drift_empty_call_rest(): +def test_deprovision_deployment_group_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25156,21 +32689,21 @@ def test_get_resource_drift_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_resource_drift), "__call__" + type(client.transport.deprovision_deployment_group), "__call__" ) as call: - client.get_resource_drift(request=None) + client.deprovision_deployment_group(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.GetResourceDriftRequest() + request_msg = config.DeprovisionDeploymentGroupRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_auto_migration_config_empty_call_rest(): +def test_get_deployment_group_revision_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25178,21 +32711,21 @@ def test_get_auto_migration_config_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_auto_migration_config), "__call__" + type(client.transport.get_deployment_group_revision), "__call__" ) as call: - client.get_auto_migration_config(request=None) + client.get_deployment_group_revision(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.GetAutoMigrationConfigRequest() + request_msg = config.GetDeploymentGroupRevisionRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_update_auto_migration_config_empty_call_rest(): +def test_list_deployment_group_revisions_empty_call_rest(): client = ConfigClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -25200,14 +32733,14 @@ def test_update_auto_migration_config_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.update_auto_migration_config), "__call__" + type(client.transport.list_deployment_group_revisions), "__call__" ) as call: - client.update_auto_migration_config(request=None) + client.list_deployment_group_revisions(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = config.UpdateAutoMigrationConfigRequest() + request_msg = config.ListDeploymentGroupRevisionsRequest() assert args[0] == request_msg @@ -25291,6 +32824,15 @@ def test_config_base_transport(): "get_resource_drift", "get_auto_migration_config", "update_auto_migration_config", + "get_deployment_group", + "create_deployment_group", + "update_deployment_group", + "delete_deployment_group", + "list_deployment_groups", + "provision_deployment_group", + "deprovision_deployment_group", + "get_deployment_group_revision", + "list_deployment_group_revisions", "set_iam_policy", "get_iam_policy", "test_iam_permissions", @@ -25654,6 +33196,33 @@ def test_config_client_transport_session_collision(transport_name): session1 = client1.transport.update_auto_migration_config._session session2 = client2.transport.update_auto_migration_config._session assert session1 != session2 + session1 = client1.transport.get_deployment_group._session + session2 = client2.transport.get_deployment_group._session + assert session1 != session2 + session1 = client1.transport.create_deployment_group._session + session2 = client2.transport.create_deployment_group._session + assert session1 != session2 + session1 = client1.transport.update_deployment_group._session + session2 = client2.transport.update_deployment_group._session + assert session1 != session2 + session1 = client1.transport.delete_deployment_group._session + session2 = client2.transport.delete_deployment_group._session + assert session1 != session2 + session1 = client1.transport.list_deployment_groups._session + session2 = client2.transport.list_deployment_groups._session + assert session1 != session2 + session1 = client1.transport.provision_deployment_group._session + session2 = client2.transport.provision_deployment_group._session + assert session1 != session2 + session1 = client1.transport.deprovision_deployment_group._session + session2 = client2.transport.deprovision_deployment_group._session + assert session1 != session2 + session1 = client1.transport.get_deployment_group_revision._session + session2 = client2.transport.get_deployment_group_revision._session + assert session1 != session2 + session1 = client1.transport.list_deployment_group_revisions._session + session2 = client2.transport.list_deployment_group_revisions._session + assert session1 != session2 def test_config_grpc_transport_channel(): @@ -25860,10 +33429,67 @@ def test_parse_deployment_path(): assert expected == actual -def test_preview_path(): +def test_deployment_group_path(): project = "scallop" location = "abalone" - preview = "squid" + deployment_group = "squid" + expected = "projects/{project}/locations/{location}/deploymentGroups/{deployment_group}".format( + project=project, + location=location, + deployment_group=deployment_group, + ) + actual = ConfigClient.deployment_group_path(project, location, deployment_group) + assert expected == actual + + +def test_parse_deployment_group_path(): + expected = { + "project": "clam", + "location": "whelk", + "deployment_group": "octopus", + } + path = ConfigClient.deployment_group_path(**expected) + + # Check that the path construction is reversible. + actual = ConfigClient.parse_deployment_group_path(path) + assert expected == actual + + +def test_deployment_group_revision_path(): + project = "oyster" + location = "nudibranch" + deployment_group = "cuttlefish" + revision = "mussel" + expected = "projects/{project}/locations/{location}/deploymentGroups/{deployment_group}/revisions/{revision}".format( + project=project, + location=location, + deployment_group=deployment_group, + revision=revision, + ) + actual = ConfigClient.deployment_group_revision_path( + project, location, deployment_group, revision + ) + assert expected == actual + + +def test_parse_deployment_group_revision_path(): + expected = { + "project": "winkle", + "location": "nautilus", + "deployment_group": "scallop", + "revision": "abalone", + } + path = ConfigClient.deployment_group_revision_path(**expected) + + # Check that the path construction is reversible. + actual = ConfigClient.parse_deployment_group_revision_path(path) + assert expected == actual + + +def test_preview_path(): + project = "squid" + location = "clam" + preview = "whelk" expected = "projects/{project}/locations/{location}/previews/{preview}".format( project=project, location=location, @@ -25875,9 +33501,9 @@ def test_preview_path(): def test_parse_preview_path(): expected = { - "project": "clam", - "location": "whelk", - "preview": "octopus", + "project": "octopus", + "location": "oyster", + "preview": "nudibranch", } path = ConfigClient.preview_path(**expected) @@ -25887,11 +33513,11 @@ def test_parse_preview_path(): def test_resource_path(): - project = "oyster" - location = "nudibranch" - deployment = "cuttlefish" - revision = "mussel" - resource = "winkle" + project = "cuttlefish" + location = "mussel" + deployment = "winkle" + revision = "nautilus" + resource = "scallop" expected = "projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision}/resources/{resource}".format( project=project, location=location, @@ -25907,11 +33533,11 @@ def test_resource_path(): def test_parse_resource_path(): expected = { - "project": "nautilus", - "location": "scallop", - "deployment": "abalone", - "revision": "squid", - "resource": "clam", + "project": "abalone", + "location": "squid", + "deployment": "clam", + "revision": "whelk", + "resource": "octopus", } path = ConfigClient.resource_path(**expected) @@ -25921,10 +33547,10 @@ def test_parse_resource_path(): def test_resource_change_path(): - project = "whelk" - location = "octopus" - preview = "oyster" - resource_change = "nudibranch" + project = "oyster" + location = "nudibranch" + preview = "cuttlefish" + resource_change = "mussel" expected = "projects/{project}/locations/{location}/previews/{preview}/resourceChanges/{resource_change}".format( project=project, location=location, @@ -25939,10 +33565,10 @@ def test_resource_change_path(): def test_parse_resource_change_path(): expected = { - "project": "cuttlefish", - "location": "mussel", - "preview": "winkle", - "resource_change": "nautilus", + "project": "winkle", + "location": "nautilus", + "preview": "scallop", + "resource_change": "abalone", } path = ConfigClient.resource_change_path(**expected) @@ -25952,10 +33578,10 @@ def test_parse_resource_change_path(): def test_resource_drift_path(): - project = "scallop" - location = "abalone" - preview = "squid" - resource_drift = "clam" + project = "squid" + location = "clam" + preview = "whelk" + resource_drift = "octopus" expected = "projects/{project}/locations/{location}/previews/{preview}/resourceDrifts/{resource_drift}".format( project=project, location=location, @@ -25970,10 +33596,10 @@ def test_resource_drift_path(): def test_parse_resource_drift_path(): expected = { - "project": "whelk", - "location": "octopus", - "preview": "oyster", - "resource_drift": "nudibranch", + "project": "oyster", + "location": "nudibranch", + "preview": "cuttlefish", + "resource_drift": "mussel", } path = ConfigClient.resource_drift_path(**expected) @@ -25983,10 +33609,10 @@ def test_parse_resource_drift_path(): def test_revision_path(): - project = "cuttlefish" - location = "mussel" - deployment = "winkle" - revision = "nautilus" + project = "winkle" + location = "nautilus" + deployment = "scallop" + revision = "abalone" expected = "projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision}".format( project=project, location=location, @@ -25999,10 +33625,10 @@ def test_revision_path(): def test_parse_revision_path(): expected = { - "project": "scallop", - "location": "abalone", - "deployment": "squid", - "revision": "clam", + "project": "squid", + "location": "clam", + "deployment": "whelk", + "revision": "octopus", } path = ConfigClient.revision_path(**expected) @@ -26012,8 +33638,8 @@ def test_parse_revision_path(): def test_service_account_path(): - project = "whelk" - service_account = "octopus" + project = "oyster" + service_account = "nudibranch" expected = "projects/{project}/serviceAccounts/{service_account}".format( project=project, service_account=service_account, @@ -26024,8 +33650,8 @@ def test_service_account_path(): def test_parse_service_account_path(): expected = { - "project": "oyster", - "service_account": "nudibranch", + "project": "cuttlefish", + "service_account": "mussel", } path = ConfigClient.service_account_path(**expected) @@ -26035,9 +33661,9 @@ def test_parse_service_account_path(): def test_terraform_version_path(): - project = "cuttlefish" - location = "mussel" - terraform_version = "winkle" + project = "winkle" + location = "nautilus" + terraform_version = "scallop" expected = "projects/{project}/locations/{location}/terraformVersions/{terraform_version}".format( project=project, location=location, @@ -26049,9 +33675,9 @@ def test_terraform_version_path(): def test_parse_terraform_version_path(): expected = { - "project": "nautilus", - "location": "scallop", - "terraform_version": "abalone", + "project": "abalone", + "location": "squid", + "terraform_version": "clam", } path = ConfigClient.terraform_version_path(**expected) @@ -26061,9 +33687,9 @@ def test_parse_terraform_version_path(): def test_worker_pool_path(): - project = "squid" - location = "clam" - worker_pool = "whelk" + project = "whelk" + location = "octopus" + worker_pool = "oyster" expected = ( "projects/{project}/locations/{location}/workerPools/{worker_pool}".format( project=project, @@ -26077,9 +33703,9 @@ def test_worker_pool_path(): def test_parse_worker_pool_path(): expected = { - "project": "octopus", - "location": "oyster", - "worker_pool": "nudibranch", + "project": "nudibranch", + "location": "cuttlefish", + "worker_pool": "mussel", } path = ConfigClient.worker_pool_path(**expected) @@ -26089,7 +33715,7 @@ def test_parse_worker_pool_path(): def test_common_billing_account_path(): - billing_account = "cuttlefish" + billing_account = "winkle" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -26099,7 +33725,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "mussel", + "billing_account": "nautilus", } path = ConfigClient.common_billing_account_path(**expected) @@ -26109,7 +33735,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "winkle" + folder = "scallop" expected = "folders/{folder}".format( folder=folder, ) @@ -26119,7 +33745,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nautilus", + "folder": "abalone", } path = ConfigClient.common_folder_path(**expected) @@ -26129,7 +33755,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "scallop" + organization = "squid" expected = "organizations/{organization}".format( organization=organization, ) @@ -26139,7 +33765,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "abalone", + "organization": "clam", } path = ConfigClient.common_organization_path(**expected) @@ -26149,7 +33775,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "squid" + project = "whelk" expected = "projects/{project}".format( project=project, ) @@ -26159,7 +33785,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "clam", + "project": "octopus", } path = ConfigClient.common_project_path(**expected) @@ -26169,8 +33795,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "whelk" - location = "octopus" + project = "oyster" + location = "nudibranch" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -26181,8 +33807,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "oyster", - "location": "nudibranch", + "project": "cuttlefish", + "location": "mussel", } path = ConfigClient.common_location_path(**expected)