diff --git a/.librarian/state.yaml b/.librarian/state.yaml index d166a80b00c0..e8e3015ea043 100644 --- a/.librarian/state.yaml +++ b/.librarian/state.yaml @@ -2,7 +2,7 @@ image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-li libraries: - id: google-cloud-dlp version: 3.32.0 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/privacy/dlp/v2 service_config: dlp_v2.yaml @@ -21,7 +21,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-eventarc version: 1.16.0 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/eventarc/v1 service_config: eventarc_v1.yaml @@ -40,7 +40,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-video-live-stream version: 1.13.0 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/video/livestream/v1 service_config: livestream_v1.yaml @@ -59,7 +59,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-ads-marketingplatform-admin version: 0.1.6 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/marketingplatform/admin/v1alpha service_config: marketingplatformadmin_v1alpha.yaml @@ -78,7 +78,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-ai-generativelanguage version: 0.7.0 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/ai/generativelanguage/v1 service_config: generativelanguage_v1.yaml @@ -105,7 +105,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-analytics-admin version: 0.25.0 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/analytics/admin/v1beta service_config: analyticsadmin_v1beta.yaml @@ -126,7 +126,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-analytics-data version: 0.18.19 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/analytics/data/v1alpha service_config: analyticsdata_v1alpha.yaml @@ -147,7 +147,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-ads-admanager version: 0.4.0 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/ads/admanager/v1 service_config: admanager_v1.yaml @@ -166,10 +166,10 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-card version: 0.1.8 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/apps/card/v1 - service_config: '' + service_config: "" source_roots: - packages/google-apps-card preserve_regex: @@ -186,7 +186,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-chat version: 0.2.9 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/chat/v1 service_config: chat_v1.yaml @@ -205,7 +205,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-events-subscriptions version: 0.2.2 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/apps/events/subscriptions/v1 service_config: workspaceevents_v1.yaml @@ -226,7 +226,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-meet version: 0.1.16 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/apps/meet/v2beta service_config: meet_v2beta.yaml @@ -247,22 +247,22 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-script-type version: 0.3.15 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/apps/script/type - service_config: '' + service_config: "" - path: google/apps/script/type/gmail - service_config: '' + service_config: "" - path: google/apps/script/type/docs - service_config: '' + service_config: "" - path: google/apps/script/type/drive - service_config: '' + service_config: "" - path: google/apps/script/type/sheets - service_config: '' + service_config: "" - path: google/apps/script/type/calendar - service_config: '' + service_config: "" - path: google/apps/script/type/slides - service_config: '' + service_config: "" source_roots: - packages/google-apps-script-type preserve_regex: @@ -285,7 +285,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-area120-tables version: 0.11.17 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/area120/tables/v1alpha1 service_config: area120tables_v1alpha1.yaml @@ -304,7 +304,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-access-approval version: 1.16.2 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/accessapproval/v1 service_config: accessapproval_v1.yaml @@ -323,7 +323,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-advisorynotifications version: 0.3.16 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/advisorynotifications/v1 service_config: advisorynotifications_v1.yaml @@ -342,7 +342,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-alloydb version: 0.4.9 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/alloydb/v1beta service_config: alloydb_v1beta.yaml @@ -365,7 +365,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-alloydb-connectors version: 0.1.11 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/alloydb/connectors/v1 service_config: connectors_v1.yaml @@ -389,7 +389,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-api-gateway version: 1.12.2 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/apigateway/v1 service_config: apigateway_v1.yaml @@ -408,7 +408,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-api-keys version: 0.5.17 - last_generated_commit: 329ace5e3712a2e37d6159d4dcd998d8c73f261e + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/api/apikeys/v2 service_config: apikeys_v2.yaml @@ -427,9 +427,10 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-apigee-connect version: 1.12.2 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/apigeeconnect/v1 + service_config: apigeeconnect_v1.yaml source_roots: - packages/google-cloud-apigee-connect preserve_regex: @@ -445,9 +446,10 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-apigee-registry version: 0.6.18 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/apigeeregistry/v1 + service_config: apigeeregistry_v1.yaml source_roots: - packages/google-cloud-apigee-registry preserve_regex: @@ -463,9 +465,10 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-appengine-admin version: 1.14.2 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/appengine/v1 + service_config: appengine_v1.yaml source_roots: - packages/google-cloud-appengine-admin preserve_regex: @@ -481,9 +484,10 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-appengine-logging version: 1.6.2 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/appengine/logging/v1 + service_config: "" source_roots: - packages/google-cloud-appengine-logging preserve_regex: @@ -500,9 +504,10 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-apphub version: 0.1.10 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/apphub/v1 + service_config: apphub_v1.yaml source_roots: - packages/google-cloud-apphub preserve_regex: @@ -518,10 +523,12 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-artifact-registry version: 1.16.1 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/devtools/artifactregistry/v1 + service_config: artifactregistry_v1.yaml - path: google/devtools/artifactregistry/v1beta2 + service_config: artifactregistry_v1beta2.yaml source_roots: - packages/google-cloud-artifact-registry preserve_regex: @@ -537,10 +544,12 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-automl version: 2.16.4 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/automl/v1beta1 + service_config: automl_v1beta1.yaml - path: google/cloud/automl/v1 + service_config: automl_v1.yaml source_roots: - packages/google-cloud-automl preserve_regex: @@ -561,9 +570,10 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-backupdr version: 0.2.5 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/backupdr/v1 + service_config: backupdr_v1.yaml source_roots: - packages/google-cloud-backupdr preserve_regex: @@ -579,9 +589,10 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-bare-metal-solution version: 1.10.3 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/baremetalsolution/v2 + service_config: baremetalsolution_v2.yaml source_roots: - packages/google-cloud-bare-metal-solution preserve_regex: @@ -597,10 +608,12 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-batch version: 0.17.37 - last_generated_commit: d300b151a973ce0425ae4ad07b3de957ca31bec6 + last_generated_commit: 8cd780626041ecd4666974fd0c4099f1ad1ca01a apis: - path: google/cloud/batch/v1alpha + service_config: batch_v1alpha.yaml - path: google/cloud/batch/v1 + service_config: batch_v1.yaml source_roots: - packages/google-cloud-batch preserve_regex: diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/async_client.py index 6cbd57878a89..dddd8e9b95d1 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/async_client.py @@ -91,6 +91,8 @@ class AlloyDBAdminAsyncClient: parse_connection_info_path = staticmethod( AlloyDBAdminClient.parse_connection_info_path ) + crypto_key_path = staticmethod(AlloyDBAdminClient.crypto_key_path) + parse_crypto_key_path = staticmethod(AlloyDBAdminClient.parse_crypto_key_path) crypto_key_version_path = staticmethod(AlloyDBAdminClient.crypto_key_version_path) parse_crypto_key_version_path = staticmethod( AlloyDBAdminClient.parse_crypto_key_version_path @@ -101,6 +103,10 @@ class AlloyDBAdminAsyncClient: parse_instance_path = staticmethod(AlloyDBAdminClient.parse_instance_path) network_path = staticmethod(AlloyDBAdminClient.network_path) parse_network_path = staticmethod(AlloyDBAdminClient.parse_network_path) + service_attachment_path = staticmethod(AlloyDBAdminClient.service_attachment_path) + parse_service_attachment_path = staticmethod( + AlloyDBAdminClient.parse_service_attachment_path + ) supported_database_flag_path = staticmethod( AlloyDBAdminClient.supported_database_flag_path ) @@ -1243,7 +1249,7 @@ async def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request @@ -5142,8 +5148,7 @@ async def sample_list_databases(): Args: request (Optional[Union[google.cloud.alloydb_v1.types.ListDatabasesRequest, dict]]): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. parent (:class:`str`): Required. Parent value for ListDatabasesRequest. @@ -5161,8 +5166,8 @@ async def sample_list_databases(): Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListDatabasesAsyncPager: - Message for response to listing - Databases. + Message for ListDatabases response. + Iterating over this object will yield results and resolve additional pages automatically. diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/client.py index db78adc65fcd..ed729794d70c 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/client.py @@ -272,6 +272,30 @@ def parse_connection_info_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def crypto_key_path( + project: str, + location: str, + key_ring: str, + crypto_key: str, + ) -> str: + """Returns a fully-qualified crypto_key string.""" + return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + + @staticmethod + def parse_crypto_key_path(path: str) -> Dict[str, str]: + """Parses a crypto_key path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def crypto_key_version_path( project: str, @@ -365,6 +389,28 @@ def parse_network_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def service_attachment_path( + project: str, + region: str, + service_attachment: str, + ) -> str: + """Returns a fully-qualified service_attachment string.""" + return "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}".format( + project=project, + region=region, + service_attachment=service_attachment, + ) + + @staticmethod + def parse_service_attachment_path(path: str) -> Dict[str, str]: + """Parses a service_attachment path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/regions/(?P.+?)/serviceAttachments/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def supported_database_flag_path( project: str, @@ -1808,7 +1854,7 @@ def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request @@ -5627,8 +5673,7 @@ def sample_list_databases(): Args: request (Union[google.cloud.alloydb_v1.types.ListDatabasesRequest, dict]): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. parent (str): Required. Parent value for ListDatabasesRequest. @@ -5646,8 +5691,8 @@ def sample_list_databases(): Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListDatabasesPager: - Message for response to listing - Databases. + Message for ListDatabases response. + Iterating over this object will yield results and resolve additional pages automatically. diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/rest.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/rest.py index b7e3da27a774..ba5276f9572b 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/rest.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/rest.py @@ -5985,8 +5985,7 @@ def __call__( Args: request (~.service.ListDatabasesRequest): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -5997,9 +5996,7 @@ def __call__( Returns: ~.service.ListDatabasesResponse: - Message for response to listing - Databases. - + Message for ListDatabases response. """ http_options = ( diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_dbcsql_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_dbcsql_admin/async_client.py index ce04112e1a4e..6ba3260e8da6 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_dbcsql_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_dbcsql_admin/async_client.py @@ -83,6 +83,8 @@ class AlloyDBCSQLAdminAsyncClient: parse_backup_path = staticmethod(AlloyDBCSQLAdminClient.parse_backup_path) cluster_path = staticmethod(AlloyDBCSQLAdminClient.cluster_path) parse_cluster_path = staticmethod(AlloyDBCSQLAdminClient.parse_cluster_path) + crypto_key_path = staticmethod(AlloyDBCSQLAdminClient.crypto_key_path) + parse_crypto_key_path = staticmethod(AlloyDBCSQLAdminClient.parse_crypto_key_path) crypto_key_version_path = staticmethod( AlloyDBCSQLAdminClient.crypto_key_version_path ) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_dbcsql_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_dbcsql_admin/client.py index e39d34d16463..1354a08970ee 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_dbcsql_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_dbcsql_admin/client.py @@ -246,6 +246,30 @@ def parse_cluster_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def crypto_key_path( + project: str, + location: str, + key_ring: str, + crypto_key: str, + ) -> str: + """Returns a fully-qualified crypto_key string.""" + return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + + @staticmethod + def parse_crypto_key_path(path: str) -> Dict[str, str]: + """Parses a crypto_key path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def crypto_key_version_path( project: str, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/types/resources.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/types/resources.py index d168894dc59d..497f8c73a573 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/types/resources.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/types/resources.py @@ -119,12 +119,15 @@ class DatabaseVersion(proto.Enum): The database version is Postgres 15. POSTGRES_16 (4): The database version is Postgres 16. + POSTGRES_17 (5): + The database version is Postgres 17. """ DATABASE_VERSION_UNSPECIFIED = 0 POSTGRES_13 = 1 POSTGRES_14 = 2 POSTGRES_15 = 3 POSTGRES_16 = 4 + POSTGRES_17 = 5 class SubscriptionType(proto.Enum): @@ -939,14 +942,9 @@ class State(proto.Enum): READY (1): The cluster is active and running. STOPPED (2): - The cluster is stopped. All instances in the - cluster are stopped. Customers can start a - stopped cluster at any point and all their - instances will come back to life with same names - and IP resources. In this state, customer pays - for storage. - Associated backups could also be present in a - stopped cluster. + This is unused. Even when all instances in + the cluster are stopped, the cluster remains in + READY state. EMPTY (3): The cluster is empty and has no associated resources. All instances, associated storage and @@ -1427,6 +1425,9 @@ class Instance(proto.Message): can/cannot be activated (for example, a read pool instance should be stopped before stopping primary etc.). Please refer to the API documentation for more details. + connection_pool_config (google.cloud.alloydb_v1.types.Instance.ConnectionPoolConfig): + Optional. The configuration for Managed + Connection Pool (MCP). """ class State(proto.Enum): @@ -1994,6 +1995,35 @@ class AuthorizedNetwork(proto.Message): number=5, ) + class ConnectionPoolConfig(proto.Message): + r"""Configuration for Managed Connection Pool (MCP). + + Attributes: + enabled (bool): + Optional. Whether to enable Managed + Connection Pool (MCP). + flags (MutableMapping[str, str]): + Optional. Connection Pool flags, as a list of + "key": "value" pairs. + pooler_count (int): + Output only. The number of running poolers + per instance. + """ + + enabled: bool = proto.Field( + proto.BOOL, + number=12, + ) + flags: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=13, + ) + pooler_count: int = proto.Field( + proto.INT32, + number=14, + ) + name: str = proto.Field( proto.STRING, number=1, @@ -2129,6 +2159,11 @@ class AuthorizedNetwork(proto.Message): number=35, enum=ActivationPolicy, ) + connection_pool_config: ConnectionPoolConfig = proto.Field( + proto.MESSAGE, + number=37, + message=ConnectionPoolConfig, + ) class ConnectionInfo(proto.Message): @@ -2729,19 +2764,31 @@ class UserType(proto.Enum): class Database(proto.Message): r"""Message describing Database object. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Identifier. Name of the resource in the form of ``projects/{project}/locations/{location}/clusters/{cluster}/databases/{database}``. charset (str): - Optional. Charset for the database. This field can contain - any PostgreSQL supported charset name. Example values - include "UTF8", "SQL_ASCII", etc. + Optional. Immutable. Charset for the database. This field + can contain any PostgreSQL supported charset name. Example + values include "UTF8", "SQL_ASCII", etc. collation (str): - Optional. Collation for the database. - Name of the custom or native collation for - postgres. Example values include "C", "POSIX", - etc + Optional. Immutable. lc_collate for the database. String + sort order. Example values include "C", "POSIX", etc. + character_type (str): + Optional. Immutable. lc_ctype for the database. Character + classification (What is a letter? The upper-case + equivalent?). Example values include "C", "POSIX", etc. + database_template (str): + Input only. Immutable. Template of the + database to be used for creating a new database. + is_template_database (bool): + Optional. Whether the database is a template + database. + + This field is a member of `oneof`_ ``_is_template_database``. """ name: str = proto.Field( @@ -2756,6 +2803,19 @@ class Database(proto.Message): proto.STRING, number=3, ) + character_type: str = proto.Field( + proto.STRING, + number=4, + ) + database_template: str = proto.Field( + proto.STRING, + number=6, + ) + is_template_database: bool = proto.Field( + proto.BOOL, + number=7, + optional=True, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/types/service.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/types/service.py index 33858f024591..47abef01327c 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/types/service.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/types/service.py @@ -2023,6 +2023,10 @@ class ExecuteSqlRequest(proto.Message): Required. SQL statement to execute on database. Any valid statement is permitted, including DDL, DML, DQL statements. + validate_only (bool): + Optional. If set, validates the sql statement + by performing syntax and semantic validation and + doesn't execute the query. """ password: str = proto.Field( @@ -2046,6 +2050,10 @@ class ExecuteSqlRequest(proto.Message): proto.STRING, number=4, ) + validate_only: bool = proto.Field( + proto.BOOL, + number=6, + ) class ExecuteSqlResponse(proto.Message): @@ -2747,8 +2755,50 @@ class StageStatus(proto.Message): Upgrade stage. state (google.cloud.alloydb_v1.types.UpgradeClusterResponse.Status): State of this stage. + schedule (google.cloud.alloydb_v1.types.UpgradeClusterStatus.StageStatus.StageSchedule): + Output only. Timing information for the stage + execution. """ + class StageSchedule(proto.Message): + r"""Timing information for the stage execution. + + Attributes: + estimated_start_time (google.protobuf.timestamp_pb2.Timestamp): + When the stage is expected to start. Set only + if the stage has not started yet. + actual_start_time (google.protobuf.timestamp_pb2.Timestamp): + Actual start time of the stage. Set only if + the stage has started. + estimated_end_time (google.protobuf.timestamp_pb2.Timestamp): + When the stage is expected to end. Set only + if the stage has not completed yet. + actual_end_time (google.protobuf.timestamp_pb2.Timestamp): + Actual end time of the stage. Set only if the + stage has completed. + """ + + estimated_start_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + actual_start_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + estimated_end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + actual_end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + read_pool_instances_upgrade: "UpgradeClusterStatus.ReadPoolInstancesUpgradeStageStatus" = proto.Field( proto.MESSAGE, number=11, @@ -2765,6 +2815,11 @@ class StageStatus(proto.Message): number=2, enum="UpgradeClusterResponse.Status", ) + schedule: "UpgradeClusterStatus.StageStatus.StageSchedule" = proto.Field( + proto.MESSAGE, + number=3, + message="UpgradeClusterStatus.StageStatus.StageSchedule", + ) class ReadPoolInstancesUpgradeStageStatus(proto.Message): r"""Read pool instances upgrade specific status. @@ -3102,7 +3157,7 @@ class DeleteUserRequest(proto.Message): class ListDatabasesRequest(proto.Message): - r"""Message for requesting list of Databases. + r"""Message for ListDatabases request. Attributes: parent (str): @@ -3143,11 +3198,11 @@ class ListDatabasesRequest(proto.Message): class ListDatabasesResponse(proto.Message): - r"""Message for response to listing Databases. + r"""Message for ListDatabases response. Attributes: databases (MutableSequence[google.cloud.alloydb_v1.types.Database]): - The list of databases + The list of databases. next_page_token (str): A token identifying the next page of results the server should return. If this field is diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/__init__.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/__init__.py index 0e19b602a91b..adf3b6ba1e0e 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/__init__.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/__init__.py @@ -64,6 +64,7 @@ BatchCreateInstanceStatus, CreateBackupRequest, CreateClusterRequest, + CreateDatabaseRequest, CreateInstanceRequest, CreateInstanceRequests, CreateSecondaryClusterRequest, @@ -138,6 +139,7 @@ "ContinuousBackupSource", "CreateBackupRequest", "CreateClusterRequest", + "CreateDatabaseRequest", "CreateInstanceRequest", "CreateInstanceRequests", "CreateSecondaryClusterRequest", diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/gapic_metadata.json b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/gapic_metadata.json index 337a9a99b02d..57b3cfc7d1f5 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/gapic_metadata.json +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/gapic_metadata.json @@ -25,6 +25,11 @@ "create_cluster" ] }, + "CreateDatabase": { + "methods": [ + "create_database" + ] + }, "CreateInstance": { "methods": [ "create_instance" @@ -215,6 +220,11 @@ "create_cluster" ] }, + "CreateDatabase": { + "methods": [ + "create_database" + ] + }, "CreateInstance": { "methods": [ "create_instance" @@ -405,6 +415,11 @@ "create_cluster" ] }, + "CreateDatabase": { + "methods": [ + "create_database" + ] + }, "CreateInstance": { "methods": [ "create_instance" diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/async_client.py index 4ee7c40fa04a..8fd1652816c5 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/async_client.py @@ -97,6 +97,8 @@ class AlloyDBAdminAsyncClient: parse_connection_info_path = staticmethod( AlloyDBAdminClient.parse_connection_info_path ) + crypto_key_path = staticmethod(AlloyDBAdminClient.crypto_key_path) + parse_crypto_key_path = staticmethod(AlloyDBAdminClient.parse_crypto_key_path) crypto_key_version_path = staticmethod(AlloyDBAdminClient.crypto_key_version_path) parse_crypto_key_version_path = staticmethod( AlloyDBAdminClient.parse_crypto_key_version_path @@ -107,6 +109,10 @@ class AlloyDBAdminAsyncClient: parse_instance_path = staticmethod(AlloyDBAdminClient.parse_instance_path) network_path = staticmethod(AlloyDBAdminClient.network_path) parse_network_path = staticmethod(AlloyDBAdminClient.parse_network_path) + service_attachment_path = staticmethod(AlloyDBAdminClient.service_attachment_path) + parse_service_attachment_path = staticmethod( + AlloyDBAdminClient.parse_service_attachment_path + ) supported_database_flag_path = staticmethod( AlloyDBAdminClient.supported_database_flag_path ) @@ -1249,7 +1255,7 @@ async def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1alpha.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request @@ -5149,8 +5155,7 @@ async def sample_list_databases(): Args: request (Optional[Union[google.cloud.alloydb_v1alpha.types.ListDatabasesRequest, dict]]): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. parent (:class:`str`): Required. Parent value for ListDatabasesRequest. @@ -5168,8 +5173,8 @@ async def sample_list_databases(): Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListDatabasesAsyncPager: - Message for response to listing - Databases. + Message for ListDatabases response. + Iterating over this object will yield results and resolve additional pages automatically. @@ -5235,6 +5240,132 @@ async def sample_list_databases(): # Done; return the response. return response + async def create_database( + self, + request: Optional[Union[service.CreateDatabaseRequest, dict]] = None, + *, + parent: Optional[str] = None, + database: Optional[resources.Database] = None, + database_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]]] = (), + ) -> resources.Database: + r"""Creates a new Database in a given project, location, + and cluster. + + .. 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 alloydb_v1alpha + + async def sample_create_database(): + # Create a client + client = alloydb_v1alpha.AlloyDBAdminAsyncClient() + + # Initialize request argument(s) + request = alloydb_v1alpha.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + response = await client.create_database(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.alloydb_v1alpha.types.CreateDatabaseRequest, dict]]): + The request object. Message for CreateDatabase request. + parent (:class:`str`): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + database (:class:`google.cloud.alloydb_v1alpha.types.Database`): + Required. The resource being created. + This corresponds to the ``database`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + database_id (:class:`str`): + Required. ID of the requesting + object. + + This corresponds to the ``database_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.cloud.alloydb_v1alpha.types.Database: + Message describing Database object. + """ + # 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, database, database_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, service.CreateDatabaseRequest): + request = service.CreateDatabaseRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if database is not None: + request.database = database + if database_id is not None: + request.database_id = database_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_database + ] + + # 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, + ) + + # Done; return the response. + return response + async def list_operations( self, request: Optional[operations_pb2.ListOperationsRequest] = None, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/client.py index 0495060a2b43..dec2ce2e6d5d 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/client.py @@ -278,6 +278,30 @@ def parse_connection_info_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def crypto_key_path( + project: str, + location: str, + key_ring: str, + crypto_key: str, + ) -> str: + """Returns a fully-qualified crypto_key string.""" + return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + + @staticmethod + def parse_crypto_key_path(path: str) -> Dict[str, str]: + """Parses a crypto_key path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def crypto_key_version_path( project: str, @@ -371,6 +395,28 @@ def parse_network_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def service_attachment_path( + project: str, + region: str, + service_attachment: str, + ) -> str: + """Returns a fully-qualified service_attachment string.""" + return "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}".format( + project=project, + region=region, + service_attachment=service_attachment, + ) + + @staticmethod + def parse_service_attachment_path(path: str) -> Dict[str, str]: + """Parses a service_attachment path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/regions/(?P.+?)/serviceAttachments/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def supported_database_flag_path( project: str, @@ -1814,7 +1860,7 @@ def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1alpha.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request @@ -5634,8 +5680,7 @@ def sample_list_databases(): Args: request (Union[google.cloud.alloydb_v1alpha.types.ListDatabasesRequest, dict]): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. parent (str): Required. Parent value for ListDatabasesRequest. @@ -5653,8 +5698,8 @@ def sample_list_databases(): Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListDatabasesPager: - Message for response to listing - Databases. + Message for ListDatabases response. + Iterating over this object will yield results and resolve additional pages automatically. @@ -5717,6 +5762,129 @@ def sample_list_databases(): # Done; return the response. return response + def create_database( + self, + request: Optional[Union[service.CreateDatabaseRequest, dict]] = None, + *, + parent: Optional[str] = None, + database: Optional[resources.Database] = None, + database_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]]] = (), + ) -> resources.Database: + r"""Creates a new Database in a given project, location, + and cluster. + + .. 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 alloydb_v1alpha + + def sample_create_database(): + # Create a client + client = alloydb_v1alpha.AlloyDBAdminClient() + + # Initialize request argument(s) + request = alloydb_v1alpha.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + response = client.create_database(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.alloydb_v1alpha.types.CreateDatabaseRequest, dict]): + The request object. Message for CreateDatabase request. + parent (str): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + database (google.cloud.alloydb_v1alpha.types.Database): + Required. The resource being created. + This corresponds to the ``database`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + database_id (str): + Required. ID of the requesting + object. + + This corresponds to the ``database_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.cloud.alloydb_v1alpha.types.Database: + Message describing Database object. + """ + # 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, database, database_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, service.CreateDatabaseRequest): + request = service.CreateDatabaseRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if database is not None: + request.database = database + if database_id is not None: + request.database_id = database_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_database] + + # 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, + ) + + # Done; return the response. + return response + def __enter__(self) -> "AlloyDBAdminClient": return self diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/base.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/base.py index 12f1b160346a..bf0ec81c060e 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/base.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/base.py @@ -421,6 +421,20 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_database: gapic_v1.method.wrap_method( + self.create_database, + default_retry=retries.Retry( + initial=1.0, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, @@ -801,6 +815,15 @@ def list_databases( ]: raise NotImplementedError() + @property + def create_database( + self, + ) -> Callable[ + [service.CreateDatabaseRequest], + Union[resources.Database, Awaitable[resources.Database]], + ]: + raise NotImplementedError() + @property def list_operations( self, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc.py index 56ea36ebb111..055b741be364 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc.py @@ -1342,6 +1342,33 @@ def list_databases( ) return self._stubs["list_databases"] + @property + def create_database( + self, + ) -> Callable[[service.CreateDatabaseRequest], resources.Database]: + r"""Return a callable for the create database method over gRPC. + + Creates a new Database in a given project, location, + and cluster. + + Returns: + Callable[[~.CreateDatabaseRequest], + ~.Database]: + 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_database" not in self._stubs: + self._stubs["create_database"] = self._logged_channel.unary_unary( + "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateDatabase", + request_serializer=service.CreateDatabaseRequest.serialize, + response_deserializer=resources.Database.deserialize, + ) + return self._stubs["create_database"] + def close(self): self._logged_channel.close() diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc_asyncio.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc_asyncio.py index daaeba70ef5b..241661c22145 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc_asyncio.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc_asyncio.py @@ -1380,6 +1380,33 @@ def list_databases( ) return self._stubs["list_databases"] + @property + def create_database( + self, + ) -> Callable[[service.CreateDatabaseRequest], Awaitable[resources.Database]]: + r"""Return a callable for the create database method over gRPC. + + Creates a new Database in a given project, location, + and cluster. + + Returns: + Callable[[~.CreateDatabaseRequest], + Awaitable[~.Database]]: + 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_database" not in self._stubs: + self._stubs["create_database"] = self._logged_channel.unary_unary( + "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateDatabase", + request_serializer=service.CreateDatabaseRequest.serialize, + response_deserializer=resources.Database.deserialize, + ) + return self._stubs["create_database"] + def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { @@ -1667,6 +1694,20 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_database: self._wrap_method( + self.create_database, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest.py index 0411a7be7bff..3703f604cfd8 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest.py @@ -101,6 +101,14 @@ def post_create_cluster(self, response): logging.log(f"Received response: {response}") return response + def pre_create_database(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_database(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_instance(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -515,6 +523,50 @@ def post_create_cluster_with_metadata( """ return response, metadata + def pre_create_database( + self, + request: service.CreateDatabaseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_database + + Override in a subclass to manipulate the request or metadata + before they are sent to the AlloyDBAdmin server. + """ + return request, metadata + + def post_create_database(self, response: resources.Database) -> resources.Database: + """Post-rpc interceptor for create_database + + DEPRECATED. Please use the `post_create_database_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the AlloyDBAdmin server but before + it is returned to user code. This `post_create_database` interceptor runs + before the `post_create_database_with_metadata` interceptor. + """ + return response + + def post_create_database_with_metadata( + self, + response: resources.Database, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[resources.Database, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_database + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the AlloyDBAdmin server but before it is returned to user code. + + We recommend only using this `post_create_database_with_metadata` + interceptor in new development instead of the `post_create_database` interceptor. + When both interceptors are used, this `post_create_database_with_metadata` interceptor runs after the + `post_create_database` interceptor. The (possibly modified) response returned by + `post_create_database` will be passed to + `post_create_database_with_metadata`. + """ + return response, metadata + def pre_create_instance( self, request: service.CreateInstanceRequest, @@ -2802,6 +2854,156 @@ def __call__( ) return resp + class _CreateDatabase( + _BaseAlloyDBAdminRestTransport._BaseCreateDatabase, AlloyDBAdminRestStub + ): + def __hash__(self): + return hash("AlloyDBAdminRestTransport.CreateDatabase") + + @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: service.CreateDatabaseRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> resources.Database: + r"""Call the create database method over HTTP. + + Args: + request (~.service.CreateDatabaseRequest): + The request object. Message for CreateDatabase request. + 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: + ~.resources.Database: + Message describing Database object. + """ + + http_options = ( + _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_database(request, metadata) + transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._get_transcoded_request( + http_options, request + ) + + body = _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._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.alloydb_v1alpha.AlloyDBAdminClient.CreateDatabase", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = AlloyDBAdminRestTransport._CreateDatabase._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 = resources.Database() + pb_resp = resources.Database.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_database(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_database_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Database.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.alloydb_v1alpha.AlloyDBAdminClient.create_database", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + class _CreateInstance( _BaseAlloyDBAdminRestTransport._BaseCreateInstance, AlloyDBAdminRestStub ): @@ -5985,8 +6187,7 @@ def __call__( Args: request (~.service.ListDatabasesRequest): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -5997,9 +6198,7 @@ def __call__( Returns: ~.service.ListDatabasesResponse: - Message for response to listing - Databases. - + Message for ListDatabases response. """ http_options = ( @@ -7943,6 +8142,14 @@ def create_cluster( # In C++ this would require a dynamic_cast return self._CreateCluster(self._session, self._host, self._interceptor) # type: ignore + @property + def create_database( + self, + ) -> Callable[[service.CreateDatabaseRequest], resources.Database]: + # 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._CreateDatabase(self._session, self._host, self._interceptor) # type: ignore + @property def create_instance( self, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest_base.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest_base.py index 35b150d68ced..bcac90f9df8e 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest_base.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest_base.py @@ -267,6 +267,65 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseCreateDatabase: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "databaseId": "", + } + + @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": "/v1alpha/{parent=projects/*/locations/*/clusters/*}/databases", + "body": "database", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = service.CreateDatabaseRequest.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( + _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseCreateInstance: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_dbcsql_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_dbcsql_admin/async_client.py index ab49f9ad3b68..fb1f49ffb1bc 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_dbcsql_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_dbcsql_admin/async_client.py @@ -83,6 +83,8 @@ class AlloyDBCSQLAdminAsyncClient: parse_backup_path = staticmethod(AlloyDBCSQLAdminClient.parse_backup_path) cluster_path = staticmethod(AlloyDBCSQLAdminClient.cluster_path) parse_cluster_path = staticmethod(AlloyDBCSQLAdminClient.parse_cluster_path) + crypto_key_path = staticmethod(AlloyDBCSQLAdminClient.crypto_key_path) + parse_crypto_key_path = staticmethod(AlloyDBCSQLAdminClient.parse_crypto_key_path) crypto_key_version_path = staticmethod( AlloyDBCSQLAdminClient.crypto_key_version_path ) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_dbcsql_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_dbcsql_admin/client.py index 16dca9c2e7ac..cab4b18dc095 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_dbcsql_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_dbcsql_admin/client.py @@ -246,6 +246,30 @@ def parse_cluster_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def crypto_key_path( + project: str, + location: str, + key_ring: str, + crypto_key: str, + ) -> str: + """Returns a fully-qualified crypto_key string.""" + return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + + @staticmethod + def parse_crypto_key_path(path: str) -> Dict[str, str]: + """Parses a crypto_key path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def crypto_key_version_path( project: str, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/__init__.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/__init__.py index 2cc30d73cb54..2b5e40149a56 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/__init__.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/__init__.py @@ -54,6 +54,7 @@ BatchCreateInstanceStatus, CreateBackupRequest, CreateClusterRequest, + CreateDatabaseRequest, CreateInstanceRequest, CreateInstanceRequests, CreateSecondaryClusterRequest, @@ -147,6 +148,7 @@ "BatchCreateInstanceStatus", "CreateBackupRequest", "CreateClusterRequest", + "CreateDatabaseRequest", "CreateInstanceRequest", "CreateInstanceRequests", "CreateSecondaryClusterRequest", diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/resources.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/resources.py index 174446710581..afa122a10797 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/resources.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/resources.py @@ -119,12 +119,15 @@ class DatabaseVersion(proto.Enum): The database version is Postgres 15. POSTGRES_16 (4): The database version is Postgres 16. + POSTGRES_17 (5): + The database version is Postgres 17. """ DATABASE_VERSION_UNSPECIFIED = 0 POSTGRES_13 = 1 POSTGRES_14 = 2 POSTGRES_15 = 3 POSTGRES_16 = 4 + POSTGRES_17 = 5 class SubscriptionType(proto.Enum): @@ -935,11 +938,11 @@ class Cluster(proto.Message): "123/costCenter": "marketing". service_account_email (str): Output only. AlloyDB per-cluster service - agent email. This service account is created + account. This service account is created per-cluster per-project, and is different from - that of the primary service agent which is - created per-project. The service account naming - format is subject to change. + the per-project service account. The per-cluster + service account naming format is subject to + change. """ class State(proto.Enum): @@ -951,14 +954,9 @@ class State(proto.Enum): READY (1): The cluster is active and running. STOPPED (2): - The cluster is stopped. All instances in the - cluster are stopped. Customers can start a - stopped cluster at any point and all their - instances will come back to life with same names - and IP resources. In this state, customer pays - for storage. - Associated backups could also be present in a - stopped cluster. + This is unused. Even when all instances in + the cluster are stopped, the cluster remains in + READY state. EMPTY (3): The cluster is empty and has no associated resources. All instances, associated storage and @@ -2094,30 +2092,27 @@ class ConnectionPoolConfig(proto.Message): enabled (bool): Optional. Whether to enable Managed Connection Pool (MCP). + flags (MutableMapping[str, str]): + Optional. Connection Pool flags, as a list of + "key": "value" pairs. + pooler_count (int): + Output only. The number of running poolers + per instance. """ - class PoolMode(proto.Enum): - r"""The pool mode. Defaults to ``POOL_MODE_TRANSACTION``. - - Values: - POOL_MODE_UNSPECIFIED (0): - The pool mode is not specified. Defaults to - ``POOL_MODE_TRANSACTION``. - POOL_MODE_SESSION (1): - Server is released back to pool after a - client disconnects. - POOL_MODE_TRANSACTION (2): - Server is released back to pool after a - transaction finishes. - """ - POOL_MODE_UNSPECIFIED = 0 - POOL_MODE_SESSION = 1 - POOL_MODE_TRANSACTION = 2 - enabled: bool = proto.Field( proto.BOOL, number=12, ) + flags: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=13, + ) + pooler_count: int = proto.Field( + proto.INT32, + number=14, + ) name: str = proto.Field( proto.STRING, @@ -2900,19 +2895,34 @@ class UserType(proto.Enum): class Database(proto.Message): r"""Message describing Database object. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Identifier. Name of the resource in the form of ``projects/{project}/locations/{location}/clusters/{cluster}/databases/{database}``. charset (str): - Optional. Charset for the database. This field can contain - any PostgreSQL supported charset name. Example values - include "UTF8", "SQL_ASCII", etc. + Optional. Immutable. Charset for the database. This field + can contain any PostgreSQL supported charset name. Example + values include "UTF8", "SQL_ASCII", etc. collation (str): - Optional. Collation for the database. - Name of the custom or native collation for - postgres. Example values include "C", "POSIX", - etc + Optional. Immutable. lc_collate for the database. String + sort order. Example values include "C", "POSIX", etc. + character_type (str): + Optional. Immutable. lc_ctype for the database. Character + classification (What is a letter? The upper-case + equivalent?). Example values include "C", "POSIX", etc. + is_template (bool): + Optional. Whether the database is a template database. + Deprecated in favor of is_template_database. + database_template (str): + Input only. Immutable. Template of the + database to be used for creating a new database. + is_template_database (bool): + Optional. Whether the database is a template + database. + + This field is a member of `oneof`_ ``_is_template_database``. """ name: str = proto.Field( @@ -2927,6 +2937,23 @@ class Database(proto.Message): proto.STRING, number=3, ) + character_type: str = proto.Field( + proto.STRING, + number=4, + ) + is_template: bool = proto.Field( + proto.BOOL, + number=5, + ) + database_template: str = proto.Field( + proto.STRING, + number=6, + ) + is_template_database: bool = proto.Field( + proto.BOOL, + number=7, + optional=True, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/service.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/service.py index 33be35df99e0..73bd04b2f542 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/service.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/types/service.py @@ -85,6 +85,7 @@ "DeleteUserRequest", "ListDatabasesRequest", "ListDatabasesResponse", + "CreateDatabaseRequest", }, ) @@ -2024,6 +2025,10 @@ class ExecuteSqlRequest(proto.Message): Required. SQL statement to execute on database. Any valid statement is permitted, including DDL, DML, DQL statements. + validate_only (bool): + Optional. If set, validates the sql statement + by performing syntax and semantic validation and + doesn't execute the query. """ password: str = proto.Field( @@ -2047,6 +2052,10 @@ class ExecuteSqlRequest(proto.Message): proto.STRING, number=4, ) + validate_only: bool = proto.Field( + proto.BOOL, + number=6, + ) class ExecuteSqlResponse(proto.Message): @@ -2820,8 +2829,50 @@ class StageStatus(proto.Message): Upgrade stage. state (google.cloud.alloydb_v1alpha.types.UpgradeClusterResponse.Status): State of this stage. + schedule (google.cloud.alloydb_v1alpha.types.UpgradeClusterStatus.StageStatus.StageSchedule): + Output only. Timing information for the stage + execution. """ + class StageSchedule(proto.Message): + r"""Timing information for the stage execution. + + Attributes: + estimated_start_time (google.protobuf.timestamp_pb2.Timestamp): + When the stage is expected to start. Set only + if the stage has not started yet. + actual_start_time (google.protobuf.timestamp_pb2.Timestamp): + Actual start time of the stage. Set only if + the stage has started. + estimated_end_time (google.protobuf.timestamp_pb2.Timestamp): + When the stage is expected to end. Set only + if the stage has not completed yet. + actual_end_time (google.protobuf.timestamp_pb2.Timestamp): + Actual end time of the stage. Set only if the + stage has completed. + """ + + estimated_start_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + actual_start_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + estimated_end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + actual_end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + read_pool_instances_upgrade: "UpgradeClusterStatus.ReadPoolInstancesUpgradeStageStatus" = proto.Field( proto.MESSAGE, number=11, @@ -2838,6 +2889,11 @@ class StageStatus(proto.Message): number=2, enum="UpgradeClusterResponse.Status", ) + schedule: "UpgradeClusterStatus.StageStatus.StageSchedule" = proto.Field( + proto.MESSAGE, + number=3, + message="UpgradeClusterStatus.StageStatus.StageSchedule", + ) class ReadPoolInstancesUpgradeStageStatus(proto.Message): r"""Read pool instances upgrade specific status. @@ -3175,7 +3231,7 @@ class DeleteUserRequest(proto.Message): class ListDatabasesRequest(proto.Message): - r"""Message for requesting list of Databases. + r"""Message for ListDatabases request. Attributes: parent (str): @@ -3216,11 +3272,11 @@ class ListDatabasesRequest(proto.Message): class ListDatabasesResponse(proto.Message): - r"""Message for response to listing Databases. + r"""Message for ListDatabases response. Attributes: databases (MutableSequence[google.cloud.alloydb_v1alpha.types.Database]): - The list of databases + The list of databases. next_page_token (str): A token identifying the next page of results the server should return. If this field is @@ -3242,4 +3298,31 @@ def raw_page(self): ) +class CreateDatabaseRequest(proto.Message): + r"""Message for CreateDatabase request. + + Attributes: + parent (str): + Required. Value for parent. + database_id (str): + Required. ID of the requesting object. + database (google.cloud.alloydb_v1alpha.types.Database): + Required. The resource being created. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + database_id: str = proto.Field( + proto.STRING, + number=2, + ) + database: resources.Database = proto.Field( + proto.MESSAGE, + number=3, + message=resources.Database, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/__init__.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/__init__.py index 65b194bd5676..b2185a5859e2 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/__init__.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/__init__.py @@ -64,6 +64,7 @@ BatchCreateInstanceStatus, CreateBackupRequest, CreateClusterRequest, + CreateDatabaseRequest, CreateInstanceRequest, CreateInstanceRequests, CreateSecondaryClusterRequest, @@ -138,6 +139,7 @@ "ContinuousBackupSource", "CreateBackupRequest", "CreateClusterRequest", + "CreateDatabaseRequest", "CreateInstanceRequest", "CreateInstanceRequests", "CreateSecondaryClusterRequest", diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/gapic_metadata.json b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/gapic_metadata.json index 2cdc98f9b8f2..4e57c2cb1a62 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/gapic_metadata.json +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/gapic_metadata.json @@ -25,6 +25,11 @@ "create_cluster" ] }, + "CreateDatabase": { + "methods": [ + "create_database" + ] + }, "CreateInstance": { "methods": [ "create_instance" @@ -215,6 +220,11 @@ "create_cluster" ] }, + "CreateDatabase": { + "methods": [ + "create_database" + ] + }, "CreateInstance": { "methods": [ "create_instance" @@ -405,6 +415,11 @@ "create_cluster" ] }, + "CreateDatabase": { + "methods": [ + "create_database" + ] + }, "CreateInstance": { "methods": [ "create_instance" diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/async_client.py index 2be9fcea5c1d..9a6fe0b23b01 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/async_client.py @@ -97,6 +97,8 @@ class AlloyDBAdminAsyncClient: parse_connection_info_path = staticmethod( AlloyDBAdminClient.parse_connection_info_path ) + crypto_key_path = staticmethod(AlloyDBAdminClient.crypto_key_path) + parse_crypto_key_path = staticmethod(AlloyDBAdminClient.parse_crypto_key_path) crypto_key_version_path = staticmethod(AlloyDBAdminClient.crypto_key_version_path) parse_crypto_key_version_path = staticmethod( AlloyDBAdminClient.parse_crypto_key_version_path @@ -107,6 +109,10 @@ class AlloyDBAdminAsyncClient: parse_instance_path = staticmethod(AlloyDBAdminClient.parse_instance_path) network_path = staticmethod(AlloyDBAdminClient.network_path) parse_network_path = staticmethod(AlloyDBAdminClient.parse_network_path) + service_attachment_path = staticmethod(AlloyDBAdminClient.service_attachment_path) + parse_service_attachment_path = staticmethod( + AlloyDBAdminClient.parse_service_attachment_path + ) supported_database_flag_path = staticmethod( AlloyDBAdminClient.supported_database_flag_path ) @@ -1249,7 +1255,7 @@ async def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1beta.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request @@ -5149,8 +5155,7 @@ async def sample_list_databases(): Args: request (Optional[Union[google.cloud.alloydb_v1beta.types.ListDatabasesRequest, dict]]): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. parent (:class:`str`): Required. Parent value for ListDatabasesRequest. @@ -5168,8 +5173,8 @@ async def sample_list_databases(): Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListDatabasesAsyncPager: - Message for response to listing - Databases. + Message for ListDatabases response. + Iterating over this object will yield results and resolve additional pages automatically. @@ -5235,6 +5240,132 @@ async def sample_list_databases(): # Done; return the response. return response + async def create_database( + self, + request: Optional[Union[service.CreateDatabaseRequest, dict]] = None, + *, + parent: Optional[str] = None, + database: Optional[resources.Database] = None, + database_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]]] = (), + ) -> resources.Database: + r"""Creates a new Database in a given project, location, + and cluster. + + .. 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 alloydb_v1beta + + async def sample_create_database(): + # Create a client + client = alloydb_v1beta.AlloyDBAdminAsyncClient() + + # Initialize request argument(s) + request = alloydb_v1beta.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + response = await client.create_database(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.alloydb_v1beta.types.CreateDatabaseRequest, dict]]): + The request object. Message for CreateDatabase request. + parent (:class:`str`): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + database (:class:`google.cloud.alloydb_v1beta.types.Database`): + Required. The resource being created. + This corresponds to the ``database`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + database_id (:class:`str`): + Required. ID of the requesting + object. + + This corresponds to the ``database_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.cloud.alloydb_v1beta.types.Database: + Message describing Database object. + """ + # 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, database, database_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, service.CreateDatabaseRequest): + request = service.CreateDatabaseRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if database is not None: + request.database = database + if database_id is not None: + request.database_id = database_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_database + ] + + # 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, + ) + + # Done; return the response. + return response + async def list_operations( self, request: Optional[operations_pb2.ListOperationsRequest] = None, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/client.py index 5925bb0c1230..fb2b7201c9b3 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/client.py @@ -278,6 +278,30 @@ def parse_connection_info_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def crypto_key_path( + project: str, + location: str, + key_ring: str, + crypto_key: str, + ) -> str: + """Returns a fully-qualified crypto_key string.""" + return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + + @staticmethod + def parse_crypto_key_path(path: str) -> Dict[str, str]: + """Parses a crypto_key path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def crypto_key_version_path( project: str, @@ -371,6 +395,28 @@ def parse_network_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def service_attachment_path( + project: str, + region: str, + service_attachment: str, + ) -> str: + """Returns a fully-qualified service_attachment string.""" + return "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}".format( + project=project, + region=region, + service_attachment=service_attachment, + ) + + @staticmethod + def parse_service_attachment_path(path: str) -> Dict[str, str]: + """Parses a service_attachment path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/regions/(?P.+?)/serviceAttachments/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def supported_database_flag_path( project: str, @@ -1814,7 +1860,7 @@ def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1beta.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request @@ -5634,8 +5680,7 @@ def sample_list_databases(): Args: request (Union[google.cloud.alloydb_v1beta.types.ListDatabasesRequest, dict]): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. parent (str): Required. Parent value for ListDatabasesRequest. @@ -5653,8 +5698,8 @@ def sample_list_databases(): Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListDatabasesPager: - Message for response to listing - Databases. + Message for ListDatabases response. + Iterating over this object will yield results and resolve additional pages automatically. @@ -5717,6 +5762,129 @@ def sample_list_databases(): # Done; return the response. return response + def create_database( + self, + request: Optional[Union[service.CreateDatabaseRequest, dict]] = None, + *, + parent: Optional[str] = None, + database: Optional[resources.Database] = None, + database_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]]] = (), + ) -> resources.Database: + r"""Creates a new Database in a given project, location, + and cluster. + + .. 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 alloydb_v1beta + + def sample_create_database(): + # Create a client + client = alloydb_v1beta.AlloyDBAdminClient() + + # Initialize request argument(s) + request = alloydb_v1beta.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + response = client.create_database(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.alloydb_v1beta.types.CreateDatabaseRequest, dict]): + The request object. Message for CreateDatabase request. + parent (str): + Required. Value for parent. + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + database (google.cloud.alloydb_v1beta.types.Database): + Required. The resource being created. + This corresponds to the ``database`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + database_id (str): + Required. ID of the requesting + object. + + This corresponds to the ``database_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.cloud.alloydb_v1beta.types.Database: + Message describing Database object. + """ + # 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, database, database_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, service.CreateDatabaseRequest): + request = service.CreateDatabaseRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if database is not None: + request.database = database + if database_id is not None: + request.database_id = database_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_database] + + # 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, + ) + + # Done; return the response. + return response + def __enter__(self) -> "AlloyDBAdminClient": return self diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/base.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/base.py index d02841acc473..7eb685d62ae8 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/base.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/base.py @@ -430,6 +430,20 @@ def _prep_wrapped_messages(self, client_info): default_timeout=60.0, client_info=client_info, ), + self.create_database: gapic_v1.method.wrap_method( + self.create_database, + default_retry=retries.Retry( + initial=1.0, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, @@ -810,6 +824,15 @@ def list_databases( ]: raise NotImplementedError() + @property + def create_database( + self, + ) -> Callable[ + [service.CreateDatabaseRequest], + Union[resources.Database, Awaitable[resources.Database]], + ]: + raise NotImplementedError() + @property def list_operations( self, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc.py index 5f67e4d4d55c..054bd05869c4 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc.py @@ -1342,6 +1342,33 @@ def list_databases( ) return self._stubs["list_databases"] + @property + def create_database( + self, + ) -> Callable[[service.CreateDatabaseRequest], resources.Database]: + r"""Return a callable for the create database method over gRPC. + + Creates a new Database in a given project, location, + and cluster. + + Returns: + Callable[[~.CreateDatabaseRequest], + ~.Database]: + 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_database" not in self._stubs: + self._stubs["create_database"] = self._logged_channel.unary_unary( + "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateDatabase", + request_serializer=service.CreateDatabaseRequest.serialize, + response_deserializer=resources.Database.deserialize, + ) + return self._stubs["create_database"] + def close(self): self._logged_channel.close() diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc_asyncio.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc_asyncio.py index 56f05d02eda9..305dc1327cba 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc_asyncio.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc_asyncio.py @@ -1380,6 +1380,33 @@ def list_databases( ) return self._stubs["list_databases"] + @property + def create_database( + self, + ) -> Callable[[service.CreateDatabaseRequest], Awaitable[resources.Database]]: + r"""Return a callable for the create database method over gRPC. + + Creates a new Database in a given project, location, + and cluster. + + Returns: + Callable[[~.CreateDatabaseRequest], + Awaitable[~.Database]]: + 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_database" not in self._stubs: + self._stubs["create_database"] = self._logged_channel.unary_unary( + "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateDatabase", + request_serializer=service.CreateDatabaseRequest.serialize, + response_deserializer=resources.Database.deserialize, + ) + return self._stubs["create_database"] + def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { @@ -1676,6 +1703,20 @@ def _prep_wrapped_messages(self, client_info): default_timeout=60.0, client_info=client_info, ), + self.create_database: self._wrap_method( + self.create_database, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=60.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest.py index c30aa5bebb56..38ceb1f2ec50 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest.py @@ -101,6 +101,14 @@ def post_create_cluster(self, response): logging.log(f"Received response: {response}") return response + def pre_create_database(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_database(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_instance(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -515,6 +523,50 @@ def post_create_cluster_with_metadata( """ return response, metadata + def pre_create_database( + self, + request: service.CreateDatabaseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_database + + Override in a subclass to manipulate the request or metadata + before they are sent to the AlloyDBAdmin server. + """ + return request, metadata + + def post_create_database(self, response: resources.Database) -> resources.Database: + """Post-rpc interceptor for create_database + + DEPRECATED. Please use the `post_create_database_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the AlloyDBAdmin server but before + it is returned to user code. This `post_create_database` interceptor runs + before the `post_create_database_with_metadata` interceptor. + """ + return response + + def post_create_database_with_metadata( + self, + response: resources.Database, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[resources.Database, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_database + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the AlloyDBAdmin server but before it is returned to user code. + + We recommend only using this `post_create_database_with_metadata` + interceptor in new development instead of the `post_create_database` interceptor. + When both interceptors are used, this `post_create_database_with_metadata` interceptor runs after the + `post_create_database` interceptor. The (possibly modified) response returned by + `post_create_database` will be passed to + `post_create_database_with_metadata`. + """ + return response, metadata + def pre_create_instance( self, request: service.CreateInstanceRequest, @@ -2801,6 +2853,156 @@ def __call__( ) return resp + class _CreateDatabase( + _BaseAlloyDBAdminRestTransport._BaseCreateDatabase, AlloyDBAdminRestStub + ): + def __hash__(self): + return hash("AlloyDBAdminRestTransport.CreateDatabase") + + @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: service.CreateDatabaseRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> resources.Database: + r"""Call the create database method over HTTP. + + Args: + request (~.service.CreateDatabaseRequest): + The request object. Message for CreateDatabase request. + 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: + ~.resources.Database: + Message describing Database object. + """ + + http_options = ( + _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_database(request, metadata) + transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._get_transcoded_request( + http_options, request + ) + + body = _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._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.alloydb_v1beta.AlloyDBAdminClient.CreateDatabase", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = AlloyDBAdminRestTransport._CreateDatabase._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 = resources.Database() + pb_resp = resources.Database.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_database(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_database_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Database.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.alloydb_v1beta.AlloyDBAdminClient.create_database", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + class _CreateInstance( _BaseAlloyDBAdminRestTransport._BaseCreateInstance, AlloyDBAdminRestStub ): @@ -5984,8 +6186,7 @@ def __call__( Args: request (~.service.ListDatabasesRequest): - The request object. Message for requesting list of - Databases. + The request object. Message for ListDatabases request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -5996,9 +6197,7 @@ def __call__( Returns: ~.service.ListDatabasesResponse: - Message for response to listing - Databases. - + Message for ListDatabases response. """ http_options = ( @@ -7942,6 +8141,14 @@ def create_cluster( # In C++ this would require a dynamic_cast return self._CreateCluster(self._session, self._host, self._interceptor) # type: ignore + @property + def create_database( + self, + ) -> Callable[[service.CreateDatabaseRequest], resources.Database]: + # 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._CreateDatabase(self._session, self._host, self._interceptor) # type: ignore + @property def create_instance( self, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest_base.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest_base.py index 28cd9f7f9f0e..b1b21fb06944 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest_base.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest_base.py @@ -267,6 +267,65 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseCreateDatabase: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "databaseId": "", + } + + @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": "/v1beta/{parent=projects/*/locations/*/clusters/*}/databases", + "body": "database", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = service.CreateDatabaseRequest.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( + _BaseAlloyDBAdminRestTransport._BaseCreateDatabase._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseCreateInstance: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_dbcsql_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_dbcsql_admin/async_client.py index e90a4d977cec..924dc8b77cce 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_dbcsql_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_dbcsql_admin/async_client.py @@ -83,6 +83,8 @@ class AlloyDBCSQLAdminAsyncClient: parse_backup_path = staticmethod(AlloyDBCSQLAdminClient.parse_backup_path) cluster_path = staticmethod(AlloyDBCSQLAdminClient.cluster_path) parse_cluster_path = staticmethod(AlloyDBCSQLAdminClient.parse_cluster_path) + crypto_key_path = staticmethod(AlloyDBCSQLAdminClient.crypto_key_path) + parse_crypto_key_path = staticmethod(AlloyDBCSQLAdminClient.parse_crypto_key_path) crypto_key_version_path = staticmethod( AlloyDBCSQLAdminClient.crypto_key_version_path ) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_dbcsql_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_dbcsql_admin/client.py index 3564157670d0..a94e06d4e7f2 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_dbcsql_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_dbcsql_admin/client.py @@ -246,6 +246,30 @@ def parse_cluster_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def crypto_key_path( + project: str, + location: str, + key_ring: str, + crypto_key: str, + ) -> str: + """Returns a fully-qualified crypto_key string.""" + return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + + @staticmethod + def parse_crypto_key_path(path: str) -> Dict[str, str]: + """Parses a crypto_key path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def crypto_key_version_path( project: str, diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/__init__.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/__init__.py index 2cc30d73cb54..2b5e40149a56 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/__init__.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/__init__.py @@ -54,6 +54,7 @@ BatchCreateInstanceStatus, CreateBackupRequest, CreateClusterRequest, + CreateDatabaseRequest, CreateInstanceRequest, CreateInstanceRequests, CreateSecondaryClusterRequest, @@ -147,6 +148,7 @@ "BatchCreateInstanceStatus", "CreateBackupRequest", "CreateClusterRequest", + "CreateDatabaseRequest", "CreateInstanceRequest", "CreateInstanceRequests", "CreateSecondaryClusterRequest", diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/resources.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/resources.py index bd6e76a59956..57af831c16e4 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/resources.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/resources.py @@ -119,12 +119,15 @@ class DatabaseVersion(proto.Enum): The database version is Postgres 15. POSTGRES_16 (4): The database version is Postgres 16. + POSTGRES_17 (5): + The database version is Postgres 17. """ DATABASE_VERSION_UNSPECIFIED = 0 POSTGRES_13 = 1 POSTGRES_14 = 2 POSTGRES_15 = 3 POSTGRES_16 = 4 + POSTGRES_17 = 5 class SubscriptionType(proto.Enum): @@ -933,11 +936,11 @@ class Cluster(proto.Message): "123/costCenter": "marketing". service_account_email (str): Output only. AlloyDB per-cluster service - agent email. This service account is created + account. This service account is created per-cluster per-project, and is different from - that of the primary service agent which is - created per-project. The service account naming - format is subject to change. + the per-project service account. The per-cluster + service account naming format is subject to + change. """ class State(proto.Enum): @@ -949,14 +952,9 @@ class State(proto.Enum): READY (1): The cluster is active and running. STOPPED (2): - The cluster is stopped. All instances in the - cluster are stopped. Customers can start a - stopped cluster at any point and all their - instances will come back to life with same names - and IP resources. In this state, customer pays - for storage. - Associated backups could also be present in a - stopped cluster. + This is unused. Even when all instances in + the cluster are stopped, the cluster remains in + READY state. EMPTY (3): The cluster is empty and has no associated resources. All instances, associated storage and @@ -2089,26 +2087,11 @@ class ConnectionPoolConfig(proto.Message): flags (MutableMapping[str, str]): Optional. Connection Pool flags, as a list of "key": "value" pairs. + pooler_count (int): + Output only. The number of running poolers + per instance. """ - class PoolMode(proto.Enum): - r"""The pool mode. Defaults to ``POOL_MODE_TRANSACTION``. - - Values: - POOL_MODE_UNSPECIFIED (0): - The pool mode is not specified. Defaults to - ``POOL_MODE_TRANSACTION``. - POOL_MODE_SESSION (1): - Server is released back to pool after a - client disconnects. - POOL_MODE_TRANSACTION (2): - Server is released back to pool after a - transaction finishes. - """ - POOL_MODE_UNSPECIFIED = 0 - POOL_MODE_SESSION = 1 - POOL_MODE_TRANSACTION = 2 - enabled: bool = proto.Field( proto.BOOL, number=12, @@ -2118,6 +2101,10 @@ class PoolMode(proto.Enum): proto.STRING, number=13, ) + pooler_count: int = proto.Field( + proto.INT32, + number=14, + ) name: str = proto.Field( proto.STRING, @@ -2890,19 +2877,34 @@ class UserType(proto.Enum): class Database(proto.Message): r"""Message describing Database object. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Identifier. Name of the resource in the form of ``projects/{project}/locations/{location}/clusters/{cluster}/databases/{database}``. charset (str): - Optional. Charset for the database. This field can contain - any PostgreSQL supported charset name. Example values - include "UTF8", "SQL_ASCII", etc. + Optional. Immutable. Charset for the database. This field + can contain any PostgreSQL supported charset name. Example + values include "UTF8", "SQL_ASCII", etc. collation (str): - Optional. Collation for the database. - Name of the custom or native collation for - postgres. Example values include "C", "POSIX", - etc + Optional. Immutable. lc_collate for the database. String + sort order. Example values include "C", "POSIX", etc. + character_type (str): + Optional. Immutable. lc_ctype for the database. Character + classification (What is a letter? The upper-case + equivalent?). Example values include "C", "POSIX", etc. + is_template (bool): + Optional. Whether the database is a template database. + Deprecated in favor of is_template_database. + database_template (str): + Input only. Immutable. Template of the + database to be used for creating a new database. + is_template_database (bool): + Optional. Whether the database is a template + database. + + This field is a member of `oneof`_ ``_is_template_database``. """ name: str = proto.Field( @@ -2917,6 +2919,23 @@ class Database(proto.Message): proto.STRING, number=3, ) + character_type: str = proto.Field( + proto.STRING, + number=4, + ) + is_template: bool = proto.Field( + proto.BOOL, + number=5, + ) + database_template: str = proto.Field( + proto.STRING, + number=6, + ) + is_template_database: bool = proto.Field( + proto.BOOL, + number=7, + optional=True, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/service.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/service.py index 36e66bd48724..753af81c3709 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/service.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/types/service.py @@ -85,6 +85,7 @@ "DeleteUserRequest", "ListDatabasesRequest", "ListDatabasesResponse", + "CreateDatabaseRequest", }, ) @@ -2024,6 +2025,10 @@ class ExecuteSqlRequest(proto.Message): Required. SQL statement to execute on database. Any valid statement is permitted, including DDL, DML, DQL statements. + validate_only (bool): + Optional. If set, validates the sql statement + by performing syntax and semantic validation and + doesn't execute the query. """ password: str = proto.Field( @@ -2047,6 +2052,10 @@ class ExecuteSqlRequest(proto.Message): proto.STRING, number=4, ) + validate_only: bool = proto.Field( + proto.BOOL, + number=6, + ) class ExecuteSqlResponse(proto.Message): @@ -2820,8 +2829,50 @@ class StageStatus(proto.Message): Upgrade stage. state (google.cloud.alloydb_v1beta.types.UpgradeClusterResponse.Status): State of this stage. + schedule (google.cloud.alloydb_v1beta.types.UpgradeClusterStatus.StageStatus.StageSchedule): + Output only. Timing information for the stage + execution. """ + class StageSchedule(proto.Message): + r"""Timing information for the stage execution. + + Attributes: + estimated_start_time (google.protobuf.timestamp_pb2.Timestamp): + When the stage is expected to start. Set only + if the stage has not started yet. + actual_start_time (google.protobuf.timestamp_pb2.Timestamp): + Actual start time of the stage. Set only if + the stage has started. + estimated_end_time (google.protobuf.timestamp_pb2.Timestamp): + When the stage is expected to end. Set only + if the stage has not completed yet. + actual_end_time (google.protobuf.timestamp_pb2.Timestamp): + Actual end time of the stage. Set only if the + stage has completed. + """ + + estimated_start_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + actual_start_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + estimated_end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + actual_end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + read_pool_instances_upgrade: "UpgradeClusterStatus.ReadPoolInstancesUpgradeStageStatus" = proto.Field( proto.MESSAGE, number=11, @@ -2838,6 +2889,11 @@ class StageStatus(proto.Message): number=2, enum="UpgradeClusterResponse.Status", ) + schedule: "UpgradeClusterStatus.StageStatus.StageSchedule" = proto.Field( + proto.MESSAGE, + number=3, + message="UpgradeClusterStatus.StageStatus.StageSchedule", + ) class ReadPoolInstancesUpgradeStageStatus(proto.Message): r"""Read pool instances upgrade specific status. @@ -3175,7 +3231,7 @@ class DeleteUserRequest(proto.Message): class ListDatabasesRequest(proto.Message): - r"""Message for requesting list of Databases. + r"""Message for ListDatabases request. Attributes: parent (str): @@ -3216,11 +3272,11 @@ class ListDatabasesRequest(proto.Message): class ListDatabasesResponse(proto.Message): - r"""Message for response to listing Databases. + r"""Message for ListDatabases response. Attributes: databases (MutableSequence[google.cloud.alloydb_v1beta.types.Database]): - The list of databases + The list of databases. next_page_token (str): A token identifying the next page of results the server should return. If this field is @@ -3242,4 +3298,31 @@ def raw_page(self): ) +class CreateDatabaseRequest(proto.Message): + r"""Message for CreateDatabase request. + + Attributes: + parent (str): + Required. Value for parent. + database_id (str): + Required. ID of the requesting object. + database (google.cloud.alloydb_v1beta.types.Database): + Required. The resource being created. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + database_id: str = proto.Field( + proto.STRING, + number=2, + ) + database: resources.Database = proto.Field( + proto.MESSAGE, + number=3, + message=resources.Database, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1_generated_alloy_db_admin_upgrade_cluster_async.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1_generated_alloy_db_admin_upgrade_cluster_async.py index b37df6c78db3..bc4576c08edb 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1_generated_alloy_db_admin_upgrade_cluster_async.py +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1_generated_alloy_db_admin_upgrade_cluster_async.py @@ -41,7 +41,7 @@ async def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1_generated_alloy_db_admin_upgrade_cluster_sync.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1_generated_alloy_db_admin_upgrade_cluster_sync.py index bcd34b8a4bf3..bce3a7cd9046 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1_generated_alloy_db_admin_upgrade_cluster_sync.py +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1_generated_alloy_db_admin_upgrade_cluster_sync.py @@ -41,7 +41,7 @@ def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_create_database_async.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_create_database_async.py new file mode 100644 index 000000000000..cbc37bc92d21 --- /dev/null +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_create_database_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 CreateDatabase +# 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-alloydb + + +# [START alloydb_v1alpha_generated_AlloyDBAdmin_CreateDatabase_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 alloydb_v1alpha + + +async def sample_create_database(): + # Create a client + client = alloydb_v1alpha.AlloyDBAdminAsyncClient() + + # Initialize request argument(s) + request = alloydb_v1alpha.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + response = await client.create_database(request=request) + + # Handle the response + print(response) + +# [END alloydb_v1alpha_generated_AlloyDBAdmin_CreateDatabase_async] diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_create_database_sync.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_create_database_sync.py new file mode 100644 index 000000000000..06abaad1ac38 --- /dev/null +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_create_database_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 CreateDatabase +# 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-alloydb + + +# [START alloydb_v1alpha_generated_AlloyDBAdmin_CreateDatabase_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 alloydb_v1alpha + + +def sample_create_database(): + # Create a client + client = alloydb_v1alpha.AlloyDBAdminClient() + + # Initialize request argument(s) + request = alloydb_v1alpha.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + response = client.create_database(request=request) + + # Handle the response + print(response) + +# [END alloydb_v1alpha_generated_AlloyDBAdmin_CreateDatabase_sync] diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_upgrade_cluster_async.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_upgrade_cluster_async.py index 8570afc3d6f2..96ceec40ce83 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_upgrade_cluster_async.py +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_upgrade_cluster_async.py @@ -41,7 +41,7 @@ async def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1alpha.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_upgrade_cluster_sync.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_upgrade_cluster_sync.py index 14cf4326094d..47b17fe0f05a 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_upgrade_cluster_sync.py +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1alpha_generated_alloy_db_admin_upgrade_cluster_sync.py @@ -41,7 +41,7 @@ def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1alpha.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_create_database_async.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_create_database_async.py new file mode 100644 index 000000000000..3f1d71de5488 --- /dev/null +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_create_database_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 CreateDatabase +# 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-alloydb + + +# [START alloydb_v1beta_generated_AlloyDBAdmin_CreateDatabase_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 alloydb_v1beta + + +async def sample_create_database(): + # Create a client + client = alloydb_v1beta.AlloyDBAdminAsyncClient() + + # Initialize request argument(s) + request = alloydb_v1beta.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + response = await client.create_database(request=request) + + # Handle the response + print(response) + +# [END alloydb_v1beta_generated_AlloyDBAdmin_CreateDatabase_async] diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_create_database_sync.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_create_database_sync.py new file mode 100644 index 000000000000..532cd0aacd82 --- /dev/null +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_create_database_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 CreateDatabase +# 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-alloydb + + +# [START alloydb_v1beta_generated_AlloyDBAdmin_CreateDatabase_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 alloydb_v1beta + + +def sample_create_database(): + # Create a client + client = alloydb_v1beta.AlloyDBAdminClient() + + # Initialize request argument(s) + request = alloydb_v1beta.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Make the request + response = client.create_database(request=request) + + # Handle the response + print(response) + +# [END alloydb_v1beta_generated_AlloyDBAdmin_CreateDatabase_sync] diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_upgrade_cluster_async.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_upgrade_cluster_async.py index a50a5c29ba63..d33787d047a1 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_upgrade_cluster_async.py +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_upgrade_cluster_async.py @@ -41,7 +41,7 @@ async def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1beta.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request diff --git a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_upgrade_cluster_sync.py b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_upgrade_cluster_sync.py index ee7582d04c9e..ac8912f7a571 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_upgrade_cluster_sync.py +++ b/packages/google-cloud-alloydb/samples/generated_samples/alloydb_v1beta_generated_alloy_db_admin_upgrade_cluster_sync.py @@ -41,7 +41,7 @@ def sample_upgrade_cluster(): # Initialize request argument(s) request = alloydb_v1beta.UpgradeClusterRequest( name="name_value", - version="POSTGRES_16", + version="POSTGRES_17", ) # Make the request diff --git a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1alpha.json b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1alpha.json index 1cafd27a4879..aeb6349f4055 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1alpha.json +++ b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1alpha.json @@ -518,6 +518,183 @@ ], "title": "alloydb_v1alpha_generated_alloy_db_admin_create_cluster_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.alloydb_v1alpha.AlloyDBAdminAsyncClient", + "shortName": "AlloyDBAdminAsyncClient" + }, + "fullName": "google.cloud.alloydb_v1alpha.AlloyDBAdminAsyncClient.create_database", + "method": { + "fullName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin.CreateDatabase", + "service": { + "fullName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "shortName": "AlloyDBAdmin" + }, + "shortName": "CreateDatabase" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.alloydb_v1alpha.types.CreateDatabaseRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "database", + "type": "google.cloud.alloydb_v1alpha.types.Database" + }, + { + "name": "database_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.cloud.alloydb_v1alpha.types.Database", + "shortName": "create_database" + }, + "description": "Sample for CreateDatabase", + "file": "alloydb_v1alpha_generated_alloy_db_admin_create_database_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "alloydb_v1alpha_generated_AlloyDBAdmin_CreateDatabase_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "alloydb_v1alpha_generated_alloy_db_admin_create_database_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.alloydb_v1alpha.AlloyDBAdminClient", + "shortName": "AlloyDBAdminClient" + }, + "fullName": "google.cloud.alloydb_v1alpha.AlloyDBAdminClient.create_database", + "method": { + "fullName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin.CreateDatabase", + "service": { + "fullName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "shortName": "AlloyDBAdmin" + }, + "shortName": "CreateDatabase" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.alloydb_v1alpha.types.CreateDatabaseRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "database", + "type": "google.cloud.alloydb_v1alpha.types.Database" + }, + { + "name": "database_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.cloud.alloydb_v1alpha.types.Database", + "shortName": "create_database" + }, + "description": "Sample for CreateDatabase", + "file": "alloydb_v1alpha_generated_alloy_db_admin_create_database_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "alloydb_v1alpha_generated_AlloyDBAdmin_CreateDatabase_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "alloydb_v1alpha_generated_alloy_db_admin_create_database_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1beta.json b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1beta.json index 3e961c3e9d48..9e0e47501ef4 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1beta.json +++ b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1beta.json @@ -518,6 +518,183 @@ ], "title": "alloydb_v1beta_generated_alloy_db_admin_create_cluster_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.alloydb_v1beta.AlloyDBAdminAsyncClient", + "shortName": "AlloyDBAdminAsyncClient" + }, + "fullName": "google.cloud.alloydb_v1beta.AlloyDBAdminAsyncClient.create_database", + "method": { + "fullName": "google.cloud.alloydb.v1beta.AlloyDBAdmin.CreateDatabase", + "service": { + "fullName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "shortName": "AlloyDBAdmin" + }, + "shortName": "CreateDatabase" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.alloydb_v1beta.types.CreateDatabaseRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "database", + "type": "google.cloud.alloydb_v1beta.types.Database" + }, + { + "name": "database_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.cloud.alloydb_v1beta.types.Database", + "shortName": "create_database" + }, + "description": "Sample for CreateDatabase", + "file": "alloydb_v1beta_generated_alloy_db_admin_create_database_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "alloydb_v1beta_generated_AlloyDBAdmin_CreateDatabase_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "alloydb_v1beta_generated_alloy_db_admin_create_database_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.alloydb_v1beta.AlloyDBAdminClient", + "shortName": "AlloyDBAdminClient" + }, + "fullName": "google.cloud.alloydb_v1beta.AlloyDBAdminClient.create_database", + "method": { + "fullName": "google.cloud.alloydb.v1beta.AlloyDBAdmin.CreateDatabase", + "service": { + "fullName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "shortName": "AlloyDBAdmin" + }, + "shortName": "CreateDatabase" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.alloydb_v1beta.types.CreateDatabaseRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "database", + "type": "google.cloud.alloydb_v1beta.types.Database" + }, + { + "name": "database_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.cloud.alloydb_v1beta.types.Database", + "shortName": "create_database" + }, + "description": "Sample for CreateDatabase", + "file": "alloydb_v1beta_generated_alloy_db_admin_create_database_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "alloydb_v1beta_generated_AlloyDBAdmin_CreateDatabase_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "alloydb_v1beta_generated_alloy_db_admin_create_database_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1_keywords.py b/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1_keywords.py index 2b7ad0f47590..d47703c5e3e2 100644 --- a/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1_keywords.py +++ b/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1_keywords.py @@ -50,7 +50,7 @@ class alloydbCallTransformer(cst.CSTTransformer): 'delete_cluster': ('name', 'request_id', 'etag', 'validate_only', 'force', ), 'delete_instance': ('name', 'request_id', 'etag', 'validate_only', ), 'delete_user': ('name', 'request_id', 'validate_only', ), - 'execute_sql': ('instance', 'database', 'sql_statement', 'password', 'user', ), + 'execute_sql': ('instance', 'database', 'sql_statement', 'password', 'user', 'validate_only', ), 'export_cluster': ('gcs_destination', 'name', 'database', 'csv_export_options', 'sql_export_options', ), 'failover_instance': ('name', 'request_id', 'validate_only', ), 'generate_client_certificate': ('parent', 'request_id', 'cert_duration', 'public_key', 'use_metadata_exchange', ), diff --git a/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1alpha_keywords.py b/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1alpha_keywords.py index 537931f9ebf9..591f7aef2826 100644 --- a/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1alpha_keywords.py +++ b/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1alpha_keywords.py @@ -42,6 +42,7 @@ class alloydbCallTransformer(cst.CSTTransformer): 'batch_create_instances': ('parent', 'requests', 'request_id', ), 'create_backup': ('parent', 'backup_id', 'backup', 'request_id', 'validate_only', ), 'create_cluster': ('parent', 'cluster_id', 'cluster', 'request_id', 'validate_only', ), + 'create_database': ('parent', 'database_id', 'database', ), 'create_instance': ('parent', 'instance_id', 'instance', 'request_id', 'validate_only', ), 'create_secondary_cluster': ('parent', 'cluster_id', 'cluster', 'request_id', 'validate_only', ), 'create_secondary_instance': ('parent', 'instance_id', 'instance', 'request_id', 'validate_only', ), @@ -50,7 +51,7 @@ class alloydbCallTransformer(cst.CSTTransformer): 'delete_cluster': ('name', 'request_id', 'etag', 'validate_only', 'force', ), 'delete_instance': ('name', 'request_id', 'etag', 'validate_only', ), 'delete_user': ('name', 'request_id', 'validate_only', ), - 'execute_sql': ('instance', 'database', 'user', 'sql_statement', 'password', ), + 'execute_sql': ('instance', 'database', 'user', 'sql_statement', 'password', 'validate_only', ), 'export_cluster': ('gcs_destination', 'name', 'database', 'csv_export_options', 'sql_export_options', ), 'failover_instance': ('name', 'request_id', 'validate_only', ), 'generate_client_certificate': ('parent', 'request_id', 'pem_csr', 'cert_duration', 'public_key', 'use_metadata_exchange', ), diff --git a/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1beta_keywords.py b/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1beta_keywords.py index 537931f9ebf9..591f7aef2826 100644 --- a/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1beta_keywords.py +++ b/packages/google-cloud-alloydb/scripts/fixup_alloydb_v1beta_keywords.py @@ -42,6 +42,7 @@ class alloydbCallTransformer(cst.CSTTransformer): 'batch_create_instances': ('parent', 'requests', 'request_id', ), 'create_backup': ('parent', 'backup_id', 'backup', 'request_id', 'validate_only', ), 'create_cluster': ('parent', 'cluster_id', 'cluster', 'request_id', 'validate_only', ), + 'create_database': ('parent', 'database_id', 'database', ), 'create_instance': ('parent', 'instance_id', 'instance', 'request_id', 'validate_only', ), 'create_secondary_cluster': ('parent', 'cluster_id', 'cluster', 'request_id', 'validate_only', ), 'create_secondary_instance': ('parent', 'instance_id', 'instance', 'request_id', 'validate_only', ), @@ -50,7 +51,7 @@ class alloydbCallTransformer(cst.CSTTransformer): 'delete_cluster': ('name', 'request_id', 'etag', 'validate_only', 'force', ), 'delete_instance': ('name', 'request_id', 'etag', 'validate_only', ), 'delete_user': ('name', 'request_id', 'validate_only', ), - 'execute_sql': ('instance', 'database', 'user', 'sql_statement', 'password', ), + 'execute_sql': ('instance', 'database', 'user', 'sql_statement', 'password', 'validate_only', ), 'export_cluster': ('gcs_destination', 'name', 'database', 'csv_export_options', 'sql_export_options', ), 'failover_instance': ('name', 'request_id', 'validate_only', ), 'generate_client_certificate': ('parent', 'request_id', 'pem_csr', 'cert_duration', 'public_key', 'use_metadata_exchange', ), diff --git a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_db_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_db_admin.py index 79b17526adab..d5be9f6d6769 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_db_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_db_admin.py @@ -26706,6 +26706,7 @@ def test_create_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, } # 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 @@ -26975,6 +26976,7 @@ def test_create_secondary_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, } # 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 @@ -27259,6 +27261,11 @@ def test_batch_create_instances_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, + "connection_pool_config": { + "enabled": True, + "flags": {}, + "pooler_count": 1305, + }, }, "request_id": "request_id_value", "validate_only": True, @@ -27542,6 +27549,7 @@ def test_update_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, } # 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 @@ -32288,12 +32296,41 @@ def test_parse_connection_info_path(): assert expected == actual -def test_crypto_key_version_path(): +def test_crypto_key_path(): project = "winkle" location = "nautilus" key_ring = "scallop" crypto_key = "abalone" - crypto_key_version = "squid" + expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + actual = AlloyDBAdminClient.crypto_key_path(project, location, key_ring, crypto_key) + assert expected == actual + + +def test_parse_crypto_key_path(): + expected = { + "project": "squid", + "location": "clam", + "key_ring": "whelk", + "crypto_key": "octopus", + } + path = AlloyDBAdminClient.crypto_key_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBAdminClient.parse_crypto_key_path(path) + assert expected == actual + + +def test_crypto_key_version_path(): + project = "oyster" + location = "nudibranch" + key_ring = "cuttlefish" + crypto_key = "mussel" + crypto_key_version = "winkle" expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format( project=project, location=location, @@ -32309,11 +32346,11 @@ def test_crypto_key_version_path(): def test_parse_crypto_key_version_path(): expected = { - "project": "clam", - "location": "whelk", - "key_ring": "octopus", - "crypto_key": "oyster", - "crypto_key_version": "nudibranch", + "project": "nautilus", + "location": "scallop", + "key_ring": "abalone", + "crypto_key": "squid", + "crypto_key_version": "clam", } path = AlloyDBAdminClient.crypto_key_version_path(**expected) @@ -32323,10 +32360,10 @@ def test_parse_crypto_key_version_path(): def test_database_path(): - project = "cuttlefish" - location = "mussel" - cluster = "winkle" - database = "nautilus" + project = "whelk" + location = "octopus" + cluster = "oyster" + database = "nudibranch" expected = "projects/{project}/locations/{location}/clusters/{cluster}/databases/{database}".format( project=project, location=location, @@ -32339,10 +32376,10 @@ def test_database_path(): def test_parse_database_path(): expected = { - "project": "scallop", - "location": "abalone", - "cluster": "squid", - "database": "clam", + "project": "cuttlefish", + "location": "mussel", + "cluster": "winkle", + "database": "nautilus", } path = AlloyDBAdminClient.database_path(**expected) @@ -32352,10 +32389,10 @@ def test_parse_database_path(): def test_instance_path(): - project = "whelk" - location = "octopus" - cluster = "oyster" - instance = "nudibranch" + project = "scallop" + location = "abalone" + cluster = "squid" + instance = "clam" expected = "projects/{project}/locations/{location}/clusters/{cluster}/instances/{instance}".format( project=project, location=location, @@ -32368,10 +32405,10 @@ def test_instance_path(): def test_parse_instance_path(): expected = { - "project": "cuttlefish", - "location": "mussel", - "cluster": "winkle", - "instance": "nautilus", + "project": "whelk", + "location": "octopus", + "cluster": "oyster", + "instance": "nudibranch", } path = AlloyDBAdminClient.instance_path(**expected) @@ -32381,8 +32418,8 @@ def test_parse_instance_path(): def test_network_path(): - project = "scallop" - network = "abalone" + project = "cuttlefish" + network = "mussel" expected = "projects/{project}/global/networks/{network}".format( project=project, network=network, @@ -32393,8 +32430,8 @@ def test_network_path(): def test_parse_network_path(): expected = { - "project": "squid", - "network": "clam", + "project": "winkle", + "network": "nautilus", } path = AlloyDBAdminClient.network_path(**expected) @@ -32403,10 +32440,38 @@ def test_parse_network_path(): assert expected == actual +def test_service_attachment_path(): + project = "scallop" + region = "abalone" + service_attachment = "squid" + expected = "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}".format( + project=project, + region=region, + service_attachment=service_attachment, + ) + actual = AlloyDBAdminClient.service_attachment_path( + project, region, service_attachment + ) + assert expected == actual + + +def test_parse_service_attachment_path(): + expected = { + "project": "clam", + "region": "whelk", + "service_attachment": "octopus", + } + path = AlloyDBAdminClient.service_attachment_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBAdminClient.parse_service_attachment_path(path) + assert expected == actual + + def test_supported_database_flag_path(): - project = "whelk" - location = "octopus" - flag = "oyster" + project = "oyster" + location = "nudibranch" + flag = "cuttlefish" expected = "projects/{project}/locations/{location}/flags/{flag}".format( project=project, location=location, @@ -32418,9 +32483,9 @@ def test_supported_database_flag_path(): def test_parse_supported_database_flag_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "flag": "mussel", + "project": "mussel", + "location": "winkle", + "flag": "nautilus", } path = AlloyDBAdminClient.supported_database_flag_path(**expected) @@ -32430,10 +32495,10 @@ def test_parse_supported_database_flag_path(): def test_user_path(): - project = "winkle" - location = "nautilus" - cluster = "scallop" - user = "abalone" + project = "scallop" + location = "abalone" + cluster = "squid" + user = "clam" expected = "projects/{project}/locations/{location}/clusters/{cluster}/users/{user}".format( project=project, location=location, @@ -32446,10 +32511,10 @@ def test_user_path(): def test_parse_user_path(): expected = { - "project": "squid", - "location": "clam", - "cluster": "whelk", - "user": "octopus", + "project": "whelk", + "location": "octopus", + "cluster": "oyster", + "user": "nudibranch", } path = AlloyDBAdminClient.user_path(**expected) @@ -32459,7 +32524,7 @@ def test_parse_user_path(): def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "cuttlefish" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -32469,7 +32534,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "mussel", } path = AlloyDBAdminClient.common_billing_account_path(**expected) @@ -32479,7 +32544,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "winkle" expected = "folders/{folder}".format( folder=folder, ) @@ -32489,7 +32554,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "nautilus", } path = AlloyDBAdminClient.common_folder_path(**expected) @@ -32499,7 +32564,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "scallop" expected = "organizations/{organization}".format( organization=organization, ) @@ -32509,7 +32574,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "abalone", } path = AlloyDBAdminClient.common_organization_path(**expected) @@ -32519,7 +32584,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "squid" expected = "projects/{project}".format( project=project, ) @@ -32529,7 +32594,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "clam", } path = AlloyDBAdminClient.common_project_path(**expected) @@ -32539,8 +32604,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "whelk" + location = "octopus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -32551,8 +32616,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "oyster", + "location": "nudibranch", } path = AlloyDBAdminClient.common_location_path(**expected) diff --git a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_dbcsql_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_dbcsql_admin.py index 4535190ea2c8..e772a46d4b9f 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_dbcsql_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_dbcsql_admin.py @@ -2955,12 +2955,43 @@ def test_parse_cluster_path(): assert expected == actual -def test_crypto_key_version_path(): +def test_crypto_key_path(): project = "squid" location = "clam" key_ring = "whelk" crypto_key = "octopus" - crypto_key_version = "oyster" + expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + actual = AlloyDBCSQLAdminClient.crypto_key_path( + project, location, key_ring, crypto_key + ) + assert expected == actual + + +def test_parse_crypto_key_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "key_ring": "cuttlefish", + "crypto_key": "mussel", + } + path = AlloyDBCSQLAdminClient.crypto_key_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBCSQLAdminClient.parse_crypto_key_path(path) + assert expected == actual + + +def test_crypto_key_version_path(): + project = "winkle" + location = "nautilus" + key_ring = "scallop" + crypto_key = "abalone" + crypto_key_version = "squid" expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format( project=project, location=location, @@ -2976,11 +3007,11 @@ def test_crypto_key_version_path(): def test_parse_crypto_key_version_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "key_ring": "mussel", - "crypto_key": "winkle", - "crypto_key_version": "nautilus", + "project": "clam", + "location": "whelk", + "key_ring": "octopus", + "crypto_key": "oyster", + "crypto_key_version": "nudibranch", } path = AlloyDBCSQLAdminClient.crypto_key_version_path(**expected) @@ -2990,8 +3021,8 @@ def test_parse_crypto_key_version_path(): def test_network_path(): - project = "scallop" - network = "abalone" + project = "cuttlefish" + network = "mussel" expected = "projects/{project}/global/networks/{network}".format( project=project, network=network, @@ -3002,8 +3033,8 @@ def test_network_path(): def test_parse_network_path(): expected = { - "project": "squid", - "network": "clam", + "project": "winkle", + "network": "nautilus", } path = AlloyDBCSQLAdminClient.network_path(**expected) @@ -3013,7 +3044,7 @@ def test_parse_network_path(): def test_common_billing_account_path(): - billing_account = "whelk" + billing_account = "scallop" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3023,7 +3054,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "octopus", + "billing_account": "abalone", } path = AlloyDBCSQLAdminClient.common_billing_account_path(**expected) @@ -3033,7 +3064,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "oyster" + folder = "squid" expected = "folders/{folder}".format( folder=folder, ) @@ -3043,7 +3074,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nudibranch", + "folder": "clam", } path = AlloyDBCSQLAdminClient.common_folder_path(**expected) @@ -3053,7 +3084,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "cuttlefish" + organization = "whelk" expected = "organizations/{organization}".format( organization=organization, ) @@ -3063,7 +3094,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "mussel", + "organization": "octopus", } path = AlloyDBCSQLAdminClient.common_organization_path(**expected) @@ -3073,7 +3104,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "winkle" + project = "oyster" expected = "projects/{project}".format( project=project, ) @@ -3083,7 +3114,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nautilus", + "project": "nudibranch", } path = AlloyDBCSQLAdminClient.common_project_path(**expected) @@ -3093,8 +3124,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "scallop" - location = "abalone" + project = "cuttlefish" + location = "mussel" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -3105,8 +3136,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "squid", - "location": "clam", + "project": "winkle", + "location": "nautilus", } path = AlloyDBCSQLAdminClient.common_location_path(**expected) diff --git a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_db_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_db_admin.py index d19585249983..48134743e11d 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_db_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_db_admin.py @@ -14954,6 +14954,371 @@ async def test_list_databases_async_pages(): assert page_.raw_page.next_page_token == token +@pytest.mark.parametrize( + "request_type", + [ + service.CreateDatabaseRequest, + dict, + ], +) +def test_create_database(request_type, transport: str = "grpc"): + client = AlloyDBAdminClient( + 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.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Database( + name="name_value", + charset="charset_value", + collation="collation_value", + character_type="character_type_value", + is_template=True, + database_template="database_template_value", + is_template_database=True, + ) + response = client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = service.CreateDatabaseRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Database) + assert response.name == "name_value" + assert response.charset == "charset_value" + assert response.collation == "collation_value" + assert response.character_type == "character_type_value" + assert response.is_template is True + assert response.database_template == "database_template_value" + assert response.is_template_database is True + + +def test_create_database_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 = AlloyDBAdminClient( + 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 = service.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_database(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + +def test_create_database_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 = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # 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_database 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_database] = mock_rpc + request = {} + client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_database(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_create_database_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 = AlloyDBAdminAsyncClient( + 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.create_database + 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.create_database + ] = mock_rpc + + request = {} + await client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.create_database(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_create_database_async( + transport: str = "grpc_asyncio", request_type=service.CreateDatabaseRequest +): + client = AlloyDBAdminAsyncClient( + 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.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Database( + name="name_value", + charset="charset_value", + collation="collation_value", + character_type="character_type_value", + is_template=True, + database_template="database_template_value", + is_template_database=True, + ) + ) + response = await client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = service.CreateDatabaseRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Database) + assert response.name == "name_value" + assert response.charset == "charset_value" + assert response.collation == "collation_value" + assert response.character_type == "character_type_value" + assert response.is_template is True + assert response.database_template == "database_template_value" + assert response.is_template_database is True + + +@pytest.mark.asyncio +async def test_create_database_async_from_dict(): + await test_create_database_async(request_type=dict) + + +def test_create_database_field_headers(): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # 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 = service.CreateDatabaseRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + call.return_value = resources.Database() + client.create_database(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", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_database_field_headers_async(): + client = AlloyDBAdminAsyncClient( + 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 = service.CreateDatabaseRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Database()) + await client.create_database(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_database_flattened(): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Database() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_database( + parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_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].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].database + mock_val = resources.Database(name="name_value") + assert arg == mock_val + arg = args[0].database_id + mock_val = "database_id_value" + assert arg == mock_val + + +def test_create_database_flattened_error(): + client = AlloyDBAdminClient( + 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_database( + service.CreateDatabaseRequest(), + parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_value", + ) + + +@pytest.mark.asyncio +async def test_create_database_flattened_async(): + client = AlloyDBAdminAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Database() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Database()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_database( + parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_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 + arg = args[0].database + mock_val = resources.Database(name="name_value") + assert arg == mock_val + arg = args[0].database_id + mock_val = "database_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_database_flattened_error_async(): + client = AlloyDBAdminAsyncClient( + 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_database( + service.CreateDatabaseRequest(), + parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_value", + ) + + def test_list_clusters_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call @@ -22227,11 +22592,272 @@ def test_list_databases_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_list_databases_rest_required_fields(request_type=service.ListDatabasesRequest): +def test_list_databases_rest_required_fields(request_type=service.ListDatabasesRequest): + transport_class = transports.AlloyDBAdminRestTransport + + 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_databases._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_databases._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "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 = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = service.ListDatabasesResponse() + # 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 = service.ListDatabasesResponse.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_databases(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_databases_rest_unset_required_fields(): + transport = transports.AlloyDBAdminRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_databases._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_databases_rest_flattened(): + client = AlloyDBAdminClient( + 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 = service.ListDatabasesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/clusters/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 = service.ListDatabasesResponse.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_databases(**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/v1alpha/{parent=projects/*/locations/*/clusters/*}/databases" + % client.transport._host, + args[1], + ) + + +def test_list_databases_rest_flattened_error(transport: str = "rest"): + client = AlloyDBAdminClient( + 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_databases( + service.ListDatabasesRequest(), + parent="parent_value", + ) + + +def test_list_databases_rest_pager(transport: str = "rest"): + client = AlloyDBAdminClient( + 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 = ( + service.ListDatabasesResponse( + databases=[ + resources.Database(), + resources.Database(), + resources.Database(), + ], + next_page_token="abc", + ), + service.ListDatabasesResponse( + databases=[], + next_page_token="def", + ), + service.ListDatabasesResponse( + databases=[ + resources.Database(), + ], + next_page_token="ghi", + ), + service.ListDatabasesResponse( + databases=[ + resources.Database(), + resources.Database(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(service.ListDatabasesResponse.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/clusters/sample3" + } + + pager = client.list_databases(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Database) for i in results) + + pages = list(client.list_databases(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_create_database_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 = AlloyDBAdminClient( + 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_database 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_database] = mock_rpc + + request = {} + client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_database(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_database_rest_required_fields( + request_type=service.CreateDatabaseRequest, +): transport_class = transports.AlloyDBAdminRestTransport request_init = {} request_init["parent"] = "" + request_init["database_id"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -22239,32 +22865,32 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR ) # verify fields with default values are dropped + assert "databaseId" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_databases._get_unset_required_fields(jsonified_request) + ).create_database._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + assert "databaseId" in jsonified_request + assert jsonified_request["databaseId"] == request_init["database_id"] jsonified_request["parent"] = "parent_value" + jsonified_request["databaseId"] = "database_id_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_databases._get_unset_required_fields(jsonified_request) + ).create_database._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "page_size", - "page_token", - ) - ) + assert not set(unset_fields) - set(("database_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 "databaseId" in jsonified_request + assert jsonified_request["databaseId"] == "database_id_value" client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), @@ -22273,7 +22899,7 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = service.ListDatabasesResponse() + return_value = resources.Database() # 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 @@ -22285,48 +22911,55 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR 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 = service.ListDatabasesResponse.pb(return_value) + return_value = resources.Database.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_databases(request) + response = client.create_database(request) - expected_params = [("$alt", "json;enum-encoding=int")] + expected_params = [ + ( + "databaseId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_databases_rest_unset_required_fields(): +def test_create_database_rest_unset_required_fields(): transport = transports.AlloyDBAdminRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_databases._get_unset_required_fields({}) + unset_fields = transport.create_database._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(("databaseId",)) + & set( ( - "filter", - "pageSize", - "pageToken", + "parent", + "databaseId", + "database", ) ) - & set(("parent",)) ) -def test_list_databases_rest_flattened(): +def test_create_database_rest_flattened(): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -22335,7 +22968,7 @@ def test_list_databases_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 = service.ListDatabasesResponse() + return_value = resources.Database() # get arguments that satisfy an http rule for this method sample_request = { @@ -22345,6 +22978,8 @@ def test_list_databases_rest_flattened(): # get truthy value for each flattened field mock_args = dict( parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_value", ) mock_args.update(sample_request) @@ -22352,13 +22987,13 @@ def test_list_databases_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = service.ListDatabasesResponse.pb(return_value) + return_value = resources.Database.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_databases(**mock_args) + client.create_database(**mock_args) # Establish that the underlying call was made with the expected # request object values. @@ -22371,7 +23006,7 @@ def test_list_databases_rest_flattened(): ) -def test_list_databases_rest_flattened_error(transport: str = "rest"): +def test_create_database_rest_flattened_error(transport: str = "rest"): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -22380,75 +23015,14 @@ def test_list_databases_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_databases( - service.ListDatabasesRequest(), + client.create_database( + service.CreateDatabaseRequest(), parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_value", ) -def test_list_databases_rest_pager(transport: str = "rest"): - client = AlloyDBAdminClient( - 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 = ( - service.ListDatabasesResponse( - databases=[ - resources.Database(), - resources.Database(), - resources.Database(), - ], - next_page_token="abc", - ), - service.ListDatabasesResponse( - databases=[], - next_page_token="def", - ), - service.ListDatabasesResponse( - databases=[ - resources.Database(), - ], - next_page_token="ghi", - ), - service.ListDatabasesResponse( - databases=[ - resources.Database(), - resources.Database(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(service.ListDatabasesResponse.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/clusters/sample3" - } - - pager = client.list_databases(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Database) for i in results) - - pages = list(client.list_databases(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.AlloyDBAdminGrpcTransport( @@ -23348,6 +23922,27 @@ def test_list_databases_empty_call_grpc(): 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_database_empty_call_grpc(): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + call.return_value = resources.Database() + client.create_database(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = service.CreateDatabaseRequest() + + assert args[0] == request_msg + + def test_transport_kind_grpc_asyncio(): transport = AlloyDBAdminAsyncClient.get_transport_class("grpc_asyncio")( credentials=async_anonymous_credentials() @@ -24391,6 +24986,39 @@ async def test_list_databases_empty_call_grpc_asyncio(): 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_database_empty_call_grpc_asyncio(): + client = AlloyDBAdminAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Database( + name="name_value", + charset="charset_value", + collation="collation_value", + character_type="character_type_value", + is_template=True, + database_template="database_template_value", + is_template_database=True, + ) + ) + await client.create_database(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = service.CreateDatabaseRequest() + + assert args[0] == request_msg + + def test_transport_kind_rest(): transport = AlloyDBAdminClient.get_transport_class("rest")( credentials=ga_credentials.AnonymousCredentials() @@ -26782,7 +27410,7 @@ def test_create_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, - "connection_pool_config": {"enabled": True}, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, "gca_config": {"gca_entitlement": 1}, } # The version of a generated dependency at test runtime may differ from the version used during generation. @@ -27058,7 +27686,7 @@ def test_create_secondary_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, - "connection_pool_config": {"enabled": True}, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, "gca_config": {"gca_entitlement": 1}, } # The version of a generated dependency at test runtime may differ from the version used during generation. @@ -27349,7 +27977,11 @@ def test_batch_create_instances_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, - "connection_pool_config": {"enabled": True}, + "connection_pool_config": { + "enabled": True, + "flags": {}, + "pooler_count": 1305, + }, "gca_config": {"gca_entitlement": 1}, }, "request_id": "request_id_value", @@ -27639,7 +28271,7 @@ def test_update_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, - "connection_pool_config": {"enabled": True}, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, "gca_config": {"gca_entitlement": 1}, } # The version of a generated dependency at test runtime may differ from the version used during generation. @@ -30293,9 +30925,124 @@ def test_update_user_rest_interceptors(null_interceptor): transports.AlloyDBAdminRestInterceptor, "pre_update_user" ) as pre: pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = service.UpdateUserRequest.pb(service.UpdateUserRequest()) + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = service.UpdateUserRequest.pb(service.UpdateUserRequest()) + 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 = resources.User.to_json(resources.User()) + req.return_value.content = return_value + + request = service.UpdateUserRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.User() + post_with_metadata.return_value = resources.User(), metadata + + client.update_user( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/clusters/sample3/users/sample4" + } + 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_user(request) + + +@pytest.mark.parametrize( + "request_type", + [ + service.DeleteUserRequest, + dict, + ], +) +def test_delete_user_rest_call_success(request_type): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/clusters/sample3/users/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 = None + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + 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_user(request) + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_user_rest_interceptors(null_interceptor): + transport = transports.AlloyDBAdminRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AlloyDBAdminRestInterceptor(), + ) + client = AlloyDBAdminClient(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.AlloyDBAdminRestInterceptor, "pre_delete_user" + ) as pre: + pre.assert_not_called() + pb_message = service.DeleteUserRequest.pb(service.DeleteUserRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -30306,19 +31053,15 @@ def test_update_user_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 = resources.User.to_json(resources.User()) - req.return_value.content = return_value - request = service.UpdateUserRequest() + request = service.DeleteUserRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.User() - post_with_metadata.return_value = resources.User(), metadata - client.update_user( + client.delete_user( request, metadata=[ ("key", "val"), @@ -30327,18 +31070,14 @@ def test_update_user_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() -def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): +def test_list_databases_rest_bad_request(request_type=service.ListDatabasesRequest): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/clusters/sample3/users/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2/clusters/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30353,47 +31092,51 @@ def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_user(request) + client.list_databases(request) @pytest.mark.parametrize( "request_type", [ - service.DeleteUserRequest, + service.ListDatabasesRequest, dict, ], ) -def test_delete_user_rest_call_success(request_type): +def test_list_databases_rest_call_success(request_type): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/clusters/sample3/users/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2/clusters/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 = service.ListDatabasesResponse( + next_page_token="next_page_token_value", + ) # 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 = service.ListDatabasesResponse.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_user(request) + response = client.list_databases(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, pagers.ListDatabasesPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_user_rest_interceptors(null_interceptor): +def test_list_databases_rest_interceptors(null_interceptor): transport = transports.AlloyDBAdminRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30407,10 +31150,16 @@ def test_delete_user_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AlloyDBAdminRestInterceptor, "pre_delete_user" + transports.AlloyDBAdminRestInterceptor, "post_list_databases" + ) as post, mock.patch.object( + transports.AlloyDBAdminRestInterceptor, "post_list_databases_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.AlloyDBAdminRestInterceptor, "pre_list_databases" ) as pre: pre.assert_not_called() - pb_message = service.DeleteUserRequest.pb(service.DeleteUserRequest()) + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = service.ListDatabasesRequest.pb(service.ListDatabasesRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -30421,15 +31170,21 @@ def test_delete_user_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 = service.ListDatabasesResponse.to_json( + service.ListDatabasesResponse() + ) + req.return_value.content = return_value - request = service.DeleteUserRequest() + request = service.ListDatabasesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = service.ListDatabasesResponse() + post_with_metadata.return_value = service.ListDatabasesResponse(), metadata - client.delete_user( + client.list_databases( request, metadata=[ ("key", "val"), @@ -30438,9 +31193,11 @@ def test_delete_user_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_list_databases_rest_bad_request(request_type=service.ListDatabasesRequest): +def test_create_database_rest_bad_request(request_type=service.CreateDatabaseRequest): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -30460,30 +31217,112 @@ def test_list_databases_rest_bad_request(request_type=service.ListDatabasesReque response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_databases(request) + client.create_database(request) @pytest.mark.parametrize( "request_type", [ - service.ListDatabasesRequest, + service.CreateDatabaseRequest, dict, ], ) -def test_list_databases_rest_call_success(request_type): +def test_create_database_rest_call_success(request_type): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2/clusters/sample3"} + request_init["database"] = { + "name": "name_value", + "charset": "charset_value", + "collation": "collation_value", + "character_type": "character_type_value", + "is_template": True, + "database_template": "database_template_value", + "is_template_database": 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 = service.CreateDatabaseRequest.meta.fields["database"] + + 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["database"].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["database"][field])): + del request_init["database"][field][i][subfield] + else: + del request_init["database"][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 = service.ListDatabasesResponse( - next_page_token="next_page_token_value", + return_value = resources.Database( + name="name_value", + charset="charset_value", + collation="collation_value", + character_type="character_type_value", + is_template=True, + database_template="database_template_value", + is_template_database=True, ) # Wrap the value into a proper Response obj @@ -30491,20 +31330,26 @@ def test_list_databases_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = service.ListDatabasesResponse.pb(return_value) + return_value = resources.Database.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_databases(request) + response = client.create_database(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDatabasesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.Database) + assert response.name == "name_value" + assert response.charset == "charset_value" + assert response.collation == "collation_value" + assert response.character_type == "character_type_value" + assert response.is_template is True + assert response.database_template == "database_template_value" + assert response.is_template_database is True @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_databases_rest_interceptors(null_interceptor): +def test_create_database_rest_interceptors(null_interceptor): transport = transports.AlloyDBAdminRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30518,16 +31363,16 @@ def test_list_databases_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AlloyDBAdminRestInterceptor, "post_list_databases" + transports.AlloyDBAdminRestInterceptor, "post_create_database" ) as post, mock.patch.object( - transports.AlloyDBAdminRestInterceptor, "post_list_databases_with_metadata" + transports.AlloyDBAdminRestInterceptor, "post_create_database_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.AlloyDBAdminRestInterceptor, "pre_list_databases" + transports.AlloyDBAdminRestInterceptor, "pre_create_database" ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = service.ListDatabasesRequest.pb(service.ListDatabasesRequest()) + pb_message = service.CreateDatabaseRequest.pb(service.CreateDatabaseRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -30538,21 +31383,19 @@ def test_list_databases_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 = service.ListDatabasesResponse.to_json( - service.ListDatabasesResponse() - ) + return_value = resources.Database.to_json(resources.Database()) req.return_value.content = return_value - request = service.ListDatabasesRequest() + request = service.CreateDatabaseRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = service.ListDatabasesResponse() - post_with_metadata.return_value = service.ListDatabasesResponse(), metadata + post.return_value = resources.Database() + post_with_metadata.return_value = resources.Database(), metadata - client.list_databases( + client.create_database( request, metadata=[ ("key", "val"), @@ -31696,6 +32539,26 @@ def test_list_databases_empty_call_rest(): 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_database_empty_call_rest(): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + client.create_database(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = service.CreateDatabaseRequest() + + assert args[0] == request_msg + + def test_alloy_db_admin_rest_lro_client(): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31783,6 +32646,7 @@ def test_alloy_db_admin_base_transport(): "update_user", "delete_user", "list_databases", + "create_database", "get_location", "list_locations", "get_operation", @@ -32160,6 +33024,9 @@ def test_alloy_db_admin_client_transport_session_collision(transport_name): session1 = client1.transport.list_databases._session session2 = client2.transport.list_databases._session assert session1 != session2 + session1 = client1.transport.create_database._session + session2 = client2.transport.create_database._session + assert session1 != session2 def test_alloy_db_admin_grpc_transport_channel(): @@ -32397,12 +33264,41 @@ def test_parse_connection_info_path(): assert expected == actual -def test_crypto_key_version_path(): +def test_crypto_key_path(): project = "winkle" location = "nautilus" key_ring = "scallop" crypto_key = "abalone" - crypto_key_version = "squid" + expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + actual = AlloyDBAdminClient.crypto_key_path(project, location, key_ring, crypto_key) + assert expected == actual + + +def test_parse_crypto_key_path(): + expected = { + "project": "squid", + "location": "clam", + "key_ring": "whelk", + "crypto_key": "octopus", + } + path = AlloyDBAdminClient.crypto_key_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBAdminClient.parse_crypto_key_path(path) + assert expected == actual + + +def test_crypto_key_version_path(): + project = "oyster" + location = "nudibranch" + key_ring = "cuttlefish" + crypto_key = "mussel" + crypto_key_version = "winkle" expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format( project=project, location=location, @@ -32418,11 +33314,11 @@ def test_crypto_key_version_path(): def test_parse_crypto_key_version_path(): expected = { - "project": "clam", - "location": "whelk", - "key_ring": "octopus", - "crypto_key": "oyster", - "crypto_key_version": "nudibranch", + "project": "nautilus", + "location": "scallop", + "key_ring": "abalone", + "crypto_key": "squid", + "crypto_key_version": "clam", } path = AlloyDBAdminClient.crypto_key_version_path(**expected) @@ -32432,10 +33328,10 @@ def test_parse_crypto_key_version_path(): def test_database_path(): - project = "cuttlefish" - location = "mussel" - cluster = "winkle" - database = "nautilus" + project = "whelk" + location = "octopus" + cluster = "oyster" + database = "nudibranch" expected = "projects/{project}/locations/{location}/clusters/{cluster}/databases/{database}".format( project=project, location=location, @@ -32448,10 +33344,10 @@ def test_database_path(): def test_parse_database_path(): expected = { - "project": "scallop", - "location": "abalone", - "cluster": "squid", - "database": "clam", + "project": "cuttlefish", + "location": "mussel", + "cluster": "winkle", + "database": "nautilus", } path = AlloyDBAdminClient.database_path(**expected) @@ -32461,10 +33357,10 @@ def test_parse_database_path(): def test_instance_path(): - project = "whelk" - location = "octopus" - cluster = "oyster" - instance = "nudibranch" + project = "scallop" + location = "abalone" + cluster = "squid" + instance = "clam" expected = "projects/{project}/locations/{location}/clusters/{cluster}/instances/{instance}".format( project=project, location=location, @@ -32477,10 +33373,10 @@ def test_instance_path(): def test_parse_instance_path(): expected = { - "project": "cuttlefish", - "location": "mussel", - "cluster": "winkle", - "instance": "nautilus", + "project": "whelk", + "location": "octopus", + "cluster": "oyster", + "instance": "nudibranch", } path = AlloyDBAdminClient.instance_path(**expected) @@ -32490,8 +33386,8 @@ def test_parse_instance_path(): def test_network_path(): - project = "scallop" - network = "abalone" + project = "cuttlefish" + network = "mussel" expected = "projects/{project}/global/networks/{network}".format( project=project, network=network, @@ -32502,8 +33398,8 @@ def test_network_path(): def test_parse_network_path(): expected = { - "project": "squid", - "network": "clam", + "project": "winkle", + "network": "nautilus", } path = AlloyDBAdminClient.network_path(**expected) @@ -32512,10 +33408,38 @@ def test_parse_network_path(): assert expected == actual +def test_service_attachment_path(): + project = "scallop" + region = "abalone" + service_attachment = "squid" + expected = "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}".format( + project=project, + region=region, + service_attachment=service_attachment, + ) + actual = AlloyDBAdminClient.service_attachment_path( + project, region, service_attachment + ) + assert expected == actual + + +def test_parse_service_attachment_path(): + expected = { + "project": "clam", + "region": "whelk", + "service_attachment": "octopus", + } + path = AlloyDBAdminClient.service_attachment_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBAdminClient.parse_service_attachment_path(path) + assert expected == actual + + def test_supported_database_flag_path(): - project = "whelk" - location = "octopus" - flag = "oyster" + project = "oyster" + location = "nudibranch" + flag = "cuttlefish" expected = "projects/{project}/locations/{location}/flags/{flag}".format( project=project, location=location, @@ -32527,9 +33451,9 @@ def test_supported_database_flag_path(): def test_parse_supported_database_flag_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "flag": "mussel", + "project": "mussel", + "location": "winkle", + "flag": "nautilus", } path = AlloyDBAdminClient.supported_database_flag_path(**expected) @@ -32539,10 +33463,10 @@ def test_parse_supported_database_flag_path(): def test_user_path(): - project = "winkle" - location = "nautilus" - cluster = "scallop" - user = "abalone" + project = "scallop" + location = "abalone" + cluster = "squid" + user = "clam" expected = "projects/{project}/locations/{location}/clusters/{cluster}/users/{user}".format( project=project, location=location, @@ -32555,10 +33479,10 @@ def test_user_path(): def test_parse_user_path(): expected = { - "project": "squid", - "location": "clam", - "cluster": "whelk", - "user": "octopus", + "project": "whelk", + "location": "octopus", + "cluster": "oyster", + "user": "nudibranch", } path = AlloyDBAdminClient.user_path(**expected) @@ -32568,7 +33492,7 @@ def test_parse_user_path(): def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "cuttlefish" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -32578,7 +33502,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "mussel", } path = AlloyDBAdminClient.common_billing_account_path(**expected) @@ -32588,7 +33512,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "winkle" expected = "folders/{folder}".format( folder=folder, ) @@ -32598,7 +33522,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "nautilus", } path = AlloyDBAdminClient.common_folder_path(**expected) @@ -32608,7 +33532,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "scallop" expected = "organizations/{organization}".format( organization=organization, ) @@ -32618,7 +33542,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "abalone", } path = AlloyDBAdminClient.common_organization_path(**expected) @@ -32628,7 +33552,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "squid" expected = "projects/{project}".format( project=project, ) @@ -32638,7 +33562,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "clam", } path = AlloyDBAdminClient.common_project_path(**expected) @@ -32648,8 +33572,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "whelk" + location = "octopus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -32660,8 +33584,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "oyster", + "location": "nudibranch", } path = AlloyDBAdminClient.common_location_path(**expected) diff --git a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_dbcsql_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_dbcsql_admin.py index 979ddd5ee99d..4bb77ef23364 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_dbcsql_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_dbcsql_admin.py @@ -2956,12 +2956,43 @@ def test_parse_cluster_path(): assert expected == actual -def test_crypto_key_version_path(): +def test_crypto_key_path(): project = "squid" location = "clam" key_ring = "whelk" crypto_key = "octopus" - crypto_key_version = "oyster" + expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + actual = AlloyDBCSQLAdminClient.crypto_key_path( + project, location, key_ring, crypto_key + ) + assert expected == actual + + +def test_parse_crypto_key_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "key_ring": "cuttlefish", + "crypto_key": "mussel", + } + path = AlloyDBCSQLAdminClient.crypto_key_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBCSQLAdminClient.parse_crypto_key_path(path) + assert expected == actual + + +def test_crypto_key_version_path(): + project = "winkle" + location = "nautilus" + key_ring = "scallop" + crypto_key = "abalone" + crypto_key_version = "squid" expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format( project=project, location=location, @@ -2977,11 +3008,11 @@ def test_crypto_key_version_path(): def test_parse_crypto_key_version_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "key_ring": "mussel", - "crypto_key": "winkle", - "crypto_key_version": "nautilus", + "project": "clam", + "location": "whelk", + "key_ring": "octopus", + "crypto_key": "oyster", + "crypto_key_version": "nudibranch", } path = AlloyDBCSQLAdminClient.crypto_key_version_path(**expected) @@ -2991,8 +3022,8 @@ def test_parse_crypto_key_version_path(): def test_network_path(): - project = "scallop" - network = "abalone" + project = "cuttlefish" + network = "mussel" expected = "projects/{project}/global/networks/{network}".format( project=project, network=network, @@ -3003,8 +3034,8 @@ def test_network_path(): def test_parse_network_path(): expected = { - "project": "squid", - "network": "clam", + "project": "winkle", + "network": "nautilus", } path = AlloyDBCSQLAdminClient.network_path(**expected) @@ -3014,7 +3045,7 @@ def test_parse_network_path(): def test_common_billing_account_path(): - billing_account = "whelk" + billing_account = "scallop" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3024,7 +3055,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "octopus", + "billing_account": "abalone", } path = AlloyDBCSQLAdminClient.common_billing_account_path(**expected) @@ -3034,7 +3065,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "oyster" + folder = "squid" expected = "folders/{folder}".format( folder=folder, ) @@ -3044,7 +3075,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nudibranch", + "folder": "clam", } path = AlloyDBCSQLAdminClient.common_folder_path(**expected) @@ -3054,7 +3085,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "cuttlefish" + organization = "whelk" expected = "organizations/{organization}".format( organization=organization, ) @@ -3064,7 +3095,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "mussel", + "organization": "octopus", } path = AlloyDBCSQLAdminClient.common_organization_path(**expected) @@ -3074,7 +3105,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "winkle" + project = "oyster" expected = "projects/{project}".format( project=project, ) @@ -3084,7 +3115,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nautilus", + "project": "nudibranch", } path = AlloyDBCSQLAdminClient.common_project_path(**expected) @@ -3094,8 +3125,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "scallop" - location = "abalone" + project = "cuttlefish" + location = "mussel" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -3106,8 +3137,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "squid", - "location": "clam", + "project": "winkle", + "location": "nautilus", } path = AlloyDBCSQLAdminClient.common_location_path(**expected) diff --git a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_db_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_db_admin.py index 0241b0866dd5..b24df828a260 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_db_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_db_admin.py @@ -14942,6 +14942,371 @@ async def test_list_databases_async_pages(): assert page_.raw_page.next_page_token == token +@pytest.mark.parametrize( + "request_type", + [ + service.CreateDatabaseRequest, + dict, + ], +) +def test_create_database(request_type, transport: str = "grpc"): + client = AlloyDBAdminClient( + 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.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Database( + name="name_value", + charset="charset_value", + collation="collation_value", + character_type="character_type_value", + is_template=True, + database_template="database_template_value", + is_template_database=True, + ) + response = client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = service.CreateDatabaseRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Database) + assert response.name == "name_value" + assert response.charset == "charset_value" + assert response.collation == "collation_value" + assert response.character_type == "character_type_value" + assert response.is_template is True + assert response.database_template == "database_template_value" + assert response.is_template_database is True + + +def test_create_database_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 = AlloyDBAdminClient( + 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 = service.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_database(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.CreateDatabaseRequest( + parent="parent_value", + database_id="database_id_value", + ) + + +def test_create_database_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 = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # 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_database 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_database] = mock_rpc + request = {} + client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_database(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_create_database_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 = AlloyDBAdminAsyncClient( + 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.create_database + 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.create_database + ] = mock_rpc + + request = {} + await client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.create_database(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_create_database_async( + transport: str = "grpc_asyncio", request_type=service.CreateDatabaseRequest +): + client = AlloyDBAdminAsyncClient( + 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.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Database( + name="name_value", + charset="charset_value", + collation="collation_value", + character_type="character_type_value", + is_template=True, + database_template="database_template_value", + is_template_database=True, + ) + ) + response = await client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = service.CreateDatabaseRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Database) + assert response.name == "name_value" + assert response.charset == "charset_value" + assert response.collation == "collation_value" + assert response.character_type == "character_type_value" + assert response.is_template is True + assert response.database_template == "database_template_value" + assert response.is_template_database is True + + +@pytest.mark.asyncio +async def test_create_database_async_from_dict(): + await test_create_database_async(request_type=dict) + + +def test_create_database_field_headers(): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # 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 = service.CreateDatabaseRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + call.return_value = resources.Database() + client.create_database(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", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_database_field_headers_async(): + client = AlloyDBAdminAsyncClient( + 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 = service.CreateDatabaseRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Database()) + await client.create_database(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_database_flattened(): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Database() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_database( + parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_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].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].database + mock_val = resources.Database(name="name_value") + assert arg == mock_val + arg = args[0].database_id + mock_val = "database_id_value" + assert arg == mock_val + + +def test_create_database_flattened_error(): + client = AlloyDBAdminClient( + 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_database( + service.CreateDatabaseRequest(), + parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_value", + ) + + +@pytest.mark.asyncio +async def test_create_database_flattened_async(): + client = AlloyDBAdminAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Database() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Database()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_database( + parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_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 + arg = args[0].database + mock_val = resources.Database(name="name_value") + assert arg == mock_val + arg = args[0].database_id + mock_val = "database_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_database_flattened_error_async(): + client = AlloyDBAdminAsyncClient( + 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_database( + service.CreateDatabaseRequest(), + parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_value", + ) + + def test_list_clusters_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call @@ -22215,11 +22580,272 @@ def test_list_databases_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_list_databases_rest_required_fields(request_type=service.ListDatabasesRequest): +def test_list_databases_rest_required_fields(request_type=service.ListDatabasesRequest): + transport_class = transports.AlloyDBAdminRestTransport + + 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_databases._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_databases._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "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 = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = service.ListDatabasesResponse() + # 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 = service.ListDatabasesResponse.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_databases(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_databases_rest_unset_required_fields(): + transport = transports.AlloyDBAdminRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_databases._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_databases_rest_flattened(): + client = AlloyDBAdminClient( + 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 = service.ListDatabasesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/clusters/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 = service.ListDatabasesResponse.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_databases(**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/v1beta/{parent=projects/*/locations/*/clusters/*}/databases" + % client.transport._host, + args[1], + ) + + +def test_list_databases_rest_flattened_error(transport: str = "rest"): + client = AlloyDBAdminClient( + 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_databases( + service.ListDatabasesRequest(), + parent="parent_value", + ) + + +def test_list_databases_rest_pager(transport: str = "rest"): + client = AlloyDBAdminClient( + 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 = ( + service.ListDatabasesResponse( + databases=[ + resources.Database(), + resources.Database(), + resources.Database(), + ], + next_page_token="abc", + ), + service.ListDatabasesResponse( + databases=[], + next_page_token="def", + ), + service.ListDatabasesResponse( + databases=[ + resources.Database(), + ], + next_page_token="ghi", + ), + service.ListDatabasesResponse( + databases=[ + resources.Database(), + resources.Database(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(service.ListDatabasesResponse.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/clusters/sample3" + } + + pager = client.list_databases(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Database) for i in results) + + pages = list(client.list_databases(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_create_database_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 = AlloyDBAdminClient( + 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_database 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_database] = mock_rpc + + request = {} + client.create_database(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_database(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_database_rest_required_fields( + request_type=service.CreateDatabaseRequest, +): transport_class = transports.AlloyDBAdminRestTransport request_init = {} request_init["parent"] = "" + request_init["database_id"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -22227,32 +22853,32 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR ) # verify fields with default values are dropped + assert "databaseId" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_databases._get_unset_required_fields(jsonified_request) + ).create_database._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + assert "databaseId" in jsonified_request + assert jsonified_request["databaseId"] == request_init["database_id"] jsonified_request["parent"] = "parent_value" + jsonified_request["databaseId"] = "database_id_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_databases._get_unset_required_fields(jsonified_request) + ).create_database._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "page_size", - "page_token", - ) - ) + assert not set(unset_fields) - set(("database_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 "databaseId" in jsonified_request + assert jsonified_request["databaseId"] == "database_id_value" client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), @@ -22261,7 +22887,7 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = service.ListDatabasesResponse() + return_value = resources.Database() # 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 @@ -22273,48 +22899,55 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR 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 = service.ListDatabasesResponse.pb(return_value) + return_value = resources.Database.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_databases(request) + response = client.create_database(request) - expected_params = [("$alt", "json;enum-encoding=int")] + expected_params = [ + ( + "databaseId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_databases_rest_unset_required_fields(): +def test_create_database_rest_unset_required_fields(): transport = transports.AlloyDBAdminRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_databases._get_unset_required_fields({}) + unset_fields = transport.create_database._get_unset_required_fields({}) assert set(unset_fields) == ( - set( + set(("databaseId",)) + & set( ( - "filter", - "pageSize", - "pageToken", + "parent", + "databaseId", + "database", ) ) - & set(("parent",)) ) -def test_list_databases_rest_flattened(): +def test_create_database_rest_flattened(): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -22323,7 +22956,7 @@ def test_list_databases_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 = service.ListDatabasesResponse() + return_value = resources.Database() # get arguments that satisfy an http rule for this method sample_request = { @@ -22333,6 +22966,8 @@ def test_list_databases_rest_flattened(): # get truthy value for each flattened field mock_args = dict( parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_value", ) mock_args.update(sample_request) @@ -22340,13 +22975,13 @@ def test_list_databases_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = service.ListDatabasesResponse.pb(return_value) + return_value = resources.Database.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_databases(**mock_args) + client.create_database(**mock_args) # Establish that the underlying call was made with the expected # request object values. @@ -22359,7 +22994,7 @@ def test_list_databases_rest_flattened(): ) -def test_list_databases_rest_flattened_error(transport: str = "rest"): +def test_create_database_rest_flattened_error(transport: str = "rest"): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -22368,75 +23003,14 @@ def test_list_databases_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_databases( - service.ListDatabasesRequest(), + client.create_database( + service.CreateDatabaseRequest(), parent="parent_value", + database=resources.Database(name="name_value"), + database_id="database_id_value", ) -def test_list_databases_rest_pager(transport: str = "rest"): - client = AlloyDBAdminClient( - 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 = ( - service.ListDatabasesResponse( - databases=[ - resources.Database(), - resources.Database(), - resources.Database(), - ], - next_page_token="abc", - ), - service.ListDatabasesResponse( - databases=[], - next_page_token="def", - ), - service.ListDatabasesResponse( - databases=[ - resources.Database(), - ], - next_page_token="ghi", - ), - service.ListDatabasesResponse( - databases=[ - resources.Database(), - resources.Database(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(service.ListDatabasesResponse.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/clusters/sample3" - } - - pager = client.list_databases(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Database) for i in results) - - pages = list(client.list_databases(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.AlloyDBAdminGrpcTransport( @@ -23336,6 +23910,27 @@ def test_list_databases_empty_call_grpc(): 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_database_empty_call_grpc(): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + call.return_value = resources.Database() + client.create_database(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = service.CreateDatabaseRequest() + + assert args[0] == request_msg + + def test_transport_kind_grpc_asyncio(): transport = AlloyDBAdminAsyncClient.get_transport_class("grpc_asyncio")( credentials=async_anonymous_credentials() @@ -24376,6 +24971,39 @@ async def test_list_databases_empty_call_grpc_asyncio(): 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_database_empty_call_grpc_asyncio(): + client = AlloyDBAdminAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Database( + name="name_value", + charset="charset_value", + collation="collation_value", + character_type="character_type_value", + is_template=True, + database_template="database_template_value", + is_template_database=True, + ) + ) + await client.create_database(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = service.CreateDatabaseRequest() + + assert args[0] == request_msg + + def test_transport_kind_rest(): transport = AlloyDBAdminClient.get_transport_class("rest")( credentials=ga_credentials.AnonymousCredentials() @@ -26759,7 +27387,7 @@ def test_create_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, - "connection_pool_config": {"enabled": True, "flags": {}}, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, "gca_config": {"gca_entitlement": 1}, } # The version of a generated dependency at test runtime may differ from the version used during generation. @@ -27034,7 +27662,7 @@ def test_create_secondary_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, - "connection_pool_config": {"enabled": True, "flags": {}}, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, "gca_config": {"gca_entitlement": 1}, } # The version of a generated dependency at test runtime may differ from the version used during generation. @@ -27324,7 +27952,11 @@ def test_batch_create_instances_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, - "connection_pool_config": {"enabled": True, "flags": {}}, + "connection_pool_config": { + "enabled": True, + "flags": {}, + "pooler_count": 1305, + }, "gca_config": {"gca_entitlement": 1}, }, "request_id": "request_id_value", @@ -27613,7 +28245,7 @@ def test_update_instance_rest_call_success(request_type): "outbound_public_ip_addresses_value2", ], "activation_policy": 1, - "connection_pool_config": {"enabled": True, "flags": {}}, + "connection_pool_config": {"enabled": True, "flags": {}, "pooler_count": 1305}, "gca_config": {"gca_entitlement": 1}, } # The version of a generated dependency at test runtime may differ from the version used during generation. @@ -30263,9 +30895,124 @@ def test_update_user_rest_interceptors(null_interceptor): transports.AlloyDBAdminRestInterceptor, "pre_update_user" ) as pre: pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = service.UpdateUserRequest.pb(service.UpdateUserRequest()) + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = service.UpdateUserRequest.pb(service.UpdateUserRequest()) + 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 = resources.User.to_json(resources.User()) + req.return_value.content = return_value + + request = service.UpdateUserRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.User() + post_with_metadata.return_value = resources.User(), metadata + + client.update_user( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/clusters/sample3/users/sample4" + } + 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_user(request) + + +@pytest.mark.parametrize( + "request_type", + [ + service.DeleteUserRequest, + dict, + ], +) +def test_delete_user_rest_call_success(request_type): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/clusters/sample3/users/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 = None + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + 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_user(request) + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_user_rest_interceptors(null_interceptor): + transport = transports.AlloyDBAdminRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.AlloyDBAdminRestInterceptor(), + ) + client = AlloyDBAdminClient(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.AlloyDBAdminRestInterceptor, "pre_delete_user" + ) as pre: + pre.assert_not_called() + pb_message = service.DeleteUserRequest.pb(service.DeleteUserRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -30276,19 +31023,15 @@ def test_update_user_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 = resources.User.to_json(resources.User()) - req.return_value.content = return_value - request = service.UpdateUserRequest() + request = service.DeleteUserRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = resources.User() - post_with_metadata.return_value = resources.User(), metadata - client.update_user( + client.delete_user( request, metadata=[ ("key", "val"), @@ -30297,18 +31040,14 @@ def test_update_user_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() -def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): +def test_list_databases_rest_bad_request(request_type=service.ListDatabasesRequest): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/clusters/sample3/users/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2/clusters/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -30323,47 +31062,51 @@ def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_user(request) + client.list_databases(request) @pytest.mark.parametrize( "request_type", [ - service.DeleteUserRequest, + service.ListDatabasesRequest, dict, ], ) -def test_delete_user_rest_call_success(request_type): +def test_list_databases_rest_call_success(request_type): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/clusters/sample3/users/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2/clusters/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 = service.ListDatabasesResponse( + next_page_token="next_page_token_value", + ) # 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 = service.ListDatabasesResponse.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_user(request) + response = client.list_databases(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, pagers.ListDatabasesPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_user_rest_interceptors(null_interceptor): +def test_list_databases_rest_interceptors(null_interceptor): transport = transports.AlloyDBAdminRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30377,10 +31120,16 @@ def test_delete_user_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AlloyDBAdminRestInterceptor, "pre_delete_user" + transports.AlloyDBAdminRestInterceptor, "post_list_databases" + ) as post, mock.patch.object( + transports.AlloyDBAdminRestInterceptor, "post_list_databases_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.AlloyDBAdminRestInterceptor, "pre_list_databases" ) as pre: pre.assert_not_called() - pb_message = service.DeleteUserRequest.pb(service.DeleteUserRequest()) + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = service.ListDatabasesRequest.pb(service.ListDatabasesRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -30391,15 +31140,21 @@ def test_delete_user_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 = service.ListDatabasesResponse.to_json( + service.ListDatabasesResponse() + ) + req.return_value.content = return_value - request = service.DeleteUserRequest() + request = service.ListDatabasesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = service.ListDatabasesResponse() + post_with_metadata.return_value = service.ListDatabasesResponse(), metadata - client.delete_user( + client.list_databases( request, metadata=[ ("key", "val"), @@ -30408,9 +31163,11 @@ def test_delete_user_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_list_databases_rest_bad_request(request_type=service.ListDatabasesRequest): +def test_create_database_rest_bad_request(request_type=service.CreateDatabaseRequest): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -30430,30 +31187,112 @@ def test_list_databases_rest_bad_request(request_type=service.ListDatabasesReque response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_databases(request) + client.create_database(request) @pytest.mark.parametrize( "request_type", [ - service.ListDatabasesRequest, + service.CreateDatabaseRequest, dict, ], ) -def test_list_databases_rest_call_success(request_type): +def test_create_database_rest_call_success(request_type): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2/clusters/sample3"} + request_init["database"] = { + "name": "name_value", + "charset": "charset_value", + "collation": "collation_value", + "character_type": "character_type_value", + "is_template": True, + "database_template": "database_template_value", + "is_template_database": 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 = service.CreateDatabaseRequest.meta.fields["database"] + + 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["database"].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["database"][field])): + del request_init["database"][field][i][subfield] + else: + del request_init["database"][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 = service.ListDatabasesResponse( - next_page_token="next_page_token_value", + return_value = resources.Database( + name="name_value", + charset="charset_value", + collation="collation_value", + character_type="character_type_value", + is_template=True, + database_template="database_template_value", + is_template_database=True, ) # Wrap the value into a proper Response obj @@ -30461,20 +31300,26 @@ def test_list_databases_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = service.ListDatabasesResponse.pb(return_value) + return_value = resources.Database.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_databases(request) + response = client.create_database(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDatabasesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, resources.Database) + assert response.name == "name_value" + assert response.charset == "charset_value" + assert response.collation == "collation_value" + assert response.character_type == "character_type_value" + assert response.is_template is True + assert response.database_template == "database_template_value" + assert response.is_template_database is True @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_databases_rest_interceptors(null_interceptor): +def test_create_database_rest_interceptors(null_interceptor): transport = transports.AlloyDBAdminRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -30488,16 +31333,16 @@ def test_list_databases_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.AlloyDBAdminRestInterceptor, "post_list_databases" + transports.AlloyDBAdminRestInterceptor, "post_create_database" ) as post, mock.patch.object( - transports.AlloyDBAdminRestInterceptor, "post_list_databases_with_metadata" + transports.AlloyDBAdminRestInterceptor, "post_create_database_with_metadata" ) as post_with_metadata, mock.patch.object( - transports.AlloyDBAdminRestInterceptor, "pre_list_databases" + transports.AlloyDBAdminRestInterceptor, "pre_create_database" ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = service.ListDatabasesRequest.pb(service.ListDatabasesRequest()) + pb_message = service.CreateDatabaseRequest.pb(service.CreateDatabaseRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -30508,21 +31353,19 @@ def test_list_databases_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 = service.ListDatabasesResponse.to_json( - service.ListDatabasesResponse() - ) + return_value = resources.Database.to_json(resources.Database()) req.return_value.content = return_value - request = service.ListDatabasesRequest() + request = service.CreateDatabaseRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = service.ListDatabasesResponse() - post_with_metadata.return_value = service.ListDatabasesResponse(), metadata + post.return_value = resources.Database() + post_with_metadata.return_value = resources.Database(), metadata - client.list_databases( + client.create_database( request, metadata=[ ("key", "val"), @@ -31666,6 +32509,26 @@ def test_list_databases_empty_call_rest(): 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_database_empty_call_rest(): + client = AlloyDBAdminClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_database), "__call__") as call: + client.create_database(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = service.CreateDatabaseRequest() + + assert args[0] == request_msg + + def test_alloy_db_admin_rest_lro_client(): client = AlloyDBAdminClient( credentials=ga_credentials.AnonymousCredentials(), @@ -31753,6 +32616,7 @@ def test_alloy_db_admin_base_transport(): "update_user", "delete_user", "list_databases", + "create_database", "get_location", "list_locations", "get_operation", @@ -32130,6 +32994,9 @@ def test_alloy_db_admin_client_transport_session_collision(transport_name): session1 = client1.transport.list_databases._session session2 = client2.transport.list_databases._session assert session1 != session2 + session1 = client1.transport.create_database._session + session2 = client2.transport.create_database._session + assert session1 != session2 def test_alloy_db_admin_grpc_transport_channel(): @@ -32367,12 +33234,41 @@ def test_parse_connection_info_path(): assert expected == actual -def test_crypto_key_version_path(): +def test_crypto_key_path(): project = "winkle" location = "nautilus" key_ring = "scallop" crypto_key = "abalone" - crypto_key_version = "squid" + expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + actual = AlloyDBAdminClient.crypto_key_path(project, location, key_ring, crypto_key) + assert expected == actual + + +def test_parse_crypto_key_path(): + expected = { + "project": "squid", + "location": "clam", + "key_ring": "whelk", + "crypto_key": "octopus", + } + path = AlloyDBAdminClient.crypto_key_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBAdminClient.parse_crypto_key_path(path) + assert expected == actual + + +def test_crypto_key_version_path(): + project = "oyster" + location = "nudibranch" + key_ring = "cuttlefish" + crypto_key = "mussel" + crypto_key_version = "winkle" expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format( project=project, location=location, @@ -32388,11 +33284,11 @@ def test_crypto_key_version_path(): def test_parse_crypto_key_version_path(): expected = { - "project": "clam", - "location": "whelk", - "key_ring": "octopus", - "crypto_key": "oyster", - "crypto_key_version": "nudibranch", + "project": "nautilus", + "location": "scallop", + "key_ring": "abalone", + "crypto_key": "squid", + "crypto_key_version": "clam", } path = AlloyDBAdminClient.crypto_key_version_path(**expected) @@ -32402,10 +33298,10 @@ def test_parse_crypto_key_version_path(): def test_database_path(): - project = "cuttlefish" - location = "mussel" - cluster = "winkle" - database = "nautilus" + project = "whelk" + location = "octopus" + cluster = "oyster" + database = "nudibranch" expected = "projects/{project}/locations/{location}/clusters/{cluster}/databases/{database}".format( project=project, location=location, @@ -32418,10 +33314,10 @@ def test_database_path(): def test_parse_database_path(): expected = { - "project": "scallop", - "location": "abalone", - "cluster": "squid", - "database": "clam", + "project": "cuttlefish", + "location": "mussel", + "cluster": "winkle", + "database": "nautilus", } path = AlloyDBAdminClient.database_path(**expected) @@ -32431,10 +33327,10 @@ def test_parse_database_path(): def test_instance_path(): - project = "whelk" - location = "octopus" - cluster = "oyster" - instance = "nudibranch" + project = "scallop" + location = "abalone" + cluster = "squid" + instance = "clam" expected = "projects/{project}/locations/{location}/clusters/{cluster}/instances/{instance}".format( project=project, location=location, @@ -32447,10 +33343,10 @@ def test_instance_path(): def test_parse_instance_path(): expected = { - "project": "cuttlefish", - "location": "mussel", - "cluster": "winkle", - "instance": "nautilus", + "project": "whelk", + "location": "octopus", + "cluster": "oyster", + "instance": "nudibranch", } path = AlloyDBAdminClient.instance_path(**expected) @@ -32460,8 +33356,8 @@ def test_parse_instance_path(): def test_network_path(): - project = "scallop" - network = "abalone" + project = "cuttlefish" + network = "mussel" expected = "projects/{project}/global/networks/{network}".format( project=project, network=network, @@ -32472,8 +33368,8 @@ def test_network_path(): def test_parse_network_path(): expected = { - "project": "squid", - "network": "clam", + "project": "winkle", + "network": "nautilus", } path = AlloyDBAdminClient.network_path(**expected) @@ -32482,10 +33378,38 @@ def test_parse_network_path(): assert expected == actual +def test_service_attachment_path(): + project = "scallop" + region = "abalone" + service_attachment = "squid" + expected = "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}".format( + project=project, + region=region, + service_attachment=service_attachment, + ) + actual = AlloyDBAdminClient.service_attachment_path( + project, region, service_attachment + ) + assert expected == actual + + +def test_parse_service_attachment_path(): + expected = { + "project": "clam", + "region": "whelk", + "service_attachment": "octopus", + } + path = AlloyDBAdminClient.service_attachment_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBAdminClient.parse_service_attachment_path(path) + assert expected == actual + + def test_supported_database_flag_path(): - project = "whelk" - location = "octopus" - flag = "oyster" + project = "oyster" + location = "nudibranch" + flag = "cuttlefish" expected = "projects/{project}/locations/{location}/flags/{flag}".format( project=project, location=location, @@ -32497,9 +33421,9 @@ def test_supported_database_flag_path(): def test_parse_supported_database_flag_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "flag": "mussel", + "project": "mussel", + "location": "winkle", + "flag": "nautilus", } path = AlloyDBAdminClient.supported_database_flag_path(**expected) @@ -32509,10 +33433,10 @@ def test_parse_supported_database_flag_path(): def test_user_path(): - project = "winkle" - location = "nautilus" - cluster = "scallop" - user = "abalone" + project = "scallop" + location = "abalone" + cluster = "squid" + user = "clam" expected = "projects/{project}/locations/{location}/clusters/{cluster}/users/{user}".format( project=project, location=location, @@ -32525,10 +33449,10 @@ def test_user_path(): def test_parse_user_path(): expected = { - "project": "squid", - "location": "clam", - "cluster": "whelk", - "user": "octopus", + "project": "whelk", + "location": "octopus", + "cluster": "oyster", + "user": "nudibranch", } path = AlloyDBAdminClient.user_path(**expected) @@ -32538,7 +33462,7 @@ def test_parse_user_path(): def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "cuttlefish" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -32548,7 +33472,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "mussel", } path = AlloyDBAdminClient.common_billing_account_path(**expected) @@ -32558,7 +33482,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "winkle" expected = "folders/{folder}".format( folder=folder, ) @@ -32568,7 +33492,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "nautilus", } path = AlloyDBAdminClient.common_folder_path(**expected) @@ -32578,7 +33502,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "scallop" expected = "organizations/{organization}".format( organization=organization, ) @@ -32588,7 +33512,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "abalone", } path = AlloyDBAdminClient.common_organization_path(**expected) @@ -32598,7 +33522,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "squid" expected = "projects/{project}".format( project=project, ) @@ -32608,7 +33532,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "clam", } path = AlloyDBAdminClient.common_project_path(**expected) @@ -32618,8 +33542,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "whelk" + location = "octopus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -32630,8 +33554,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "oyster", + "location": "nudibranch", } path = AlloyDBAdminClient.common_location_path(**expected) diff --git a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_dbcsql_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_dbcsql_admin.py index b8d51794444d..d659a36634c7 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_dbcsql_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_dbcsql_admin.py @@ -2956,12 +2956,43 @@ def test_parse_cluster_path(): assert expected == actual -def test_crypto_key_version_path(): +def test_crypto_key_path(): project = "squid" location = "clam" key_ring = "whelk" crypto_key = "octopus" - crypto_key_version = "oyster" + expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + actual = AlloyDBCSQLAdminClient.crypto_key_path( + project, location, key_ring, crypto_key + ) + assert expected == actual + + +def test_parse_crypto_key_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "key_ring": "cuttlefish", + "crypto_key": "mussel", + } + path = AlloyDBCSQLAdminClient.crypto_key_path(**expected) + + # Check that the path construction is reversible. + actual = AlloyDBCSQLAdminClient.parse_crypto_key_path(path) + assert expected == actual + + +def test_crypto_key_version_path(): + project = "winkle" + location = "nautilus" + key_ring = "scallop" + crypto_key = "abalone" + crypto_key_version = "squid" expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format( project=project, location=location, @@ -2977,11 +3008,11 @@ def test_crypto_key_version_path(): def test_parse_crypto_key_version_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "key_ring": "mussel", - "crypto_key": "winkle", - "crypto_key_version": "nautilus", + "project": "clam", + "location": "whelk", + "key_ring": "octopus", + "crypto_key": "oyster", + "crypto_key_version": "nudibranch", } path = AlloyDBCSQLAdminClient.crypto_key_version_path(**expected) @@ -2991,8 +3022,8 @@ def test_parse_crypto_key_version_path(): def test_network_path(): - project = "scallop" - network = "abalone" + project = "cuttlefish" + network = "mussel" expected = "projects/{project}/global/networks/{network}".format( project=project, network=network, @@ -3003,8 +3034,8 @@ def test_network_path(): def test_parse_network_path(): expected = { - "project": "squid", - "network": "clam", + "project": "winkle", + "network": "nautilus", } path = AlloyDBCSQLAdminClient.network_path(**expected) @@ -3014,7 +3045,7 @@ def test_parse_network_path(): def test_common_billing_account_path(): - billing_account = "whelk" + billing_account = "scallop" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3024,7 +3055,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "octopus", + "billing_account": "abalone", } path = AlloyDBCSQLAdminClient.common_billing_account_path(**expected) @@ -3034,7 +3065,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "oyster" + folder = "squid" expected = "folders/{folder}".format( folder=folder, ) @@ -3044,7 +3075,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nudibranch", + "folder": "clam", } path = AlloyDBCSQLAdminClient.common_folder_path(**expected) @@ -3054,7 +3085,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "cuttlefish" + organization = "whelk" expected = "organizations/{organization}".format( organization=organization, ) @@ -3064,7 +3095,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "mussel", + "organization": "octopus", } path = AlloyDBCSQLAdminClient.common_organization_path(**expected) @@ -3074,7 +3105,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "winkle" + project = "oyster" expected = "projects/{project}".format( project=project, ) @@ -3084,7 +3115,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nautilus", + "project": "nudibranch", } path = AlloyDBCSQLAdminClient.common_project_path(**expected) @@ -3094,8 +3125,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "scallop" - location = "abalone" + project = "cuttlefish" + location = "mussel" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -3106,8 +3137,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "squid", - "location": "clam", + "project": "winkle", + "location": "nautilus", } path = AlloyDBCSQLAdminClient.common_location_path(**expected) diff --git a/packages/google-cloud-apigee-connect/.OwlBot.yaml b/packages/google-cloud-apigee-connect/.OwlBot.yaml deleted file mode 100644 index 593c2abab000..000000000000 --- a/packages/google-cloud-apigee-connect/.OwlBot.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 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. - - -deep-remove-regex: - - /owl-bot-staging - -deep-copy-regex: - - source: /google/cloud/apigeeconnect/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-apigee-connect/$1 - -begin-after-commit-hash: 70f7f0525414fe4dfeb2fc2e81546b073f83a621 -api-name: google-cloud-apigee-connect diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect/gapic_version.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect/gapic_version.py index 20a9cd975b02..173714aec920 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect/gapic_version.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.12.2" # {x-release-please-version} diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/gapic_version.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/gapic_version.py index 20a9cd975b02..173714aec920 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/gapic_version.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.12.2" # {x-release-please-version} diff --git a/packages/google-cloud-apigee-connect/samples/generated_samples/snippet_metadata_google.cloud.apigeeconnect.v1.json b/packages/google-cloud-apigee-connect/samples/generated_samples/snippet_metadata_google.cloud.apigeeconnect.v1.json index ce1973950a71..219b369df5ef 100644 --- a/packages/google-cloud-apigee-connect/samples/generated_samples/snippet_metadata_google.cloud.apigeeconnect.v1.json +++ b/packages/google-cloud-apigee-connect/samples/generated_samples/snippet_metadata_google.cloud.apigeeconnect.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-apigee-connect", - "version": "0.1.0" + "version": "1.12.2" }, "snippets": [ { diff --git a/packages/google-cloud-apigee-registry/.OwlBot.yaml b/packages/google-cloud-apigee-registry/.OwlBot.yaml deleted file mode 100644 index 2ae415f5faba..000000000000 --- a/packages/google-cloud-apigee-registry/.OwlBot.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2022 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. - - -deep-remove-regex: - - /owl-bot-staging - -deep-copy-regex: - - source: /google/cloud/apigeeregistry/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-apigee-registry/$1 - -begin-after-commit-hash: 70f7f0525414fe4dfeb2fc2e81546b073f83a621 -api-name: google-cloud-apigee-registry diff --git a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry/gapic_version.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry/gapic_version.py index 20a9cd975b02..20709ed1a2ae 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry/gapic_version.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "0.6.18" # {x-release-please-version} diff --git a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/gapic_version.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/gapic_version.py index 20a9cd975b02..20709ed1a2ae 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/gapic_version.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "0.6.18" # {x-release-please-version} diff --git a/packages/google-cloud-apigee-registry/samples/generated_samples/snippet_metadata_google.cloud.apigeeregistry.v1.json b/packages/google-cloud-apigee-registry/samples/generated_samples/snippet_metadata_google.cloud.apigeeregistry.v1.json index b2c5df756020..4b594d3725d6 100644 --- a/packages/google-cloud-apigee-registry/samples/generated_samples/snippet_metadata_google.cloud.apigeeregistry.v1.json +++ b/packages/google-cloud-apigee-registry/samples/generated_samples/snippet_metadata_google.cloud.apigeeregistry.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-apigee-registry", - "version": "0.1.0" + "version": "0.6.18" }, "snippets": [ { diff --git a/packages/google-cloud-appengine-admin/.OwlBot.yaml b/packages/google-cloud-appengine-admin/.OwlBot.yaml deleted file mode 100644 index ab84013084b0..000000000000 --- a/packages/google-cloud-appengine-admin/.OwlBot.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2021 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. - - -deep-remove-regex: - - /owl-bot-staging - -deep-copy-regex: - - source: /google/appengine/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-appengine-admin/$1 - -begin-after-commit-hash: 5f1b96948e61e31e6bb4b586238ad79d6c24cdc3 - -api-name: google-cloud-appengine-admin diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin/gapic_version.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin/gapic_version.py index 20a9cd975b02..c36cb2cf2a03 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin/gapic_version.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.14.2" # {x-release-please-version} diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/gapic_version.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/gapic_version.py index 20a9cd975b02..c36cb2cf2a03 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/gapic_version.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.14.2" # {x-release-please-version} diff --git a/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_google.appengine.v1.json b/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_google.appengine.v1.json index a039900680d7..f1d77fd5fa44 100644 --- a/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_google.appengine.v1.json +++ b/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_google.appengine.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-appengine-admin", - "version": "0.1.0" + "version": "1.14.2" }, "snippets": [ { diff --git a/packages/google-cloud-appengine-logging/.OwlBot.yaml b/packages/google-cloud-appengine-logging/.OwlBot.yaml deleted file mode 100644 index 752abf96125b..000000000000 --- a/packages/google-cloud-appengine-logging/.OwlBot.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2021 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. - - -deep-remove-regex: - - /owl-bot-staging - -deep-copy-regex: - - source: /google/appengine/logging/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-appengine-logging/$1 - -begin-after-commit-hash: b06c9034cfcbce180ba732d03be6526e5c8ea1bc -api-name: google-cloud-appengine-logging diff --git a/packages/google-cloud-appengine-logging/google/cloud/appengine_logging/gapic_version.py b/packages/google-cloud-appengine-logging/google/cloud/appengine_logging/gapic_version.py index 20a9cd975b02..0276accd3d1a 100644 --- a/packages/google-cloud-appengine-logging/google/cloud/appengine_logging/gapic_version.py +++ b/packages/google-cloud-appengine-logging/google/cloud/appengine_logging/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.6.2" # {x-release-please-version} diff --git a/packages/google-cloud-appengine-logging/google/cloud/appengine_logging_v1/gapic_version.py b/packages/google-cloud-appengine-logging/google/cloud/appengine_logging_v1/gapic_version.py index 20a9cd975b02..0276accd3d1a 100644 --- a/packages/google-cloud-appengine-logging/google/cloud/appengine_logging_v1/gapic_version.py +++ b/packages/google-cloud-appengine-logging/google/cloud/appengine_logging_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.6.2" # {x-release-please-version} diff --git a/packages/google-cloud-apphub/.OwlBot.yaml b/packages/google-cloud-apphub/.OwlBot.yaml deleted file mode 100644 index a9e737010ee5..000000000000 --- a/packages/google-cloud-apphub/.OwlBot.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2022 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. - -deep-copy-regex: - - source: /google/cloud/apphub/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-apphub/$1 -api-name: google-cloud-apphub diff --git a/packages/google-cloud-apphub/google/cloud/apphub/gapic_version.py b/packages/google-cloud-apphub/google/cloud/apphub/gapic_version.py index 20a9cd975b02..e83d2be0b25c 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub/gapic_version.py +++ b/packages/google-cloud-apphub/google/cloud/apphub/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "0.1.10" # {x-release-please-version} diff --git a/packages/google-cloud-apphub/google/cloud/apphub_v1/gapic_version.py b/packages/google-cloud-apphub/google/cloud/apphub_v1/gapic_version.py index 20a9cd975b02..e83d2be0b25c 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub_v1/gapic_version.py +++ b/packages/google-cloud-apphub/google/cloud/apphub_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "0.1.10" # {x-release-please-version} diff --git a/packages/google-cloud-apphub/samples/generated_samples/snippet_metadata_google.cloud.apphub.v1.json b/packages/google-cloud-apphub/samples/generated_samples/snippet_metadata_google.cloud.apphub.v1.json index 161a57517820..bb1fd32d5ab8 100644 --- a/packages/google-cloud-apphub/samples/generated_samples/snippet_metadata_google.cloud.apphub.v1.json +++ b/packages/google-cloud-apphub/samples/generated_samples/snippet_metadata_google.cloud.apphub.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-apphub", - "version": "0.1.0" + "version": "0.1.10" }, "snippets": [ { diff --git a/packages/google-cloud-artifact-registry/.OwlBot.yaml b/packages/google-cloud-artifact-registry/.OwlBot.yaml deleted file mode 100644 index 0c6f93f327a7..000000000000 --- a/packages/google-cloud-artifact-registry/.OwlBot.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2021 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. - - -deep-remove-regex: - - /owl-bot-staging - -deep-copy-regex: - - source: /google/devtools/artifactregistry/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-artifact-registry/$1 - -begin-after-commit-hash: 40278112d2922ec917140dcb5cc6d5ef2923aeb2 - -api-name: google-cloud-artifact-registry diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py index 20a9cd975b02..1a363fe3aaab 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.16.1" # {x-release-please-version} diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py index 20a9cd975b02..1a363fe3aaab 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.16.1" # {x-release-please-version} diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py index 20a9cd975b02..1a363fe3aaab 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.16.1" # {x-release-please-version} diff --git a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json index 43448eb993ec..915ebd94898b 100644 --- a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json +++ b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-artifact-registry", - "version": "0.1.0" + "version": "1.16.1" }, "snippets": [ { diff --git a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json index 914e581f4fb1..bad567c0acc9 100644 --- a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json +++ b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-artifact-registry", - "version": "0.1.0" + "version": "1.16.1" }, "snippets": [ { diff --git a/packages/google-cloud-automl/.OwlBot.yaml b/packages/google-cloud-automl/.OwlBot.yaml deleted file mode 100644 index 6c761ae62450..000000000000 --- a/packages/google-cloud-automl/.OwlBot.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2021 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. - - -deep-remove-regex: - - /owl-bot-staging - -deep-copy-regex: - - source: /google/cloud/automl/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-automl/$1 - -begin-after-commit-hash: 6a5da3f1274b088752f074da5bc9e30bd1beb27e - -api-name: google-cloud-automl diff --git a/packages/google-cloud-automl/google/cloud/automl/gapic_version.py b/packages/google-cloud-automl/google/cloud/automl/gapic_version.py index 20a9cd975b02..b7e73ab9b22b 100644 --- a/packages/google-cloud-automl/google/cloud/automl/gapic_version.py +++ b/packages/google-cloud-automl/google/cloud/automl/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "2.16.4" # {x-release-please-version} diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/gapic_version.py b/packages/google-cloud-automl/google/cloud/automl_v1/gapic_version.py index 20a9cd975b02..b7e73ab9b22b 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/gapic_version.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "2.16.4" # {x-release-please-version} diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/gapic_version.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/gapic_version.py index 20a9cd975b02..b7e73ab9b22b 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/gapic_version.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "2.16.4" # {x-release-please-version} diff --git a/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1.json b/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1.json index 0d8816baffc0..8095973cacfd 100644 --- a/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1.json +++ b/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-automl", - "version": "0.1.0" + "version": "2.16.4" }, "snippets": [ { diff --git a/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1beta1.json b/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1beta1.json index 3957ec9b1b9f..2aaf1787da77 100644 --- a/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1beta1.json +++ b/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-automl", - "version": "0.1.0" + "version": "2.16.4" }, "snippets": [ { diff --git a/packages/google-cloud-backupdr/.OwlBot.yaml b/packages/google-cloud-backupdr/.OwlBot.yaml deleted file mode 100644 index d13e013b74de..000000000000 --- a/packages/google-cloud-backupdr/.OwlBot.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2022 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. - -deep-copy-regex: - - source: /google/cloud/backupdr/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-backupdr/$1 -api-name: google-cloud-backupdr diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr/gapic_version.py b/packages/google-cloud-backupdr/google/cloud/backupdr/gapic_version.py index 20a9cd975b02..6f945fba720d 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr/gapic_version.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "0.2.5" # {x-release-please-version} diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/gapic_version.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/gapic_version.py index 20a9cd975b02..6f945fba720d 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/gapic_version.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "0.2.5" # {x-release-please-version} diff --git a/packages/google-cloud-backupdr/samples/generated_samples/snippet_metadata_google.cloud.backupdr.v1.json b/packages/google-cloud-backupdr/samples/generated_samples/snippet_metadata_google.cloud.backupdr.v1.json index 681d1fa60eec..bd170d70d991 100644 --- a/packages/google-cloud-backupdr/samples/generated_samples/snippet_metadata_google.cloud.backupdr.v1.json +++ b/packages/google-cloud-backupdr/samples/generated_samples/snippet_metadata_google.cloud.backupdr.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-backupdr", - "version": "0.1.0" + "version": "0.2.5" }, "snippets": [ { diff --git a/packages/google-cloud-bare-metal-solution/.OwlBot.yaml b/packages/google-cloud-bare-metal-solution/.OwlBot.yaml deleted file mode 100644 index b2bd2f024d79..000000000000 --- a/packages/google-cloud-bare-metal-solution/.OwlBot.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2022 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. - - -deep-remove-regex: - - /owl-bot-staging - -deep-copy-regex: - - source: /google/cloud/baremetalsolution/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-bare-metal-solution/$1 - -begin-after-commit-hash: 70f7f0525414fe4dfeb2fc2e81546b073f83a621 -api-name: google-cloud-bare-metal-solution diff --git a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution/gapic_version.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution/gapic_version.py index 20a9cd975b02..34db2aac060b 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution/gapic_version.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.10.3" # {x-release-please-version} diff --git a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/gapic_version.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/gapic_version.py index 20a9cd975b02..34db2aac060b 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/gapic_version.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.0.0" # {x-release-please-version} +__version__ = "1.10.3" # {x-release-please-version} diff --git a/packages/google-cloud-bare-metal-solution/samples/generated_samples/snippet_metadata_google.cloud.baremetalsolution.v2.json b/packages/google-cloud-bare-metal-solution/samples/generated_samples/snippet_metadata_google.cloud.baremetalsolution.v2.json index 2e341fc16178..ce72289f1ae5 100644 --- a/packages/google-cloud-bare-metal-solution/samples/generated_samples/snippet_metadata_google.cloud.baremetalsolution.v2.json +++ b/packages/google-cloud-bare-metal-solution/samples/generated_samples/snippet_metadata_google.cloud.baremetalsolution.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bare-metal-solution", - "version": "0.1.0" + "version": "1.10.3" }, "snippets": [ { diff --git a/packages/google-cloud-batch/.OwlBot.yaml b/packages/google-cloud-batch/.OwlBot.yaml deleted file mode 100644 index 8c74680de2cd..000000000000 --- a/packages/google-cloud-batch/.OwlBot.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2022 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. - - -deep-remove-regex: - - /owl-bot-staging - -deep-copy-regex: - - source: /google/cloud/batch/(v.*)/.*-py - dest: /owl-bot-staging/google-cloud-batch/$1 - -begin-after-commit-hash: 70f7f0525414fe4dfeb2fc2e81546b073f83a621 -api-name: google-cloud-batch