From 60d0274b7533ea675a59e98a3c4f753a3c4ee0fe Mon Sep 17 00:00:00 2001 From: Cloud SDK Librarian Date: Wed, 4 Feb 2026 08:24:28 +0000 Subject: [PATCH] feat: generate libraries --- .librarian/state.yaml | 18 +- .../datamanager_v1/types/encryption_info.py | 10 +- .../google/apps/card_v1/types/card.py | 25 +- .../google/apps/chat/__init__.py | 4 + .../google/apps/chat_v1/__init__.py | 4 + .../google/apps/chat_v1/types/__init__.py | 4 + .../google/apps/chat_v1/types/message.py | 127 ++++ .../unit/gapic/chat_v1/test_chat_service.py | 34 +- .../google/cloud/backupdr/__init__.py | 6 + .../google/cloud/backupdr_v1/__init__.py | 6 + .../services/backup_dr/async_client.py | 3 + .../backupdr_v1/services/backup_dr/client.py | 23 + .../cloud/backupdr_v1/types/__init__.py | 6 + .../cloud/backupdr_v1/types/backupplan.py | 3 +- .../cloud/backupdr_v1/types/backupvault.py | 27 + .../backupdr_v1/types/backupvault_alloydb.py | 93 +++ .../unit/gapic/backupdr_v1/test_backup_dr.py | 152 +++-- .../cloud/geminidataanalytics/__init__.py | 4 + .../geminidataanalytics_v1alpha/__init__.py | 4 + .../types/__init__.py | 4 + .../types/data_chat_service.py | 129 +++- .../geminidataanalytics_v1beta/__init__.py | 4 + .../types/__init__.py | 4 + .../types/data_chat_service.py | 129 +++- .../async_client.py | 8 +- .../quota_adjuster_settings_manager/client.py | 8 +- .../transports/grpc.py | 8 +- .../transports/grpc_asyncio.py | 8 +- .../types/quota_adjuster_settings.py | 12 +- .../google/cloud/vectorsearch/__init__.py | 6 + .../cloud/vectorsearch_v1beta/__init__.py | 6 + .../vectorsearch_v1beta/gapic_metadata.json | 15 + .../data_object_service/async_client.py | 3 +- .../services/data_object_service/client.py | 3 +- .../data_object_service/transports/base.py | 54 ++ .../transports/grpc_asyncio.py | 54 ++ .../vector_search_service/async_client.py | 136 +++- .../services/vector_search_service/client.py | 134 +++- .../vector_search_service/transports/base.py | 68 ++ .../vector_search_service/transports/grpc.py | 29 + .../transports/grpc_asyncio.py | 89 +++ .../vector_search_service/transports/rest.py | 226 ++++++- .../transports/rest_base.py | 57 ++ .../vectorsearch_v1beta/types/__init__.py | 6 + .../vectorsearch_v1beta/types/data_object.py | 4 +- .../types/data_object_search_service.py | 29 +- .../types/data_object_service.py | 7 +- .../types/embedding_config.py | 2 +- .../types/vectorsearch_service.py | 138 ++++- ...data_google.cloud.vectorsearch.v1beta.json | 153 +++++ ...earch_service_export_data_objects_async.py | 62 ++ ...search_service_export_data_objects_sync.py | 62 ++ .../test_vector_search_service.py | 586 ++++++++++++++++++ 53 files changed, 2647 insertions(+), 149 deletions(-) create mode 100644 packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupvault_alloydb.py create mode 100644 packages/google-cloud-vectorsearch/samples/generated_samples/vectorsearch_v1beta_generated_vector_search_service_export_data_objects_async.py create mode 100644 packages/google-cloud-vectorsearch/samples/generated_samples/vectorsearch_v1beta_generated_vector_search_service_export_data_objects_sync.py diff --git a/.librarian/state.yaml b/.librarian/state.yaml index 47eb3dfdc58f..2a58f7d69873 100644 --- a/.librarian/state.yaml +++ b/.librarian/state.yaml @@ -16,7 +16,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-ads-datamanager version: 0.3.0 - last_generated_commit: 87e3579c041a50f985f8de71e9494c8fc85d520b + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/ads/datamanager/v1 service_config: datamanager_v1.yaml @@ -98,7 +98,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-card version: 0.4.0 - last_generated_commit: 3322511885371d2b2253f209ccc3aa60d4100cfd + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/apps/card/v1 service_config: "" @@ -113,7 +113,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-apps-chat version: 0.5.0 - last_generated_commit: 9a477cd3c26a704130e2a2fb44a40281d9312e4c + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/chat/v1 service_config: chat_v1.yaml @@ -491,7 +491,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-backupdr version: 0.7.0 - last_generated_commit: 94aa4f5ae672addf00e7970ecc47699e34989e90 + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/cloud/backupdr/v1 service_config: backupdr_v1.yaml @@ -1590,7 +1590,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-geminidataanalytics version: 0.9.0 - last_generated_commit: 94aa4f5ae672addf00e7970ecc47699e34989e90 + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/cloud/geminidataanalytics/v1beta service_config: geminidataanalytics_v1beta.yaml @@ -2224,7 +2224,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-os-config version: 1.23.0 - last_generated_commit: 3322511885371d2b2253f209ccc3aa60d4100cfd + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/cloud/osconfig/v1alpha service_config: osconfig_v1alpha.yaml @@ -2387,7 +2387,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-quotas version: 0.4.0 - last_generated_commit: cfe62b3c5ceb9f81879c61480f26707980534462 + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/api/cloudquotas/v1 service_config: cloudquotas_v1.yaml @@ -2973,7 +2973,7 @@ libraries: tag_format: '{id}-v{version}' - id: google-cloud-vectorsearch version: 0.3.0 - last_generated_commit: ded7ed1e4cce7c165c56a417572cebea9bc1d82c + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/cloud/vectorsearch/v1beta service_config: vectorsearch_v1beta.yaml @@ -3598,7 +3598,7 @@ libraries: tag_format: '{id}-v{version}' - id: googleapis-common-protos version: 1.72.0 - last_generated_commit: cfe62b3c5ceb9f81879c61480f26707980534462 + last_generated_commit: 7a5706618f42f482acf583febcc7b977b66c25b2 apis: - path: google/api service_config: serviceconfig.yaml diff --git a/packages/google-ads-datamanager/google/ads/datamanager_v1/types/encryption_info.py b/packages/google-ads-datamanager/google/ads/datamanager_v1/types/encryption_info.py index 33512f38ea1d..425789f9f955 100644 --- a/packages/google-ads-datamanager/google/ads/datamanager_v1/types/encryption_info.py +++ b/packages/google-ads-datamanager/google/ads/datamanager_v1/types/encryption_info.py @@ -82,7 +82,9 @@ class GcpWrappedKeyInfo(proto.Message): Service resource ID `__. Should be in the format of - "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{key}". + ``projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{key}`` + or + ``gcp-kms://projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{key}`` encrypted_dek (str): Required. The base64 encoded encrypted data encryption key. @@ -129,11 +131,13 @@ class AwsWrappedKeyInfo(proto.Message): role_arn (str): Required. The Amazon Resource Name of the IAM Role to assume for KMS decryption access. Should be in the format of - "arn:{partition}:iam::{account_id}:role/{role_name}". + ``arn:{partition}:iam::{account_id}:role/{role_name}`` kek_uri (str): Required. The URI of the AWS KMS key used to decrypt the DEK. Should be in the format of - "arn:{partition}:kms:{region}:{account_id}:key/{key_id}". + ``arn:{partition}:kms:{region}:{account_id}:key/{key_id}`` + or + ``aws-kms://arn:{partition}:kms:{region}:{account_id}:key/{key_id}`` encrypted_dek (str): Required. The base64 encoded encrypted data encryption key. diff --git a/packages/google-apps-card/google/apps/card_v1/types/card.py b/packages/google-apps-card/google/apps/card_v1/types/card.py index 359b564f39e5..32fd96323ca7 100644 --- a/packages/google-apps-card/google/apps/card_v1/types/card.py +++ b/packages/google-apps-card/google/apps/card_v1/types/card.py @@ -1811,8 +1811,29 @@ class SelectionType(proto.Enum): A set of switches. Users can turn on one or more switches. DROPDOWN (3): - A dropdown menu. Users can select one item - from the menu. + A dropdown menu. Users can select one item from the menu. + + For Google Chat apps, you can populate items using a dynamic + data source and autosuggest items as users type in the menu. + For example, users can start typing the name of a Google + Chat space and the widget autosuggests the space. To + dynamically populate items for a dropdown menu, use one of + the following types of data sources: + + - Google Workspace data: Items are populated using data from + Google Workspace, such as Google Workspace users or Google + Chat spaces. + - External data: Items are populated from an external data + source outside of Google Workspace. + + For examples of how to implement dropdown menus for Chat + apps, see `Add a dropdown + menu `__ + and `Dynamically populate drop-down + menus `__. + + `Google Workspace add-ons and Chat + apps `__: MULTI_SELECT (4): A menu with a text box. Users can type and select one or more items. For Google Workspace add-ons, you must populate diff --git a/packages/google-apps-chat/google/apps/chat/__init__.py b/packages/google-apps-chat/google/apps/chat/__init__.py index 0a5ddc0db23d..453874ad0db6 100644 --- a/packages/google-apps-chat/google/apps/chat/__init__.py +++ b/packages/google-apps-chat/google/apps/chat/__init__.py @@ -86,11 +86,13 @@ DeleteMessageRequest, Dialog, DialogAction, + ForwardedMetadata, GetMessageRequest, ListMessagesRequest, ListMessagesResponse, Message, QuotedMessageMetadata, + QuotedMessageSnapshot, Thread, UpdateMessageRequest, ) @@ -206,11 +208,13 @@ "DeleteMessageRequest", "Dialog", "DialogAction", + "ForwardedMetadata", "GetMessageRequest", "ListMessagesRequest", "ListMessagesResponse", "Message", "QuotedMessageMetadata", + "QuotedMessageSnapshot", "Thread", "UpdateMessageRequest", "CreateCustomEmojiRequest", diff --git a/packages/google-apps-chat/google/apps/chat_v1/__init__.py b/packages/google-apps-chat/google/apps/chat_v1/__init__.py index db2d4e18cb0c..ad1247a6c575 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/__init__.py +++ b/packages/google-apps-chat/google/apps/chat_v1/__init__.py @@ -93,11 +93,13 @@ DeleteMessageRequest, Dialog, DialogAction, + ForwardedMetadata, GetMessageRequest, ListMessagesRequest, ListMessagesResponse, Message, QuotedMessageMetadata, + QuotedMessageSnapshot, Thread, UpdateMessageRequest, ) @@ -283,6 +285,7 @@ def _get_version(dependency_name): "Emoji", "EmojiReactionSummary", "FindDirectMessageRequest", + "ForwardedMetadata", "GetAttachmentRequest", "GetCustomEmojiRequest", "GetMembershipRequest", @@ -323,6 +326,7 @@ def _get_version(dependency_name): "MessageDeletedEventData", "MessageUpdatedEventData", "QuotedMessageMetadata", + "QuotedMessageSnapshot", "Reaction", "ReactionBatchCreatedEventData", "ReactionBatchDeletedEventData", diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/__init__.py b/packages/google-apps-chat/google/apps/chat_v1/types/__init__.py index 68048bc1193c..c9aa601a9f07 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/__init__.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/__init__.py @@ -77,11 +77,13 @@ DeleteMessageRequest, Dialog, DialogAction, + ForwardedMetadata, GetMessageRequest, ListMessagesRequest, ListMessagesResponse, Message, QuotedMessageMetadata, + QuotedMessageSnapshot, Thread, UpdateMessageRequest, ) @@ -192,11 +194,13 @@ "DeleteMessageRequest", "Dialog", "DialogAction", + "ForwardedMetadata", "GetMessageRequest", "ListMessagesRequest", "ListMessagesResponse", "Message", "QuotedMessageMetadata", + "QuotedMessageSnapshot", "Thread", "UpdateMessageRequest", "CreateCustomEmojiRequest", diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/message.py b/packages/google-apps-chat/google/apps/chat_v1/types/message.py index 5ef8ae03f642..c1e0933affa4 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/message.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/message.py @@ -39,6 +39,8 @@ "Message", "AttachedGif", "QuotedMessageMetadata", + "QuotedMessageSnapshot", + "ForwardedMetadata", "Thread", "ActionResponse", "AccessoryWidget", @@ -434,8 +436,39 @@ class QuotedMessageMetadata(proto.Message): If ``last_update_time`` doesn't match the latest version of the quoted message, the request fails. + quote_type (google.apps.chat_v1.types.QuotedMessageMetadata.QuoteType): + Optional. Specifies the quote type. If not + set, defaults to REPLY in the message read/write + path for backward compatibility. + quoted_message_snapshot (google.apps.chat_v1.types.QuotedMessageSnapshot): + Output only. A snapshot of the quoted + message's content. + forwarded_metadata (google.apps.chat_v1.types.ForwardedMetadata): + Output only. Metadata about the source space + of the quoted message. Populated only for + FORWARD quote type. """ + class QuoteType(proto.Enum): + r"""The quote type of the quoted message. + + Values: + QUOTE_TYPE_UNSPECIFIED (0): + Reserved. This value is unused. + REPLY (1): + If quote_type is ``REPLY``, you can do the following: + + - If you're replying in a thread, you can quote another + message in that thread. + + - If you're creating a root message, you can quote another + root message in that space. + + You can't quote a message reply from a different thread. + """ + QUOTE_TYPE_UNSPECIFIED = 0 + REPLY = 1 + name: str = proto.Field( proto.STRING, number=1, @@ -445,6 +478,100 @@ class QuotedMessageMetadata(proto.Message): number=2, message=timestamp_pb2.Timestamp, ) + quote_type: QuoteType = proto.Field( + proto.ENUM, + number=4, + enum=QuoteType, + ) + quoted_message_snapshot: "QuotedMessageSnapshot" = proto.Field( + proto.MESSAGE, + number=5, + message="QuotedMessageSnapshot", + ) + forwarded_metadata: "ForwardedMetadata" = proto.Field( + proto.MESSAGE, + number=6, + message="ForwardedMetadata", + ) + + +class QuotedMessageSnapshot(proto.Message): + r"""Provides a snapshot of the content of the quoted message at + the time of quoting or forwarding + + Attributes: + sender (str): + Output only. The quoted message's author + name. Populated for both REPLY & FORWARD quote + types. + text (str): + Output only. Snapshot of the quoted message's + text content. + formatted_text (str): + Output only. Contains the quoted message ``text`` with + markups added to support rich formatting like + hyperlinks,custom emojis, markup, etc. Populated only for + FORWARD quote type. + annotations (MutableSequence[google.apps.chat_v1.types.Annotation]): + Output only. Annotations parsed from the text + body of the quoted message. Populated only for + FORWARD quote type. + attachments (MutableSequence[google.apps.chat_v1.types.Attachment]): + Output only. Attachments that were part of + the quoted message. These are copies of the + quoted message's attachment metadata. Populated + only for FORWARD quote type. + """ + + sender: str = proto.Field( + proto.STRING, + number=1, + ) + text: str = proto.Field( + proto.STRING, + number=2, + ) + formatted_text: str = proto.Field( + proto.STRING, + number=3, + ) + annotations: MutableSequence[annotation.Annotation] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=annotation.Annotation, + ) + attachments: MutableSequence[gc_attachment.Attachment] = proto.RepeatedField( + proto.MESSAGE, + number=5, + message=gc_attachment.Attachment, + ) + + +class ForwardedMetadata(proto.Message): + r"""Metadata about the source space from which a message was + forwarded. + + Attributes: + space (str): + Output only. The resource name of the source + space. Format: spaces/{space} + space_display_name (str): + Output only. The display name of the source space or DM at + the time of forwarding. For ``SPACE``, this is the space + name. For ``DIRECT_MESSAGE``, this is the other + participant's name (e.g., "User A"). For ``GROUP_CHAT``, + this is a generated name based on members' first names, + limited to 5 including the creator (e.g., "User A, User B"). + """ + + space: str = proto.Field( + proto.STRING, + number=1, + ) + space_display_name: str = proto.Field( + proto.STRING, + number=2, + ) class Thread(proto.Message): diff --git a/packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py b/packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py index a0f77452c3ba..21a01ffc5264 100644 --- a/packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py +++ b/packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py @@ -22581,7 +22581,22 @@ def test_create_message_rest_call_success(request_type): ], "private_message_viewer": {}, "deletion_metadata": {"deletion_type": 1}, - "quoted_message_metadata": {"name": "name_value", "last_update_time": {}}, + "quoted_message_metadata": { + "name": "name_value", + "last_update_time": {}, + "quote_type": 1, + "quoted_message_snapshot": { + "sender": "sender_value", + "text": "text_value", + "formatted_text": "formatted_text_value", + "annotations": {}, + "attachments": {}, + }, + "forwarded_metadata": { + "space": "space_value", + "space_display_name": "space_display_name_value", + }, + }, "attached_gifs": [{"uri": "uri_value"}], "accessory_widgets": [{"button_list": {}}], } @@ -23769,7 +23784,22 @@ def test_update_message_rest_call_success(request_type): ], "private_message_viewer": {}, "deletion_metadata": {"deletion_type": 1}, - "quoted_message_metadata": {"name": "name_value", "last_update_time": {}}, + "quoted_message_metadata": { + "name": "name_value", + "last_update_time": {}, + "quote_type": 1, + "quoted_message_snapshot": { + "sender": "sender_value", + "text": "text_value", + "formatted_text": "formatted_text_value", + "annotations": {}, + "attachments": {}, + }, + "forwarded_metadata": { + "space": "space_value", + "space_display_name": "space_display_name_value", + }, + }, "attached_gifs": [{"uri": "uri_value"}], "accessory_widgets": [{"button_list": {}}], } diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr/__init__.py b/packages/google-cloud-backupdr/google/cloud/backupdr/__init__.py index 76975c5b1a26..b4dc8540fa9f 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr/__init__.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr/__init__.py @@ -111,6 +111,10 @@ UpdateBackupVaultRequest, UpdateDataSourceRequest, ) +from google.cloud.backupdr_v1.types.backupvault_alloydb import ( + AlloyDbClusterBackupProperties, + AlloyDBClusterDataSourceProperties, +) from google.cloud.backupdr_v1.types.backupvault_ba import ( BackupApplianceBackupProperties, ) @@ -258,6 +262,8 @@ "BackupConfigState", "BackupVaultView", "BackupView", + "AlloyDbClusterBackupProperties", + "AlloyDBClusterDataSourceProperties", "BackupApplianceBackupProperties", "CloudSqlInstanceBackupPlanAssociationProperties", "CloudSqlInstanceBackupProperties", diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/__init__.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/__init__.py index a2752e102651..a1cf60fcc390 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/__init__.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/__init__.py @@ -118,6 +118,10 @@ UpdateBackupVaultRequest, UpdateDataSourceRequest, ) +from .types.backupvault_alloydb import ( + AlloyDbClusterBackupProperties, + AlloyDBClusterDataSourceProperties, +) from .types.backupvault_ba import BackupApplianceBackupProperties from .types.backupvault_cloudsql import ( CloudSqlInstanceBackupPlanAssociationProperties, @@ -283,6 +287,8 @@ def _get_version(dependency_name): "AdvancedMachineFeatures", "AliasIpRange", "AllocationAffinity", + "AlloyDBClusterDataSourceProperties", + "AlloyDbClusterBackupProperties", "AttachedDisk", "Backup", "BackupApplianceBackupConfig", diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/async_client.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/async_client.py index e2d5c90b56e6..95ea347ae4be 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/async_client.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/async_client.py @@ -62,6 +62,7 @@ backupplan, backupplanassociation, backupvault, + backupvault_alloydb, backupvault_ba, backupvault_cloudsql, backupvault_disk, @@ -111,6 +112,8 @@ class BackupDRAsyncClient: ) backup_vault_path = staticmethod(BackupDRClient.backup_vault_path) parse_backup_vault_path = staticmethod(BackupDRClient.parse_backup_vault_path) + cluster_path = staticmethod(BackupDRClient.cluster_path) + parse_cluster_path = staticmethod(BackupDRClient.parse_cluster_path) crypto_key_path = staticmethod(BackupDRClient.crypto_key_path) parse_crypto_key_path = staticmethod(BackupDRClient.parse_crypto_key_path) crypto_key_version_path = staticmethod(BackupDRClient.crypto_key_version_path) diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/client.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/client.py index bd7ff4798831..16bea5c7f1f2 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/client.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/client.py @@ -79,6 +79,7 @@ backupplan, backupplanassociation, backupvault, + backupvault_alloydb, backupvault_ba, backupvault_cloudsql, backupvault_disk, @@ -364,6 +365,28 @@ def parse_backup_vault_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def cluster_path( + project: str, + location: str, + cluster: str, + ) -> str: + """Returns a fully-qualified cluster string.""" + return "projects/{project}/locations/{location}/clusters/{cluster}".format( + project=project, + location=location, + cluster=cluster, + ) + + @staticmethod + def parse_cluster_path(path: str) -> Dict[str, str]: + """Parses a cluster path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/clusters/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def crypto_key_path( project: str, diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/__init__.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/__init__.py index 93036c68775b..3fc2a7f4b72c 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/__init__.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/__init__.py @@ -98,6 +98,10 @@ UpdateBackupVaultRequest, UpdateDataSourceRequest, ) +from .backupvault_alloydb import ( + AlloyDbClusterBackupProperties, + AlloyDBClusterDataSourceProperties, +) from .backupvault_ba import BackupApplianceBackupProperties from .backupvault_cloudsql import ( CloudSqlInstanceBackupPlanAssociationProperties, @@ -239,6 +243,8 @@ "BackupConfigState", "BackupVaultView", "BackupView", + "AlloyDbClusterBackupProperties", + "AlloyDBClusterDataSourceProperties", "BackupApplianceBackupProperties", "CloudSqlInstanceBackupPlanAssociationProperties", "CloudSqlInstanceBackupProperties", diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupplan.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupplan.py index eab394c22b70..7bfc17220f6b 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupplan.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupplan.py @@ -102,7 +102,8 @@ class BackupPlan(proto.Message): for taking backups. Specify the email address of the Backup Vault Service Account. log_retention_days (int): - Optional. Applicable only for CloudSQL resource_type. + Optional. Applicable only for CloudSQL and AlloyDB + resource_type. Configures how long logs will be stored. It is defined in “days”. This value should be greater than or equal to diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupvault.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupvault.py index 6159e75a7647..5708f7f22120 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupvault.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupvault.py @@ -24,6 +24,7 @@ import proto # type: ignore from google.cloud.backupdr_v1.types import ( + backupvault_alloydb, backupvault_ba, backupvault_cloudsql, backupvault_disk, @@ -822,6 +823,13 @@ class DataSourceGcpResource(proto.Message): subset of Cloud SQL Instance properties that are useful at the Datasource level. + This field is a member of `oneof`_ ``gcp_resource_properties``. + alloy_db_cluster_datasource_properties (google.cloud.backupdr_v1.types.AlloyDBClusterDataSourceProperties): + Output only. + AlloyDBClusterDataSourceProperties has a subset + of AlloyDB cluster properties that are useful at + the Datasource level. + This field is a member of `oneof`_ ``gcp_resource_properties``. disk_datasource_properties (google.cloud.backupdr_v1.types.DiskDataSourceProperties): DiskDataSourceProperties has a subset of Disk @@ -855,6 +863,12 @@ class DataSourceGcpResource(proto.Message): oneof="gcp_resource_properties", message=backupvault_cloudsql.CloudSqlInstanceDataSourceProperties, ) + alloy_db_cluster_datasource_properties: backupvault_alloydb.AlloyDBClusterDataSourceProperties = proto.Field( + proto.MESSAGE, + number=6, + oneof="gcp_resource_properties", + message=backupvault_alloydb.AlloyDBClusterDataSourceProperties, + ) disk_datasource_properties: backupvault_disk.DiskDataSourceProperties = proto.Field( proto.MESSAGE, number=7, @@ -1137,6 +1151,11 @@ class Backup(proto.Message): Output only. Backup Appliance specific backup properties. + This field is a member of `oneof`_ ``backup_properties``. + alloy_db_backup_properties (google.cloud.backupdr_v1.types.AlloyDbClusterBackupProperties): + Output only. AlloyDB specific backup + properties. + This field is a member of `oneof`_ ``backup_properties``. disk_backup_properties (google.cloud.backupdr_v1.types.DiskBackupProperties): Output only. Disk specific backup properties. @@ -1351,6 +1370,14 @@ class GCPBackupPlanInfo(proto.Message): oneof="backup_properties", message=backupvault_ba.BackupApplianceBackupProperties, ) + alloy_db_backup_properties: backupvault_alloydb.AlloyDbClusterBackupProperties = ( + proto.Field( + proto.MESSAGE, + number=27, + oneof="backup_properties", + message=backupvault_alloydb.AlloyDbClusterBackupProperties, + ) + ) disk_backup_properties: backupvault_disk.DiskBackupProperties = proto.Field( proto.MESSAGE, number=28, diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupvault_alloydb.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupvault_alloydb.py new file mode 100644 index 000000000000..04bf8884a921 --- /dev/null +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/types/backupvault_alloydb.py @@ -0,0 +1,93 @@ +# -*- 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. +# +from __future__ import annotations + +from typing import MutableMapping, MutableSequence + +import proto # type: ignore + +__protobuf__ = proto.module( + package="google.cloud.backupdr.v1", + manifest={ + "AlloyDBClusterDataSourceProperties", + "AlloyDbClusterBackupProperties", + }, +) + + +class AlloyDBClusterDataSourceProperties(proto.Message): + r"""AlloyDBClusterDataSourceProperties represents the properties + of a AlloyDB cluster resource that are stored in the DataSource. + . + + Attributes: + name (str): + Output only. Name of the AlloyDB cluster + backed up by the datasource. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class AlloyDbClusterBackupProperties(proto.Message): + r"""AlloyDbClusterBackupProperties represents AlloyDB cluster + backup properties. + . + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + description (str): + An optional text description for the backup. + + This field is a member of `oneof`_ ``_description``. + stored_bytes (int): + Output only. Storage usage of this particular + backup + chain_id (str): + Output only. The chain id of this backup. + Backups belonging to the same chain are sharing + the same chain id. This property is calculated + and maintained by BackupDR. + database_version (str): + Output only. The PostgreSQL major version of + the AlloyDB cluster when the backup was taken. + """ + + description: str = proto.Field( + proto.STRING, + number=1, + optional=True, + ) + stored_bytes: int = proto.Field( + proto.INT64, + number=2, + ) + chain_id: str = proto.Field( + proto.STRING, + number=3, + ) + database_version: str = proto.Field( + proto.STRING, + number=4, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-backupdr/tests/unit/gapic/backupdr_v1/test_backup_dr.py b/packages/google-cloud-backupdr/tests/unit/gapic/backupdr_v1/test_backup_dr.py index 2050cabaac87..b7ab6993a2b2 100644 --- a/packages/google-cloud-backupdr/tests/unit/gapic/backupdr_v1/test_backup_dr.py +++ b/packages/google-cloud-backupdr/tests/unit/gapic/backupdr_v1/test_backup_dr.py @@ -86,6 +86,7 @@ backupplan, backupplanassociation, backupvault, + backupvault_alloydb, backupvault_ba, backupvault_cloudsql, backupvault_disk, @@ -28984,6 +28985,7 @@ def test_update_data_source_rest_call_success(request_type): "instance_create_time": {}, "instance_tier": "instance_tier_value", }, + "alloy_db_cluster_datasource_properties": {"name": "name_value"}, "disk_datasource_properties": { "name": "name_value", "description": "description_value", @@ -29749,6 +29751,12 @@ def test_update_backup_rest_call_success(request_type): "recovery_range_start_time": {}, "recovery_range_end_time": {}, }, + "alloy_db_backup_properties": { + "description": "description_value", + "stored_bytes": 1303, + "chain_id": "chain_id_value", + "database_version": "database_version_value", + }, "disk_backup_properties": { "description": "description_value", "licenses": ["licenses_value1", "licenses_value2"], @@ -35128,11 +35136,37 @@ def test_parse_backup_vault_path(): assert expected == actual -def test_crypto_key_path(): +def test_cluster_path(): project = "squid" location = "clam" - ring = "whelk" - key = "octopus" + cluster = "whelk" + expected = "projects/{project}/locations/{location}/clusters/{cluster}".format( + project=project, + location=location, + cluster=cluster, + ) + actual = BackupDRClient.cluster_path(project, location, cluster) + assert expected == actual + + +def test_parse_cluster_path(): + expected = { + "project": "octopus", + "location": "oyster", + "cluster": "nudibranch", + } + path = BackupDRClient.cluster_path(**expected) + + # Check that the path construction is reversible. + actual = BackupDRClient.parse_cluster_path(path) + assert expected == actual + + +def test_crypto_key_path(): + project = "cuttlefish" + location = "mussel" + ring = "winkle" + key = "nautilus" expected = "projects/{project}/locations/{location}/keyRings/{ring}/cryptoKeys/{key}".format( project=project, location=location, @@ -35145,10 +35179,10 @@ def test_crypto_key_path(): def test_parse_crypto_key_path(): expected = { - "project": "oyster", - "location": "nudibranch", - "ring": "cuttlefish", - "key": "mussel", + "project": "scallop", + "location": "abalone", + "ring": "squid", + "key": "clam", } path = BackupDRClient.crypto_key_path(**expected) @@ -35158,11 +35192,11 @@ def test_parse_crypto_key_path(): def test_crypto_key_version_path(): - project = "winkle" - location = "nautilus" - key_ring = "scallop" - crypto_key = "abalone" - crypto_key_version = "squid" + project = "whelk" + location = "octopus" + key_ring = "oyster" + crypto_key = "nudibranch" + crypto_key_version = "cuttlefish" expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format( project=project, location=location, @@ -35178,11 +35212,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": "mussel", + "location": "winkle", + "key_ring": "nautilus", + "crypto_key": "scallop", + "crypto_key_version": "abalone", } path = BackupDRClient.crypto_key_version_path(**expected) @@ -35192,10 +35226,10 @@ def test_parse_crypto_key_version_path(): def test_data_source_path(): - project = "cuttlefish" - location = "mussel" - backupvault = "winkle" - datasource = "nautilus" + project = "squid" + location = "clam" + backupvault = "whelk" + datasource = "octopus" expected = "projects/{project}/locations/{location}/backupVaults/{backupvault}/dataSources/{datasource}".format( project=project, location=location, @@ -35208,10 +35242,10 @@ def test_data_source_path(): def test_parse_data_source_path(): expected = { - "project": "scallop", - "location": "abalone", - "backupvault": "squid", - "datasource": "clam", + "project": "oyster", + "location": "nudibranch", + "backupvault": "cuttlefish", + "datasource": "mussel", } path = BackupDRClient.data_source_path(**expected) @@ -35221,9 +35255,9 @@ def test_parse_data_source_path(): def test_data_source_reference_path(): - project = "whelk" - location = "octopus" - data_source_reference = "oyster" + project = "winkle" + location = "nautilus" + data_source_reference = "scallop" expected = "projects/{project}/locations/{location}/dataSourceReferences/{data_source_reference}".format( project=project, location=location, @@ -35237,9 +35271,9 @@ def test_data_source_reference_path(): def test_parse_data_source_reference_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "data_source_reference": "mussel", + "project": "abalone", + "location": "squid", + "data_source_reference": "clam", } path = BackupDRClient.data_source_reference_path(**expected) @@ -35249,8 +35283,8 @@ def test_parse_data_source_reference_path(): def test_instance_path(): - project = "winkle" - instance = "nautilus" + project = "whelk" + instance = "octopus" expected = "projects/{project}/instances/{instance}".format( project=project, instance=instance, @@ -35261,8 +35295,8 @@ def test_instance_path(): def test_parse_instance_path(): expected = { - "project": "scallop", - "instance": "abalone", + "project": "oyster", + "instance": "nudibranch", } path = BackupDRClient.instance_path(**expected) @@ -35272,9 +35306,9 @@ def test_parse_instance_path(): def test_management_server_path(): - project = "squid" - location = "clam" - managementserver = "whelk" + project = "cuttlefish" + location = "mussel" + managementserver = "winkle" expected = "projects/{project}/locations/{location}/managementServers/{managementserver}".format( project=project, location=location, @@ -35286,9 +35320,9 @@ def test_management_server_path(): def test_parse_management_server_path(): expected = { - "project": "octopus", - "location": "oyster", - "managementserver": "nudibranch", + "project": "nautilus", + "location": "scallop", + "managementserver": "abalone", } path = BackupDRClient.management_server_path(**expected) @@ -35298,9 +35332,9 @@ def test_parse_management_server_path(): def test_storage_pool_path(): - project = "cuttlefish" - zone = "mussel" - storage_pool = "winkle" + project = "squid" + zone = "clam" + storage_pool = "whelk" expected = "projects/{project}/zones/{zone}/storagePools/{storage_pool}".format( project=project, zone=zone, @@ -35312,9 +35346,9 @@ def test_storage_pool_path(): def test_parse_storage_pool_path(): expected = { - "project": "nautilus", - "zone": "scallop", - "storage_pool": "abalone", + "project": "octopus", + "zone": "oyster", + "storage_pool": "nudibranch", } path = BackupDRClient.storage_pool_path(**expected) @@ -35324,7 +35358,7 @@ def test_parse_storage_pool_path(): def test_common_billing_account_path(): - billing_account = "squid" + billing_account = "cuttlefish" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -35334,7 +35368,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "clam", + "billing_account": "mussel", } path = BackupDRClient.common_billing_account_path(**expected) @@ -35344,7 +35378,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "whelk" + folder = "winkle" expected = "folders/{folder}".format( folder=folder, ) @@ -35354,7 +35388,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "octopus", + "folder": "nautilus", } path = BackupDRClient.common_folder_path(**expected) @@ -35364,7 +35398,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "oyster" + organization = "scallop" expected = "organizations/{organization}".format( organization=organization, ) @@ -35374,7 +35408,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nudibranch", + "organization": "abalone", } path = BackupDRClient.common_organization_path(**expected) @@ -35384,7 +35418,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "cuttlefish" + project = "squid" expected = "projects/{project}".format( project=project, ) @@ -35394,7 +35428,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "mussel", + "project": "clam", } path = BackupDRClient.common_project_path(**expected) @@ -35404,8 +35438,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "winkle" - location = "nautilus" + project = "whelk" + location = "octopus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -35416,8 +35450,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "scallop", - "location": "abalone", + "project": "oyster", + "location": "nudibranch", } path = BackupDRClient.common_location_path(**expected) diff --git a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics/__init__.py b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics/__init__.py index 952feba5a892..c3192fa6d1b5 100644 --- a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics/__init__.py +++ b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics/__init__.py @@ -81,6 +81,8 @@ ChartQuery, ChartResult, ChatRequest, + ClarificationMessage, + ClarificationQuestion, ClientManagedResourceContext, ConversationReference, DataAgentContext, @@ -170,6 +172,8 @@ "ChartQuery", "ChartResult", "ChatRequest", + "ClarificationMessage", + "ClarificationQuestion", "ClientManagedResourceContext", "ConversationReference", "DataAgentContext", diff --git a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/__init__.py b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/__init__.py index 130f9fe047be..18b37c784013 100644 --- a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/__init__.py +++ b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/__init__.py @@ -80,6 +80,8 @@ ChartQuery, ChartResult, ChatRequest, + ClarificationMessage, + ClarificationQuestion, ClientManagedResourceContext, ConversationReference, DataAgentContext, @@ -239,6 +241,8 @@ def _get_version(dependency_name): "ChartQuery", "ChartResult", "ChatRequest", + "ClarificationMessage", + "ClarificationQuestion", "ClientManagedResourceContext", "CloudSqlDatabaseReference", "CloudSqlReference", diff --git a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/types/__init__.py b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/types/__init__.py index 1c0709d8d30f..6ded4613aa6c 100644 --- a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/types/__init__.py +++ b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/types/__init__.py @@ -57,6 +57,8 @@ ChartQuery, ChartResult, ChatRequest, + ClarificationMessage, + ClarificationQuestion, ClientManagedResourceContext, ConversationReference, DataAgentContext, @@ -142,6 +144,8 @@ "ChartQuery", "ChartResult", "ChatRequest", + "ClarificationMessage", + "ClarificationQuestion", "ClientManagedResourceContext", "ConversationReference", "DataAgentContext", diff --git a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/types/data_chat_service.py b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/types/data_chat_service.py index 82345e5e2b60..ac3d4471c652 100644 --- a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/types/data_chat_service.py +++ b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1alpha/types/data_chat_service.py @@ -60,6 +60,8 @@ "ChartQuery", "ChartResult", "ErrorMessage", + "ClarificationQuestion", + "ClarificationMessage", "ExampleQueries", "Blob", }, @@ -723,6 +725,11 @@ class SystemMessage(proto.Message): Optional. A message containing example queries. + This field is a member of `oneof`_ ``kind``. + clarification (google.cloud.geminidataanalytics_v1alpha.types.ClarificationMessage): + Optional. A message containing clarification + questions. + This field is a member of `oneof`_ ``kind``. group_id (int): Identifies the group that the event belongs @@ -775,6 +782,12 @@ class SystemMessage(proto.Message): oneof="kind", message="ExampleQueries", ) + clarification: "ClarificationMessage" = proto.Field( + proto.MESSAGE, + number=14, + oneof="kind", + message="ClarificationMessage", + ) group_id: int = proto.Field( proto.INT32, number=12, @@ -790,6 +803,9 @@ class TextMessage(proto.Message): Optional. The parts of the message. text_type (google.cloud.geminidataanalytics_v1alpha.types.TextMessage.TextType): Optional. The type of the text message. + thought_signature (bytes): + Optional. An opaque signature for a thought + so it can be reused in subsequent requests. """ class TextType(proto.Enum): @@ -802,8 +818,7 @@ class TextType(proto.Enum): The text is a final response to the user question. THOUGHT (2): - The text is a thinking plan generated by the - thinking tool. + The text is a thought from the model. PROGRESS (3): The text is an informational message about the agent's progress, such as a tool being invoked. This is distinct @@ -825,6 +840,10 @@ class TextType(proto.Enum): number=2, enum=TextType, ) + thought_signature: bytes = proto.Field( + proto.BYTES, + number=3, + ) class SchemaMessage(proto.Message): @@ -1027,6 +1046,15 @@ class DataResult(proto.Message): is a struct that matches the schema. Simple values are represented as strings, while nested structures are represented as lists or structs. + formatted_data (MutableSequence[google.protobuf.struct_pb2.Struct]): + Optional. Formatted representation of the data, when + applicable. Each row is a struct that directly corresponds + to the row at the same index within the ``data`` field. Its + values are string representations of the original data, + formatted according to data source specifications (e.g., + "$1,234.56" for currency). Columns without formatting will + default to their raw value representation. If no columns + have formatting rules, this field will be empty. """ name: str = proto.Field( @@ -1043,6 +1071,11 @@ class DataResult(proto.Message): number=2, message=struct_pb2.Struct, ) + formatted_data: MutableSequence[struct_pb2.Struct] = proto.RepeatedField( + proto.MESSAGE, + number=6, + message=struct_pb2.Struct, + ) class BigQueryJob(proto.Message): @@ -1373,6 +1406,98 @@ class ErrorMessage(proto.Message): ) +class ClarificationQuestion(proto.Message): + r"""Represents a single question to the user to help clarify + their query. + + Attributes: + question (str): + Required. The natural language question to + ask the user. + selection_mode (google.cloud.geminidataanalytics_v1alpha.types.ClarificationQuestion.SelectionMode): + Required. The selection mode for this + question. + options (MutableSequence[str]): + Required. A list of distinct options for the + user to choose from. The number of options is + limited to a maximum of 5. + clarification_question_type (google.cloud.geminidataanalytics_v1alpha.types.ClarificationQuestion.ClarificationQuestionType): + Optional. The type of clarification question. + """ + + class SelectionMode(proto.Enum): + r"""The selection mode for the clarification question. + + Values: + SELECTION_MODE_UNSPECIFIED (0): + Unspecified selection mode. + SINGLE_SELECT (1): + The user can select only one option. + MULTI_SELECT (2): + The user can select multiple options. + """ + SELECTION_MODE_UNSPECIFIED = 0 + SINGLE_SELECT = 1 + MULTI_SELECT = 2 + + class ClarificationQuestionType(proto.Enum): + r"""The type of clarification question. + This enum may be extended with new values in the future. + + Values: + CLARIFICATION_QUESTION_TYPE_UNSPECIFIED (0): + Unspecified clarification question type. + FILTER_VALUES (1): + The clarification question is for filter + values. + FIELDS (2): + The clarification question is for data + fields. This is a generic term encompassing SQL + columns, Looker fields (dimensions/measures), or + nested data structure properties. + """ + CLARIFICATION_QUESTION_TYPE_UNSPECIFIED = 0 + FILTER_VALUES = 1 + FIELDS = 2 + + question: str = proto.Field( + proto.STRING, + number=1, + ) + selection_mode: SelectionMode = proto.Field( + proto.ENUM, + number=2, + enum=SelectionMode, + ) + options: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + clarification_question_type: ClarificationQuestionType = proto.Field( + proto.ENUM, + number=4, + enum=ClarificationQuestionType, + ) + + +class ClarificationMessage(proto.Message): + r"""A message of questions to help clarify the user's query. This + is returned when the system cannot confidently answer the user's + question. + + Attributes: + questions (MutableSequence[google.cloud.geminidataanalytics_v1alpha.types.ClarificationQuestion]): + Required. A batch of clarification questions + to ask the user. + """ + + questions: MutableSequence["ClarificationQuestion"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="ClarificationQuestion", + ) + + class ExampleQueries(proto.Message): r"""A message containing derived and authored example queries. diff --git a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/__init__.py b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/__init__.py index 2b84fb18ed3f..edf8de0c452d 100644 --- a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/__init__.py +++ b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/__init__.py @@ -80,6 +80,8 @@ ChartQuery, ChartResult, ChatRequest, + ClarificationMessage, + ClarificationQuestion, ClientManagedResourceContext, ConversationReference, DataAgentContext, @@ -239,6 +241,8 @@ def _get_version(dependency_name): "ChartQuery", "ChartResult", "ChatRequest", + "ClarificationMessage", + "ClarificationQuestion", "ClientManagedResourceContext", "CloudSqlDatabaseReference", "CloudSqlReference", diff --git a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/types/__init__.py b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/types/__init__.py index 1c0709d8d30f..6ded4613aa6c 100644 --- a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/types/__init__.py +++ b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/types/__init__.py @@ -57,6 +57,8 @@ ChartQuery, ChartResult, ChatRequest, + ClarificationMessage, + ClarificationQuestion, ClientManagedResourceContext, ConversationReference, DataAgentContext, @@ -142,6 +144,8 @@ "ChartQuery", "ChartResult", "ChatRequest", + "ClarificationMessage", + "ClarificationQuestion", "ClientManagedResourceContext", "ConversationReference", "DataAgentContext", diff --git a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/types/data_chat_service.py b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/types/data_chat_service.py index b11efaddbde7..bec4f17bd947 100644 --- a/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/types/data_chat_service.py +++ b/packages/google-cloud-geminidataanalytics/google/cloud/geminidataanalytics_v1beta/types/data_chat_service.py @@ -58,6 +58,8 @@ "ChartQuery", "ChartResult", "ErrorMessage", + "ClarificationQuestion", + "ClarificationMessage", "ExampleQueries", "Blob", }, @@ -721,6 +723,11 @@ class SystemMessage(proto.Message): Optional. A message containing example queries. + This field is a member of `oneof`_ ``kind``. + clarification (google.cloud.geminidataanalytics_v1beta.types.ClarificationMessage): + Optional. A message containing clarification + questions. + This field is a member of `oneof`_ ``kind``. group_id (int): Identifies the group that the event belongs @@ -773,6 +780,12 @@ class SystemMessage(proto.Message): oneof="kind", message="ExampleQueries", ) + clarification: "ClarificationMessage" = proto.Field( + proto.MESSAGE, + number=14, + oneof="kind", + message="ClarificationMessage", + ) group_id: int = proto.Field( proto.INT32, number=12, @@ -788,6 +801,9 @@ class TextMessage(proto.Message): Optional. The parts of the message. text_type (google.cloud.geminidataanalytics_v1beta.types.TextMessage.TextType): Optional. The type of the text message. + thought_signature (bytes): + Optional. An opaque signature for a thought + so it can be reused in subsequent requests. """ class TextType(proto.Enum): @@ -800,8 +816,7 @@ class TextType(proto.Enum): The text is a final response to the user question. THOUGHT (2): - The text is a thinking plan generated by the - thinking tool. + The text is a thought from the model. PROGRESS (3): The text is an informational message about the agent's progress, such as a tool being invoked. This is distinct @@ -823,6 +838,10 @@ class TextType(proto.Enum): number=2, enum=TextType, ) + thought_signature: bytes = proto.Field( + proto.BYTES, + number=3, + ) class SchemaMessage(proto.Message): @@ -1025,6 +1044,15 @@ class DataResult(proto.Message): is a struct that matches the schema. Simple values are represented as strings, while nested structures are represented as lists or structs. + formatted_data (MutableSequence[google.protobuf.struct_pb2.Struct]): + Optional. Formatted representation of the data, when + applicable. Each row is a struct that directly corresponds + to the row at the same index within the ``data`` field. Its + values are string representations of the original data, + formatted according to data source specifications (e.g., + "$1,234.56" for currency). Columns without formatting will + default to their raw value representation. If no columns + have formatting rules, this field will be empty. """ name: str = proto.Field( @@ -1041,6 +1069,11 @@ class DataResult(proto.Message): number=2, message=struct_pb2.Struct, ) + formatted_data: MutableSequence[struct_pb2.Struct] = proto.RepeatedField( + proto.MESSAGE, + number=6, + message=struct_pb2.Struct, + ) class BigQueryJob(proto.Message): @@ -1371,6 +1404,98 @@ class ErrorMessage(proto.Message): ) +class ClarificationQuestion(proto.Message): + r"""Represents a single question to the user to help clarify + their query. + + Attributes: + question (str): + Required. The natural language question to + ask the user. + selection_mode (google.cloud.geminidataanalytics_v1beta.types.ClarificationQuestion.SelectionMode): + Required. The selection mode for this + question. + options (MutableSequence[str]): + Required. A list of distinct options for the + user to choose from. The number of options is + limited to a maximum of 5. + clarification_question_type (google.cloud.geminidataanalytics_v1beta.types.ClarificationQuestion.ClarificationQuestionType): + Optional. The type of clarification question. + """ + + class SelectionMode(proto.Enum): + r"""The selection mode for the clarification question. + + Values: + SELECTION_MODE_UNSPECIFIED (0): + Unspecified selection mode. + SINGLE_SELECT (1): + The user can select only one option. + MULTI_SELECT (2): + The user can select multiple options. + """ + SELECTION_MODE_UNSPECIFIED = 0 + SINGLE_SELECT = 1 + MULTI_SELECT = 2 + + class ClarificationQuestionType(proto.Enum): + r"""The type of clarification question. + This enum may be extended with new values in the future. + + Values: + CLARIFICATION_QUESTION_TYPE_UNSPECIFIED (0): + Unspecified clarification question type. + FILTER_VALUES (1): + The clarification question is for filter + values. + FIELDS (2): + The clarification question is for data + fields. This is a generic term encompassing SQL + columns, Looker fields (dimensions/measures), or + nested data structure properties. + """ + CLARIFICATION_QUESTION_TYPE_UNSPECIFIED = 0 + FILTER_VALUES = 1 + FIELDS = 2 + + question: str = proto.Field( + proto.STRING, + number=1, + ) + selection_mode: SelectionMode = proto.Field( + proto.ENUM, + number=2, + enum=SelectionMode, + ) + options: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + clarification_question_type: ClarificationQuestionType = proto.Field( + proto.ENUM, + number=4, + enum=ClarificationQuestionType, + ) + + +class ClarificationMessage(proto.Message): + r"""A message of questions to help clarify the user's query. This + is returned when the system cannot confidently answer the user's + question. + + Attributes: + questions (MutableSequence[google.cloud.geminidataanalytics_v1beta.types.ClarificationQuestion]): + Required. A batch of clarification questions + to ask the user. + """ + + questions: MutableSequence["ClarificationQuestion"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="ClarificationQuestion", + ) + + class ExampleQueries(proto.Message): r"""A message containing derived and authored example queries. diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/async_client.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/async_client.py index b50baee214cc..fea5abe7448f 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/async_client.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/async_client.py @@ -328,8 +328,8 @@ async def update_quota_adjuster_settings( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_quota_adjuster_settings.QuotaAdjusterSettings: - r"""RPC Method for updating QuotaAdjusterSettings based - on the request + r"""Updates the QuotaAdjusterSettings for the specified + resource. .. code-block:: python @@ -462,8 +462,8 @@ async def get_quota_adjuster_settings( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> quota_adjuster_settings.QuotaAdjusterSettings: - r"""RPC Method for getting QuotaAdjusterSettings based on - the request + r"""Gets the QuotaAdjusterSettings for the specified + resource. .. code-block:: python diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/client.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/client.py index 85f752f02cca..9ef8f0649b1e 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/client.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/client.py @@ -772,8 +772,8 @@ def update_quota_adjuster_settings( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_quota_adjuster_settings.QuotaAdjusterSettings: - r"""RPC Method for updating QuotaAdjusterSettings based - on the request + r"""Updates the QuotaAdjusterSettings for the specified + resource. .. code-block:: python @@ -905,8 +905,8 @@ def get_quota_adjuster_settings( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> quota_adjuster_settings.QuotaAdjusterSettings: - r"""RPC Method for getting QuotaAdjusterSettings based on - the request + r"""Gets the QuotaAdjusterSettings for the specified + resource. .. code-block:: python diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/transports/grpc.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/transports/grpc.py index 155c184c602b..46180e8aa6f5 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/transports/grpc.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/transports/grpc.py @@ -338,8 +338,8 @@ def update_quota_adjuster_settings( ]: r"""Return a callable for the update quota adjuster settings method over gRPC. - RPC Method for updating QuotaAdjusterSettings based - on the request + Updates the QuotaAdjusterSettings for the specified + resource. Returns: Callable[[~.UpdateQuotaAdjusterSettingsRequest], @@ -370,8 +370,8 @@ def get_quota_adjuster_settings( ]: r"""Return a callable for the get quota adjuster settings method over gRPC. - RPC Method for getting QuotaAdjusterSettings based on - the request + Gets the QuotaAdjusterSettings for the specified + resource. Returns: Callable[[~.GetQuotaAdjusterSettingsRequest], diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/transports/grpc_asyncio.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/transports/grpc_asyncio.py index b9e8226b70a7..18f3000c191f 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/transports/grpc_asyncio.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/services/quota_adjuster_settings_manager/transports/grpc_asyncio.py @@ -348,8 +348,8 @@ def update_quota_adjuster_settings( ]: r"""Return a callable for the update quota adjuster settings method over gRPC. - RPC Method for updating QuotaAdjusterSettings based - on the request + Updates the QuotaAdjusterSettings for the specified + resource. Returns: Callable[[~.UpdateQuotaAdjusterSettingsRequest], @@ -380,8 +380,8 @@ def get_quota_adjuster_settings( ]: r"""Return a callable for the get quota adjuster settings method over gRPC. - RPC Method for getting QuotaAdjusterSettings based on - the request + Gets the QuotaAdjusterSettings for the specified + resource. Returns: Callable[[~.GetQuotaAdjusterSettingsRequest], diff --git a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/types/quota_adjuster_settings.py b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/types/quota_adjuster_settings.py index 92c1caf5c718..611916d81db7 100644 --- a/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/types/quota_adjuster_settings.py +++ b/packages/google-cloud-quotas/google/cloud/cloudquotas_v1beta/types/quota_adjuster_settings.py @@ -86,10 +86,14 @@ class QuotaAdjusterSettings(proto.Message): Attributes: name (str): - Identifier. Name of the config would be of the format: - projects/PROJECT_NUMBER/locations/global/quotaAdjusterSettings - folders/FOLDER_NUMBER/locations/global/quotaAdjusterSettings - organizations/ORGANIZATION_NUMBER/locations/global/quotaAdjusterSettings + Identifier. Name of the configuration, in the formats below: + + - For a project: + projects/PROJECT_NUMBER/locations/global/quotaAdjusterSettings + - For a folder: + folders/FOLDER_NUMBER/locations/global/quotaAdjusterSettings + - For an organization: + organizations/ORGANIZATION_NUMBER/locations/global/quotaAdjusterSettings enablement (google.cloud.cloudquotas_v1beta.types.QuotaAdjusterSettings.Enablement): Optional. The configured value of the enablement at the given resource. diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch/__init__.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch/__init__.py index 5d0788d4ab80..0ee4c1084075 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch/__init__.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch/__init__.py @@ -87,6 +87,9 @@ DeleteCollectionRequest, DeleteIndexRequest, DenseVectorField, + ExportDataObjectsMetadata, + ExportDataObjectsRequest, + ExportDataObjectsResponse, GetCollectionRequest, GetIndexRequest, ImportDataObjectsMetadata, @@ -152,6 +155,9 @@ "DeleteCollectionRequest", "DeleteIndexRequest", "DenseVectorField", + "ExportDataObjectsMetadata", + "ExportDataObjectsRequest", + "ExportDataObjectsResponse", "GetCollectionRequest", "GetIndexRequest", "ImportDataObjectsMetadata", diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/__init__.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/__init__.py index b5c9decf8884..95e9751d7331 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/__init__.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/__init__.py @@ -83,6 +83,9 @@ DeleteCollectionRequest, DeleteIndexRequest, DenseVectorField, + ExportDataObjectsMetadata, + ExportDataObjectsRequest, + ExportDataObjectsResponse, GetCollectionRequest, GetIndexRequest, ImportDataObjectsMetadata, @@ -221,6 +224,9 @@ def _get_version(dependency_name): "DenseVectorField", "DistanceMetric", "EmbeddingTaskType", + "ExportDataObjectsMetadata", + "ExportDataObjectsRequest", + "ExportDataObjectsResponse", "GetCollectionRequest", "GetDataObjectRequest", "GetIndexRequest", diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/gapic_metadata.json b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/gapic_metadata.json index b4b02acf8649..2b6221837e22 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/gapic_metadata.json +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/gapic_metadata.json @@ -233,6 +233,11 @@ "delete_index" ] }, + "ExportDataObjects": { + "methods": [ + "export_data_objects" + ] + }, "GetCollection": { "methods": [ "get_collection" @@ -288,6 +293,11 @@ "delete_index" ] }, + "ExportDataObjects": { + "methods": [ + "export_data_objects" + ] + }, "GetCollection": { "methods": [ "get_collection" @@ -343,6 +353,11 @@ "delete_index" ] }, + "ExportDataObjects": { + "methods": [ + "export_data_objects" + ] + }, "GetCollection": { "methods": [ "get_collection" diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/async_client.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/async_client.py index 97b1c7a6eb27..7688ce9a2db6 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/async_client.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/async_client.py @@ -363,7 +363,8 @@ async def sample_create_data_object(): should not be set. data_object_id (:class:`str`): Required. The id of the dataObject to create. The id - must be 1-63 characters long, and comply with RFC1035. + must be 1-63 characters long, and comply with + `RFC1035 `__. Specifically, it must be 1-63 characters long and match the regular expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/client.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/client.py index 408d9ffa2cce..87915c12fa12 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/client.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/client.py @@ -827,7 +827,8 @@ def sample_create_data_object(): should not be set. data_object_id (str): Required. The id of the dataObject to create. The id - must be 1-63 characters long, and comply with RFC1035. + must be 1-63 characters long, and comply with + `RFC1035 `__. Specifically, it must be 1-63 characters long and match the regular expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/transports/base.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/transports/base.py index b4742d4fa18e..d609622e6780 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/transports/base.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/transports/base.py @@ -143,11 +143,29 @@ def _prep_wrapped_messages(self, client_info): self._wrapped_methods = { self.create_data_object: gapic_v1.method.wrap_method( self.create_data_object, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.batch_create_data_objects: gapic_v1.method.wrap_method( self.batch_create_data_objects, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=300.0, + ), default_timeout=300.0, client_info=client_info, ), @@ -167,21 +185,57 @@ def _prep_wrapped_messages(self, client_info): ), self.update_data_object: gapic_v1.method.wrap_method( self.update_data_object, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.batch_update_data_objects: gapic_v1.method.wrap_method( self.batch_update_data_objects, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.delete_data_object: gapic_v1.method.wrap_method( self.delete_data_object, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.batch_delete_data_objects: gapic_v1.method.wrap_method( self.batch_delete_data_objects, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/transports/grpc_asyncio.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/transports/grpc_asyncio.py index 3f2f76dc41dd..9916531b24c9 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/data_object_service/transports/grpc_asyncio.py @@ -539,11 +539,29 @@ def _prep_wrapped_messages(self, client_info): self._wrapped_methods = { self.create_data_object: self._wrap_method( self.create_data_object, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.batch_create_data_objects: self._wrap_method( self.batch_create_data_objects, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=300.0, + ), default_timeout=300.0, client_info=client_info, ), @@ -563,21 +581,57 @@ def _prep_wrapped_messages(self, client_info): ), self.update_data_object: self._wrap_method( self.update_data_object, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.batch_update_data_objects: self._wrap_method( self.batch_update_data_objects, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.delete_data_object: self._wrap_method( self.delete_data_object, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.batch_delete_data_objects: self._wrap_method( self.batch_delete_data_objects, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/async_client.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/async_client.py index eefc812139f9..59725ad774d7 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/async_client.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/async_client.py @@ -608,7 +608,8 @@ async def sample_create_collection(): should not be set. collection_id (:class:`str`): Required. ID of the Collection to create. The id must be - 1-63 characters long, and comply with RFC1035. + 1-63 characters long, and comply with + `RFC1035 `__. Specifically, it must be 1-63 characters long and match the regular expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. @@ -758,10 +759,11 @@ async def sample_update_collection(): ``description``, ``labels``, ``data_schema``, ``vector_schema``. For ``data_schema`` and ``vector_schema``, fields can only be added, not - modified or deleted. Partial updates for ``data_schema`` - and ``vector_schema`` are also supported by using - sub-field paths in ``update_mask``, e.g. - ``data_schema.properties.foo`` or + deleted, but ``vertex_embedding_config`` in + ``vector_schema`` can be added or removed. Partial + updates for ``data_schema`` and ``vector_schema`` are + also supported by using sub-field paths in + ``update_mask``, e.g. ``data_schema.properties.foo`` or ``vector_schema.my_vector_field``. If ``*`` is provided in the update_mask, full @@ -1278,9 +1280,11 @@ async def sample_create_index(): should not be set. index_id (:class:`str`): Required. ID of the Index to create. The id must be 1-63 - characters long, and comply with RFC1035. Specifically, - it must be 1-63 characters long and match the regular - expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. + characters long, and comply with + `RFC1035 `__. + Specifically, it must be 1-63 characters long and match + the regular expression + ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. This corresponds to the ``index_id`` field on the ``request`` instance; if ``request`` is provided, this @@ -1547,7 +1551,7 @@ async def sample_import_data_objects(): Args: request (Optional[Union[google.cloud.vectorsearch_v1beta.types.ImportDataObjectsRequest, dict]]): The request object. Request message for - [DataObjectService.ImportDataObjects][]. + [VectorSearchService.ImportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ImportDataObjects]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1560,9 +1564,8 @@ async def sample_import_data_objects(): google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. - The result type for the operation will be - :class:`google.cloud.vectorsearch_v1beta.types.ImportDataObjectsResponse` - Response for [DataObjectService.ImportDataObjects][]. + The result type for the operation will be :class:`google.cloud.vectorsearch_v1beta.types.ImportDataObjectsResponse` Response for + [VectorSearchService.ImportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ImportDataObjects]. """ # Create or coerce a protobuf request object. @@ -1605,6 +1608,115 @@ async def sample_import_data_objects(): # Done; return the response. return response + async def export_data_objects( + self, + request: Optional[ + Union[vectorsearch_service.ExportDataObjectsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Initiates a Long-Running Operation to export + DataObjects from a Collection. + + .. 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 vectorsearch_v1beta + + async def sample_export_data_objects(): + # Create a client + client = vectorsearch_v1beta.VectorSearchServiceAsyncClient() + + # Initialize request argument(s) + gcs_destination = vectorsearch_v1beta.GcsExportDestination() + gcs_destination.export_uri = "export_uri_value" + gcs_destination.format_ = "JSON" + + request = vectorsearch_v1beta.ExportDataObjectsRequest( + gcs_destination=gcs_destination, + name="name_value", + ) + + # Make the request + operation = client.export_data_objects(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.vectorsearch_v1beta.types.ExportDataObjectsRequest, dict]]): + The request object. Request message for + [VectorSearchService.ExportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ExportDataObjects]. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.vectorsearch_v1beta.types.ExportDataObjectsResponse` + Response for the ExportDataObjects LRO. + + """ + # Create or coerce a protobuf request object. + # - 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, vectorsearch_service.ExportDataObjectsRequest): + request = vectorsearch_service.ExportDataObjectsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.export_data_objects + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + vectorsearch_service.ExportDataObjectsResponse, + metadata_type=vectorsearch_service.ExportDataObjectsMetadata, + ) + + # Done; return the response. + return response + async def list_operations( self, request: Optional[operations_pb2.ListOperationsRequest] = None, diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/client.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/client.py index 7b1a22f3f04e..fe09a0910f63 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/client.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/client.py @@ -1066,7 +1066,8 @@ def sample_create_collection(): should not be set. collection_id (str): Required. ID of the Collection to create. The id must be - 1-63 characters long, and comply with RFC1035. + 1-63 characters long, and comply with + `RFC1035 `__. Specifically, it must be 1-63 characters long and match the regular expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. @@ -1213,10 +1214,11 @@ def sample_update_collection(): ``description``, ``labels``, ``data_schema``, ``vector_schema``. For ``data_schema`` and ``vector_schema``, fields can only be added, not - modified or deleted. Partial updates for ``data_schema`` - and ``vector_schema`` are also supported by using - sub-field paths in ``update_mask``, e.g. - ``data_schema.properties.foo`` or + deleted, but ``vertex_embedding_config`` in + ``vector_schema`` can be added or removed. Partial + updates for ``data_schema`` and ``vector_schema`` are + also supported by using sub-field paths in + ``update_mask``, e.g. ``data_schema.properties.foo`` or ``vector_schema.my_vector_field``. If ``*`` is provided in the update_mask, full @@ -1721,9 +1723,11 @@ def sample_create_index(): should not be set. index_id (str): Required. ID of the Index to create. The id must be 1-63 - characters long, and comply with RFC1035. Specifically, - it must be 1-63 characters long and match the regular - expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. + characters long, and comply with + `RFC1035 `__. + Specifically, it must be 1-63 characters long and match + the regular expression + ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. This corresponds to the ``index_id`` field on the ``request`` instance; if ``request`` is provided, this @@ -1984,7 +1988,7 @@ def sample_import_data_objects(): Args: request (Union[google.cloud.vectorsearch_v1beta.types.ImportDataObjectsRequest, dict]): The request object. Request message for - [DataObjectService.ImportDataObjects][]. + [VectorSearchService.ImportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ImportDataObjects]. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1997,9 +2001,8 @@ def sample_import_data_objects(): google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be - :class:`google.cloud.vectorsearch_v1beta.types.ImportDataObjectsResponse` - Response for [DataObjectService.ImportDataObjects][]. + The result type for the operation will be :class:`google.cloud.vectorsearch_v1beta.types.ImportDataObjectsResponse` Response for + [VectorSearchService.ImportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ImportDataObjects]. """ # Create or coerce a protobuf request object. @@ -2040,6 +2043,113 @@ def sample_import_data_objects(): # Done; return the response. return response + def export_data_objects( + self, + request: Optional[ + Union[vectorsearch_service.ExportDataObjectsRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Initiates a Long-Running Operation to export + DataObjects from a Collection. + + .. 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 vectorsearch_v1beta + + def sample_export_data_objects(): + # Create a client + client = vectorsearch_v1beta.VectorSearchServiceClient() + + # Initialize request argument(s) + gcs_destination = vectorsearch_v1beta.GcsExportDestination() + gcs_destination.export_uri = "export_uri_value" + gcs_destination.format_ = "JSON" + + request = vectorsearch_v1beta.ExportDataObjectsRequest( + gcs_destination=gcs_destination, + name="name_value", + ) + + # Make the request + operation = client.export_data_objects(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.vectorsearch_v1beta.types.ExportDataObjectsRequest, dict]): + The request object. Request message for + [VectorSearchService.ExportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ExportDataObjects]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.vectorsearch_v1beta.types.ExportDataObjectsResponse` + Response for the ExportDataObjects LRO. + + """ + # Create or coerce a protobuf request object. + # - 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, vectorsearch_service.ExportDataObjectsRequest): + request = vectorsearch_service.ExportDataObjectsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.export_data_objects] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + vectorsearch_service.ExportDataObjectsResponse, + metadata_type=vectorsearch_service.ExportDataObjectsMetadata, + ) + + # Done; return the response. + return response + def __enter__(self) -> "VectorSearchServiceClient": return self diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/base.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/base.py index c9f25835d17f..bf1ed7c82aba 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/base.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/base.py @@ -168,16 +168,43 @@ def _prep_wrapped_messages(self, client_info): ), self.create_collection: gapic_v1.method.wrap_method( self.create_collection, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.update_collection: gapic_v1.method.wrap_method( self.update_collection, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.delete_collection: gapic_v1.method.wrap_method( self.delete_collection, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), @@ -211,19 +238,51 @@ def _prep_wrapped_messages(self, client_info): ), self.create_index: gapic_v1.method.wrap_method( self.create_index, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.delete_index: gapic_v1.method.wrap_method( self.delete_index, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.import_data_objects: gapic_v1.method.wrap_method( self.import_data_objects, + default_retry=retries.Retry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), + self.export_data_objects: gapic_v1.method.wrap_method( + self.export_data_objects, + default_timeout=None, + client_info=client_info, + ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, @@ -368,6 +427,15 @@ def import_data_objects( ]: raise NotImplementedError() + @property + def export_data_objects( + self, + ) -> Callable[ + [vectorsearch_service.ExportDataObjectsRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def list_operations( self, diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/grpc.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/grpc.py index 41916d8c555f..89404ccff12f 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/grpc.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/grpc.py @@ -623,6 +623,35 @@ def import_data_objects( ) return self._stubs["import_data_objects"] + @property + def export_data_objects( + self, + ) -> Callable[ + [vectorsearch_service.ExportDataObjectsRequest], operations_pb2.Operation + ]: + r"""Return a callable for the export data objects method over gRPC. + + Initiates a Long-Running Operation to export + DataObjects from a Collection. + + Returns: + Callable[[~.ExportDataObjectsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "export_data_objects" not in self._stubs: + self._stubs["export_data_objects"] = self._logged_channel.unary_unary( + "/google.cloud.vectorsearch.v1beta.VectorSearchService/ExportDataObjects", + request_serializer=vectorsearch_service.ExportDataObjectsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["export_data_objects"] + def close(self): self._logged_channel.close() diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/grpc_asyncio.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/grpc_asyncio.py index c0b0a35127cf..0ea1da4a0887 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/grpc_asyncio.py @@ -642,6 +642,36 @@ def import_data_objects( ) return self._stubs["import_data_objects"] + @property + def export_data_objects( + self, + ) -> Callable[ + [vectorsearch_service.ExportDataObjectsRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the export data objects method over gRPC. + + Initiates a Long-Running Operation to export + DataObjects from a Collection. + + Returns: + Callable[[~.ExportDataObjectsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "export_data_objects" not in self._stubs: + self._stubs["export_data_objects"] = self._logged_channel.unary_unary( + "/google.cloud.vectorsearch.v1beta.VectorSearchService/ExportDataObjects", + request_serializer=vectorsearch_service.ExportDataObjectsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["export_data_objects"] + def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { @@ -675,16 +705,43 @@ def _prep_wrapped_messages(self, client_info): ), self.create_collection: self._wrap_method( self.create_collection, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.update_collection: self._wrap_method( self.update_collection, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.delete_collection: self._wrap_method( self.delete_collection, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), @@ -718,19 +775,51 @@ def _prep_wrapped_messages(self, client_info): ), self.create_index: self._wrap_method( self.create_index, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.delete_index: self._wrap_method( self.delete_index, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), self.import_data_objects: self._wrap_method( self.import_data_objects, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), default_timeout=60.0, client_info=client_info, ), + self.export_data_objects: self._wrap_method( + self.export_data_objects, + default_timeout=None, + client_info=client_info, + ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/rest.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/rest.py index e4164457c67f..438dc650d98a 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/rest.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/rest.py @@ -106,6 +106,14 @@ def post_delete_index(self, response): logging.log(f"Received response: {response}") return response + def pre_export_data_objects(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_export_data_objects(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_collection(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -354,6 +362,55 @@ def post_delete_index_with_metadata( """ return response, metadata + def pre_export_data_objects( + self, + request: vectorsearch_service.ExportDataObjectsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vectorsearch_service.ExportDataObjectsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for export_data_objects + + Override in a subclass to manipulate the request or metadata + before they are sent to the VectorSearchService server. + """ + return request, metadata + + def post_export_data_objects( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for export_data_objects + + DEPRECATED. Please use the `post_export_data_objects_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VectorSearchService server but before + it is returned to user code. This `post_export_data_objects` interceptor runs + before the `post_export_data_objects_with_metadata` interceptor. + """ + return response + + def post_export_data_objects_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for export_data_objects + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VectorSearchService server but before it is returned to user code. + + We recommend only using this `post_export_data_objects_with_metadata` + interceptor in new development instead of the `post_export_data_objects` interceptor. + When both interceptors are used, this `post_export_data_objects_with_metadata` interceptor runs after the + `post_export_data_objects` interceptor. The (possibly modified) response returned by + `post_export_data_objects` will be passed to + `post_export_data_objects_with_metadata`. + """ + return response, metadata + def pre_get_collection( self, request: vectorsearch_service.GetCollectionRequest, @@ -1547,6 +1604,163 @@ def __call__( ) return resp + class _ExportDataObjects( + _BaseVectorSearchServiceRestTransport._BaseExportDataObjects, + VectorSearchServiceRestStub, + ): + def __hash__(self): + return hash("VectorSearchServiceRestTransport.ExportDataObjects") + + @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: vectorsearch_service.ExportDataObjectsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the export data objects method over HTTP. + + Args: + request (~.vectorsearch_service.ExportDataObjectsRequest): + The request object. Request message for + [VectorSearchService.ExportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ExportDataObjects]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVectorSearchServiceRestTransport._BaseExportDataObjects._get_http_options() + ) + + request, metadata = self._interceptor.pre_export_data_objects( + request, metadata + ) + transcoded_request = _BaseVectorSearchServiceRestTransport._BaseExportDataObjects._get_transcoded_request( + http_options, request + ) + + body = _BaseVectorSearchServiceRestTransport._BaseExportDataObjects._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseVectorSearchServiceRestTransport._BaseExportDataObjects._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 = json_format.MessageToJson(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.vectorsearch_v1beta.VectorSearchServiceClient.ExportDataObjects", + extra={ + "serviceName": "google.cloud.vectorsearch.v1beta.VectorSearchService", + "rpcName": "ExportDataObjects", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + VectorSearchServiceRestTransport._ExportDataObjects._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_export_data_objects(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_export_data_objects_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.vectorsearch_v1beta.VectorSearchServiceClient.export_data_objects", + extra={ + "serviceName": "google.cloud.vectorsearch.v1beta.VectorSearchService", + "rpcName": "ExportDataObjects", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + class _GetCollection( _BaseVectorSearchServiceRestTransport._BaseGetCollection, VectorSearchServiceRestStub, @@ -1879,7 +2093,7 @@ def __call__( Args: request (~.vectorsearch_service.ImportDataObjectsRequest): The request object. Request message for - [DataObjectService.ImportDataObjects][]. + [VectorSearchService.ImportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ImportDataObjects]. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2485,6 +2699,16 @@ def delete_index( # In C++ this would require a dynamic_cast return self._DeleteIndex(self._session, self._host, self._interceptor) # type: ignore + @property + def export_data_objects( + self, + ) -> Callable[ + [vectorsearch_service.ExportDataObjectsRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ExportDataObjects(self._session, self._host, self._interceptor) # type: ignore + @property def get_collection( self, diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/rest_base.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/rest_base.py index 56a2d6902fb0..c7b17892a6e6 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/rest_base.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/services/vector_search_service/transports/rest_base.py @@ -301,6 +301,63 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseExportDataObjects: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1beta/{name=projects/*/locations/*/collections/*}:exportDataObjects", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = vectorsearch_service.ExportDataObjectsRequest.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( + _BaseVectorSearchServiceRestTransport._BaseExportDataObjects._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseGetCollection: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/__init__.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/__init__.py index 3e670344ba14..bedf07b6fae0 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/__init__.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/__init__.py @@ -56,6 +56,9 @@ DeleteCollectionRequest, DeleteIndexRequest, DenseVectorField, + ExportDataObjectsMetadata, + ExportDataObjectsRequest, + ExportDataObjectsResponse, GetCollectionRequest, GetIndexRequest, ImportDataObjectsMetadata, @@ -115,6 +118,9 @@ "DeleteCollectionRequest", "DeleteIndexRequest", "DenseVectorField", + "ExportDataObjectsMetadata", + "ExportDataObjectsRequest", + "ExportDataObjectsResponse", "GetCollectionRequest", "GetIndexRequest", "ImportDataObjectsMetadata", diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object.py index fcd39ea87b40..67bc119b866f 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object.py @@ -37,13 +37,13 @@ class DataObject(proto.Message): Attributes: name (str): - Immutable. The fully qualified resource name of the + Identifier. The fully qualified resource name of the dataObject. Format: ``projects/{project}/locations/{location}/collections/{collection}/dataObjects/{data_object_id}`` The data_object_id must be 1-63 characters long, and comply - with RFC1035. + with `RFC1035 `__. data_object_id (str): Output only. The id of the dataObject. create_time (google.protobuf.timestamp_pb2.Timestamp): diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object_search_service.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object_search_service.py index ba0ba5935d22..ffaf470482ad 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object_search_service.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object_search_service.py @@ -106,14 +106,14 @@ class SearchHint(proto.Message): Attributes: use_index (google.cloud.vectorsearch_v1beta.types.SearchHint.IndexHint): - Specifies that the search should use a - particular index. + Optional. Specifies that the search should + use a particular index. This field is a member of `oneof`_ ``index_type``. use_knn (bool): - If set to true, the search will use the - system's default K-Nearest Neighbor (KNN) index - engine. + Optional. If set to true, the search will use + the system's default K-Nearest Neighbor (KNN) + index engine. This field is a member of `oneof`_ ``index_type``. """ @@ -305,6 +305,11 @@ class SemanticSearch(proto.Message): return. This field is a member of `oneof`_ ``_top_k``. + search_hint (google.cloud.vectorsearch_v1beta.types.SearchHint): + Optional. Sets the search hint. If no + strategy is specified, the service will use an + index if one is available, and fall back to KNN + search otherwise. """ search_text: str = proto.Field( @@ -335,6 +340,11 @@ class SemanticSearch(proto.Message): number=4, optional=True, ) + search_hint: "SearchHint" = proto.Field( + proto.MESSAGE, + number=7, + message="SearchHint", + ) class TextSearch(proto.Message): @@ -354,6 +364,10 @@ class TextSearch(proto.Message): Optional. The number of results to return. This field is a member of `oneof`_ ``_top_k``. + filter (google.protobuf.struct_pb2.Struct): + Optional. A JSON filter expression, e.g. + ``{"genre": {"$eq": "sci-fi"}}``, represented as a + ``google.protobuf.Struct``. """ search_text: str = proto.Field( @@ -374,6 +388,11 @@ class TextSearch(proto.Message): number=4, optional=True, ) + filter: struct_pb2.Struct = proto.Field( + proto.MESSAGE, + number=5, + message=struct_pb2.Struct, + ) class SearchDataObjectsRequest(proto.Message): diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object_service.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object_service.py index ac40c93ea8fd..6041b20f8805 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object_service.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/data_object_service.py @@ -49,9 +49,10 @@ class CreateDataObjectRequest(proto.Message): ``projects/{project}/locations/{location}/collections/{collection}`` data_object_id (str): Required. The id of the dataObject to create. The id must be - 1-63 characters long, and comply with RFC1035. Specifically, - it must be 1-63 characters long and match the regular - expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. + 1-63 characters long, and comply with + `RFC1035 `__. + Specifically, it must be 1-63 characters long and match the + regular expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. data_object (google.cloud.vectorsearch_v1beta.types.DataObject): Required. The DataObject to create. """ diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/embedding_config.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/embedding_config.py index 9196644c2daf..3d7aec1b41ec 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/embedding_config.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/embedding_config.py @@ -86,7 +86,7 @@ class VertexEmbeddingConfig(proto.Message): one or more references to fields in the DataObject, e.g.: - "Movie Title: {title} ---- Movie Plot: {plot}"". + "Movie Title: {title} ---- Movie Plot: {plot}". task_type (google.cloud.vectorsearch_v1beta.types.EmbeddingTaskType): Required. Required: Task type for the embeddings. diff --git a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/vectorsearch_service.py b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/vectorsearch_service.py index 5bbc0b00866c..2010defb7e8a 100644 --- a/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/vectorsearch_service.py +++ b/packages/google-cloud-vectorsearch/google/cloud/vectorsearch_v1beta/types/vectorsearch_service.py @@ -48,6 +48,9 @@ "ImportDataObjectsRequest", "ImportDataObjectsMetadata", "ImportDataObjectsResponse", + "ExportDataObjectsRequest", + "ExportDataObjectsMetadata", + "ExportDataObjectsResponse", }, ) @@ -290,9 +293,10 @@ class CreateCollectionRequest(proto.Message): Required. Value for parent. collection_id (str): Required. ID of the Collection to create. The id must be - 1-63 characters long, and comply with RFC1035. Specifically, - it must be 1-63 characters long and match the regular - expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. + 1-63 characters long, and comply with + `RFC1035 `__. + Specifically, it must be 1-63 characters long and match the + regular expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. collection (google.cloud.vectorsearch_v1beta.types.Collection): Required. The resource being created request_id (str): @@ -351,8 +355,9 @@ class UpdateCollectionRequest(proto.Message): The following fields support update: ``display_name``, ``description``, ``labels``, ``data_schema``, ``vector_schema``. For ``data_schema`` and - ``vector_schema``, fields can only be added, not modified or - deleted. Partial updates for ``data_schema`` and + ``vector_schema``, fields can only be added, not deleted, + but ``vertex_embedding_config`` in ``vector_schema`` can be + added or removed. Partial updates for ``data_schema`` and ``vector_schema`` are also supported by using sub-field paths in ``update_mask``, e.g. ``data_schema.properties.foo`` or @@ -526,9 +531,10 @@ class CreateIndexRequest(proto.Message): ``projects/{project}/locations/{location}/collections/{collection}`` index_id (str): Required. ID of the Index to create. The id must be 1-63 - characters long, and comply with RFC1035. Specifically, it - must be 1-63 characters long and match the regular - expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. + characters long, and comply with + `RFC1035 `__. + Specifically, it must be 1-63 characters long and match the + regular expression ``[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?``. index (google.cloud.vectorsearch_v1beta.types.Index): Required. The resource being created request_id (str): @@ -758,7 +764,9 @@ class OperationMetadata(proto.Message): class ImportDataObjectsRequest(proto.Message): - r"""Request message for [DataObjectService.ImportDataObjects][]. + r"""Request message for + [VectorSearchService.ImportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ImportDataObjects]. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields @@ -785,6 +793,13 @@ class GcsImportConfig(proto.Message): Required. URI prefix of the Cloud Storage location to write any errors encountered during the import. + output_uri (str): + Optional. URI prefix of the Cloud Storage location to write + DataObject ``IDs`` and ``etags`` of DataObjects that were + successfully imported. The service will write the + successfully imported DataObjects to sharded files under + this prefix. If this field is empty, no output will be + written. """ contents_uri: str = proto.Field( @@ -795,6 +810,10 @@ class GcsImportConfig(proto.Message): proto.STRING, number=2, ) + output_uri: str = proto.Field( + proto.STRING, + number=3, + ) gcs_import: GcsImportConfig = proto.Field( proto.MESSAGE, @@ -809,7 +828,8 @@ class GcsImportConfig(proto.Message): class ImportDataObjectsMetadata(proto.Message): - r"""Metadata for [DataObjectService.ImportDataObjects][]. + r"""Metadata for + [VectorSearchService.ImportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ImportDataObjects]. Attributes: create_time (google.protobuf.timestamp_pb2.Timestamp): @@ -845,7 +865,8 @@ class ImportDataObjectsMetadata(proto.Message): class ImportDataObjectsResponse(proto.Message): - r"""Response for [DataObjectService.ImportDataObjects][]. + r"""Response for + [VectorSearchService.ImportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ImportDataObjects]. Attributes: status (google.rpc.status_pb2.Status): @@ -859,4 +880,99 @@ class ImportDataObjectsResponse(proto.Message): ) +class ExportDataObjectsRequest(proto.Message): + r"""Request message for + [VectorSearchService.ExportDataObjects][google.cloud.vectorsearch.v1beta.VectorSearchService.ExportDataObjects]. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + gcs_destination (google.cloud.vectorsearch_v1beta.types.ExportDataObjectsRequest.GcsExportDestination): + The Cloud Storage location where user wants + to export Data Objects. + + This field is a member of `oneof`_ ``destination``. + name (str): + Required. The resource name of the Collection from which we + want to export Data Objects. Format: + ``projects/{project}/locations/{location}/collections/{collection}``. + """ + + class GcsExportDestination(proto.Message): + r"""Google Cloud Storage configuration for the export. + + Attributes: + export_uri (str): + Required. URI prefix of the Cloud Storage + where to export Data Objects. The bucket is + required to be in the same region as the + collection. + format_ (google.cloud.vectorsearch_v1beta.types.ExportDataObjectsRequest.GcsExportDestination.Format): + Required. The format of the exported Data + Objects. + """ + + class Format(proto.Enum): + r"""Options for the format of the exported Data Objects. + New formats may be added in the future. + + Values: + FORMAT_UNSPECIFIED (0): + Unspecified format. + JSON (1): + The exported Data Objects will be in JSON + format. + """ + FORMAT_UNSPECIFIED = 0 + JSON = 1 + + export_uri: str = proto.Field( + proto.STRING, + number=1, + ) + format_: "ExportDataObjectsRequest.GcsExportDestination.Format" = proto.Field( + proto.ENUM, + number=2, + enum="ExportDataObjectsRequest.GcsExportDestination.Format", + ) + + gcs_destination: GcsExportDestination = proto.Field( + proto.MESSAGE, + number=2, + oneof="destination", + message=GcsExportDestination, + ) + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ExportDataObjectsMetadata(proto.Message): + r"""Metadata for the ExportDataObjects LRO. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + The time the operation was created. + finish_time (google.protobuf.timestamp_pb2.Timestamp): + The time the operation finished. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + finish_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + + +class ExportDataObjectsResponse(proto.Message): + r"""Response for the ExportDataObjects LRO.""" + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-vectorsearch/samples/generated_samples/snippet_metadata_google.cloud.vectorsearch.v1beta.json b/packages/google-cloud-vectorsearch/samples/generated_samples/snippet_metadata_google.cloud.vectorsearch.v1beta.json index ce90358a1d74..a6733ef526f5 100644 --- a/packages/google-cloud-vectorsearch/samples/generated_samples/snippet_metadata_google.cloud.vectorsearch.v1beta.json +++ b/packages/google-cloud-vectorsearch/samples/generated_samples/snippet_metadata_google.cloud.vectorsearch.v1beta.json @@ -2446,6 +2446,159 @@ ], "title": "vectorsearch_v1beta_generated_vector_search_service_delete_index_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.vectorsearch_v1beta.VectorSearchServiceAsyncClient", + "shortName": "VectorSearchServiceAsyncClient" + }, + "fullName": "google.cloud.vectorsearch_v1beta.VectorSearchServiceAsyncClient.export_data_objects", + "method": { + "fullName": "google.cloud.vectorsearch.v1beta.VectorSearchService.ExportDataObjects", + "service": { + "fullName": "google.cloud.vectorsearch.v1beta.VectorSearchService", + "shortName": "VectorSearchService" + }, + "shortName": "ExportDataObjects" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.vectorsearch_v1beta.types.ExportDataObjectsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "export_data_objects" + }, + "description": "Sample for ExportDataObjects", + "file": "vectorsearch_v1beta_generated_vector_search_service_export_data_objects_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "vectorsearch_v1beta_generated_VectorSearchService_ExportDataObjects_async", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "vectorsearch_v1beta_generated_vector_search_service_export_data_objects_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.vectorsearch_v1beta.VectorSearchServiceClient", + "shortName": "VectorSearchServiceClient" + }, + "fullName": "google.cloud.vectorsearch_v1beta.VectorSearchServiceClient.export_data_objects", + "method": { + "fullName": "google.cloud.vectorsearch.v1beta.VectorSearchService.ExportDataObjects", + "service": { + "fullName": "google.cloud.vectorsearch.v1beta.VectorSearchService", + "shortName": "VectorSearchService" + }, + "shortName": "ExportDataObjects" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.vectorsearch_v1beta.types.ExportDataObjectsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "export_data_objects" + }, + "description": "Sample for ExportDataObjects", + "file": "vectorsearch_v1beta_generated_vector_search_service_export_data_objects_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "vectorsearch_v1beta_generated_VectorSearchService_ExportDataObjects_sync", + "segments": [ + { + "end": 60, + "start": 27, + "type": "FULL" + }, + { + "end": 60, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 50, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 57, + "start": 51, + "type": "REQUEST_EXECUTION" + }, + { + "end": 61, + "start": 58, + "type": "RESPONSE_HANDLING" + } + ], + "title": "vectorsearch_v1beta_generated_vector_search_service_export_data_objects_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/packages/google-cloud-vectorsearch/samples/generated_samples/vectorsearch_v1beta_generated_vector_search_service_export_data_objects_async.py b/packages/google-cloud-vectorsearch/samples/generated_samples/vectorsearch_v1beta_generated_vector_search_service_export_data_objects_async.py new file mode 100644 index 000000000000..9e6553c01a1a --- /dev/null +++ b/packages/google-cloud-vectorsearch/samples/generated_samples/vectorsearch_v1beta_generated_vector_search_service_export_data_objects_async.py @@ -0,0 +1,62 @@ +# -*- 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 ExportDataObjects +# 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-vectorsearch + + +# [START vectorsearch_v1beta_generated_VectorSearchService_ExportDataObjects_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 vectorsearch_v1beta + + +async def sample_export_data_objects(): + # Create a client + client = vectorsearch_v1beta.VectorSearchServiceAsyncClient() + + # Initialize request argument(s) + gcs_destination = vectorsearch_v1beta.GcsExportDestination() + gcs_destination.export_uri = "export_uri_value" + gcs_destination.format_ = "JSON" + + request = vectorsearch_v1beta.ExportDataObjectsRequest( + gcs_destination=gcs_destination, + name="name_value", + ) + + # Make the request + operation = client.export_data_objects(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + +# [END vectorsearch_v1beta_generated_VectorSearchService_ExportDataObjects_async] diff --git a/packages/google-cloud-vectorsearch/samples/generated_samples/vectorsearch_v1beta_generated_vector_search_service_export_data_objects_sync.py b/packages/google-cloud-vectorsearch/samples/generated_samples/vectorsearch_v1beta_generated_vector_search_service_export_data_objects_sync.py new file mode 100644 index 000000000000..7c5093841754 --- /dev/null +++ b/packages/google-cloud-vectorsearch/samples/generated_samples/vectorsearch_v1beta_generated_vector_search_service_export_data_objects_sync.py @@ -0,0 +1,62 @@ +# -*- 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 ExportDataObjects +# 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-vectorsearch + + +# [START vectorsearch_v1beta_generated_VectorSearchService_ExportDataObjects_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 vectorsearch_v1beta + + +def sample_export_data_objects(): + # Create a client + client = vectorsearch_v1beta.VectorSearchServiceClient() + + # Initialize request argument(s) + gcs_destination = vectorsearch_v1beta.GcsExportDestination() + gcs_destination.export_uri = "export_uri_value" + gcs_destination.format_ = "JSON" + + request = vectorsearch_v1beta.ExportDataObjectsRequest( + gcs_destination=gcs_destination, + name="name_value", + ) + + # Make the request + operation = client.export_data_objects(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + +# [END vectorsearch_v1beta_generated_VectorSearchService_ExportDataObjects_sync] diff --git a/packages/google-cloud-vectorsearch/tests/unit/gapic/vectorsearch_v1beta/test_vector_search_service.py b/packages/google-cloud-vectorsearch/tests/unit/gapic/vectorsearch_v1beta/test_vector_search_service.py index 95245e54623a..479be1694df5 100644 --- a/packages/google-cloud-vectorsearch/tests/unit/gapic/vectorsearch_v1beta/test_vector_search_service.py +++ b/packages/google-cloud-vectorsearch/tests/unit/gapic/vectorsearch_v1beta/test_vector_search_service.py @@ -5114,6 +5114,266 @@ async def test_import_data_objects_field_headers_async(): ) in kw["metadata"] +@pytest.mark.parametrize( + "request_type", + [ + vectorsearch_service.ExportDataObjectsRequest, + dict, + ], +) +def test_export_data_objects(request_type, transport: str = "grpc"): + client = VectorSearchServiceClient( + 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.export_data_objects), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.export_data_objects(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = vectorsearch_service.ExportDataObjectsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_export_data_objects_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 = VectorSearchServiceClient( + 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 = vectorsearch_service.ExportDataObjectsRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_data_objects), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.export_data_objects(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vectorsearch_service.ExportDataObjectsRequest( + name="name_value", + ) + + +def test_export_data_objects_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 = VectorSearchServiceClient( + 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.export_data_objects in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.export_data_objects + ] = mock_rpc + request = {} + client.export_data_objects(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.export_data_objects(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_export_data_objects_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 = VectorSearchServiceAsyncClient( + 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.export_data_objects + 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.export_data_objects + ] = mock_rpc + + request = {} + await client.export_data_objects(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.export_data_objects(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_export_data_objects_async( + transport: str = "grpc_asyncio", + request_type=vectorsearch_service.ExportDataObjectsRequest, +): + client = VectorSearchServiceAsyncClient( + 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.export_data_objects), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.export_data_objects(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = vectorsearch_service.ExportDataObjectsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_export_data_objects_async_from_dict(): + await test_export_data_objects_async(request_type=dict) + + +def test_export_data_objects_field_headers(): + client = VectorSearchServiceClient( + 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 = vectorsearch_service.ExportDataObjectsRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_data_objects), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.export_data_objects(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_export_data_objects_field_headers_async(): + client = VectorSearchServiceAsyncClient( + 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 = vectorsearch_service.ExportDataObjectsRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_data_objects), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.export_data_objects(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + def test_list_collections_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call @@ -7122,6 +7382,132 @@ def test_import_data_objects_rest_unset_required_fields(): assert set(unset_fields) == (set(()) & set(("name",))) +def test_export_data_objects_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 = VectorSearchServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.export_data_objects in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.export_data_objects + ] = mock_rpc + + request = {} + client.export_data_objects(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.export_data_objects(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_export_data_objects_rest_required_fields( + request_type=vectorsearch_service.ExportDataObjectsRequest, +): + transport_class = transports.VectorSearchServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_data_objects._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).export_data_objects._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VectorSearchServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.export_data_objects(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_export_data_objects_rest_unset_required_fields(): + transport = transports.VectorSearchServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.export_data_objects._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.VectorSearchServiceGrpcTransport( @@ -7446,6 +7832,29 @@ def test_import_data_objects_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_export_data_objects_empty_call_grpc(): + client = VectorSearchServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_data_objects), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.export_data_objects(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = vectorsearch_service.ExportDataObjectsRequest() + + assert args[0] == request_msg + + def test_transport_kind_grpc_asyncio(): transport = VectorSearchServiceAsyncClient.get_transport_class("grpc_asyncio")( credentials=async_anonymous_credentials() @@ -7735,6 +8144,33 @@ async def test_import_data_objects_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_export_data_objects_empty_call_grpc_asyncio(): + client = VectorSearchServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_data_objects), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.export_data_objects(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = vectorsearch_service.ExportDataObjectsRequest() + + assert args[0] == request_msg + + def test_transport_kind_rest(): transport = VectorSearchServiceClient.get_transport_class("rest")( credentials=ga_credentials.AnonymousCredentials() @@ -9269,6 +9705,130 @@ def test_import_data_objects_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() +def test_export_data_objects_rest_bad_request( + request_type=vectorsearch_service.ExportDataObjectsRequest, +): + client = VectorSearchServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/collections/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.export_data_objects(request) + + +@pytest.mark.parametrize( + "request_type", + [ + vectorsearch_service.ExportDataObjectsRequest, + dict, + ], +) +def test_export_data_objects_rest_call_success(request_type): + client = VectorSearchServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/collections/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.export_data_objects(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_export_data_objects_rest_interceptors(null_interceptor): + transport = transports.VectorSearchServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VectorSearchServiceRestInterceptor(), + ) + client = VectorSearchServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VectorSearchServiceRestInterceptor, "post_export_data_objects" + ) as post, mock.patch.object( + transports.VectorSearchServiceRestInterceptor, + "post_export_data_objects_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VectorSearchServiceRestInterceptor, "pre_export_data_objects" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = vectorsearch_service.ExportDataObjectsRequest.pb( + vectorsearch_service.ExportDataObjectsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = vectorsearch_service.ExportDataObjectsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.export_data_objects( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): client = VectorSearchServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -9852,6 +10412,28 @@ def test_import_data_objects_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_export_data_objects_empty_call_rest(): + client = VectorSearchServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.export_data_objects), "__call__" + ) as call: + client.export_data_objects(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = vectorsearch_service.ExportDataObjectsRequest() + + assert args[0] == request_msg + + def test_vector_search_service_rest_lro_client(): client = VectorSearchServiceClient( credentials=ga_credentials.AnonymousCredentials(), @@ -9912,6 +10494,7 @@ def test_vector_search_service_base_transport(): "create_index", "delete_index", "import_data_objects", + "export_data_objects", "get_location", "list_locations", "get_operation", @@ -10213,6 +10796,9 @@ def test_vector_search_service_client_transport_session_collision(transport_name session1 = client1.transport.import_data_objects._session session2 = client2.transport.import_data_objects._session assert session1 != session2 + session1 = client1.transport.export_data_objects._session + session2 = client2.transport.export_data_objects._session + assert session1 != session2 def test_vector_search_service_grpc_transport_channel():