diff --git a/CHANGELOG.md b/CHANGELOG.md index 408cef24ef171..32f4537df8211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ We are happy to announce the following GA libraries. Unless specifically noted, the APIs in these libraries are stable, and are ready for production use. - [Gemini Enterprise for Customer Experience API](google/cloud/ces/README.md) +- [Vector Search API](google/cloud/vectorsearch/README.md) - [Vision AI API](/google/cloud/visionai/README.md) - [Workload Manager](/google/cloud/workloadmanager/README.md) diff --git a/README.md b/README.md index e27e630f5d5a3..b2607cf6eb1d8 100644 --- a/README.md +++ b/README.md @@ -533,6 +533,9 @@ See each library's `README.md` file for more information about: - [Cloud Translation API](google/cloud/translate/README.md) [[quickstart]](google/cloud/translate/quickstart/README.md) [[reference]](https://cloud.google.com/cpp/docs/reference/translate/latest) +- [Vector Search API](google/cloud/vectorsearch/README.md) + [[quickstart]](google/cloud/vectorsearch/quickstart/README.md) + [[reference]](https://cloud.google.com/cpp/docs/reference/vectorsearch/latest) - [Video Services](google/cloud/video/README.md) [[quickstart]](google/cloud/video/quickstart/README.md) [[reference]](https://cloud.google.com/cpp/docs/reference/video/latest) diff --git a/ci/abi-dumps/google_cloud_cpp_vectorsearch.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_vectorsearch.expected.abi.dump.gz new file mode 100644 index 0000000000000..6c0940615b2e9 Binary files /dev/null and b/ci/abi-dumps/google_cloud_cpp_vectorsearch.expected.abi.dump.gz differ diff --git a/ci/etc/expected_install_directories b/ci/etc/expected_install_directories index f3426ee849677..fa28cfa35540d 100644 --- a/ci/etc/expected_install_directories +++ b/ci/etc/expected_install_directories @@ -1163,6 +1163,10 @@ ./include/google/cloud/translate/v3 ./include/google/cloud/translate/v3/internal ./include/google/cloud/translate/v3/mocks +./include/google/cloud/vectorsearch +./include/google/cloud/vectorsearch/v1 +./include/google/cloud/vectorsearch/v1/internal +./include/google/cloud/vectorsearch/v1/mocks ./include/google/cloud/video ./include/google/cloud/video/livestream ./include/google/cloud/video/livestream/v1 @@ -1570,6 +1574,8 @@ ./lib64/cmake/google_cloud_cpp_trace_mocks ./lib64/cmake/google_cloud_cpp_translate ./lib64/cmake/google_cloud_cpp_translate_mocks +./lib64/cmake/google_cloud_cpp_vectorsearch +./lib64/cmake/google_cloud_cpp_vectorsearch_mocks ./lib64/cmake/google_cloud_cpp_video ./lib64/cmake/google_cloud_cpp_video_mocks ./lib64/cmake/google_cloud_cpp_videointelligence diff --git a/cmake/GoogleCloudCppFeatures.cmake b/cmake/GoogleCloudCppFeatures.cmake index 45e0edc5e497f..d014acc8a52c4 100644 --- a/cmake/GoogleCloudCppFeatures.cmake +++ b/cmake/GoogleCloudCppFeatures.cmake @@ -186,6 +186,7 @@ set(GOOGLE_CLOUD_CPP_GA_LIBRARIES "tpu" "trace" "translate" + "vectorsearch" "video" "videointelligence" "vision" diff --git a/external/googleapis/protodeps/vectorsearch.deps b/external/googleapis/protodeps/vectorsearch.deps new file mode 100644 index 0000000000000..ce4eebcf1a3ab --- /dev/null +++ b/external/googleapis/protodeps/vectorsearch.deps @@ -0,0 +1,9 @@ +@googleapis//google/api:annotations_proto +@googleapis//google/api:client_proto +@googleapis//google/api:field_behavior_proto +@googleapis//google/api:field_info_proto +@googleapis//google/api:http_proto +@googleapis//google/api:launch_stage_proto +@googleapis//google/api:resource_proto +@googleapis//google/longrunning:operations_proto +@googleapis//google/rpc:status_proto diff --git a/external/googleapis/protolists/vectorsearch.list b/external/googleapis/protolists/vectorsearch.list new file mode 100644 index 0000000000000..0c723548e099d --- /dev/null +++ b/external/googleapis/protolists/vectorsearch.list @@ -0,0 +1,6 @@ +@googleapis//google/cloud/vectorsearch/v1:common.proto +@googleapis//google/cloud/vectorsearch/v1:data_object.proto +@googleapis//google/cloud/vectorsearch/v1:data_object_search_service.proto +@googleapis//google/cloud/vectorsearch/v1:data_object_service.proto +@googleapis//google/cloud/vectorsearch/v1:embedding_config.proto +@googleapis//google/cloud/vectorsearch/v1:vectorsearch_service.proto diff --git a/external/googleapis/update_libraries.sh b/external/googleapis/update_libraries.sh index ca9595c156431..65672303c0f3b 100755 --- a/external/googleapis/update_libraries.sh +++ b/external/googleapis/update_libraries.sh @@ -331,6 +331,7 @@ declare -A -r LIBRARIES=( "@googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_grpc" )" ["translate"]="@googleapis//google/cloud/translate/v3:translation_cc_grpc" + ["vectorsearch"]="@googleapis//google/cloud/vectorsearch/v1:vectorsearch_cc_grpc" ["video"]="$( printf ",%s" \ "@googleapis//google/cloud/video/livestream/v1:livestream_cc_grpc" \ diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index 59e79839593a5..82a54193a27f3 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -4022,6 +4022,28 @@ service { retryable_status_codes: ["kUnavailable"] } +# Vector Search +service { + service_proto_path: "google/cloud/vectorsearch/v1/data_object_service.proto" + product_path: "google/cloud/vectorsearch/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] +} + +service { + service_proto_path: "google/cloud/vectorsearch/v1/vectorsearch_service.proto" + product_path: "google/cloud/vectorsearch/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] +} + +service { + service_proto_path: "google/cloud/vectorsearch/v1/data_object_search_service.proto" + product_path: "google/cloud/vectorsearch/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] +} + # Video service { service_proto_path: "google/cloud/video/livestream/v1/service.proto" diff --git a/google/cloud/vectorsearch/BUILD.bazel b/google/cloud/vectorsearch/BUILD.bazel new file mode 100644 index 0000000000000..2c1c398a1ab79 --- /dev/null +++ b/google/cloud/vectorsearch/BUILD.bazel @@ -0,0 +1,31 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("//bazel:gapic.bzl", "cc_gapic_library") + +package(default_visibility = ["//visibility:private"]) + +licenses(["notice"]) # Apache 2.0 + +service_dirs = ["v1/"] + +googleapis_deps = [ + "@googleapis//google/cloud/vectorsearch/v1:vectorsearch_cc_grpc", +] + +cc_gapic_library( + name = "vectorsearch", + googleapis_deps = googleapis_deps, + service_dirs = service_dirs, +) diff --git a/google/cloud/vectorsearch/CMakeLists.txt b/google/cloud/vectorsearch/CMakeLists.txt new file mode 100644 index 0000000000000..f507b35b3d953 --- /dev/null +++ b/google/cloud/vectorsearch/CMakeLists.txt @@ -0,0 +1,35 @@ +# ~~~ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +include(GoogleCloudCppLibrary) + +google_cloud_cpp_add_gapic_library(vectorsearch "Vector Search API" + SERVICE_DIRS "v1/") + +if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS) + add_executable(vectorsearch_quickstart "quickstart/quickstart.cc") + target_link_libraries(vectorsearch_quickstart + PRIVATE google-cloud-cpp::vectorsearch) + google_cloud_cpp_add_common_options(vectorsearch_quickstart) + add_test( + NAME vectorsearch_quickstart + COMMAND + cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake" + $ GOOGLE_CLOUD_PROJECT + GOOGLE_CLOUD_CPP_TEST_REGION) + set_tests_properties(vectorsearch_quickstart + PROPERTIES LABELS "integration-test;quickstart") +endif () diff --git a/google/cloud/vectorsearch/README.md b/google/cloud/vectorsearch/README.md new file mode 100644 index 0000000000000..3fe37e653f393 --- /dev/null +++ b/google/cloud/vectorsearch/README.md @@ -0,0 +1,68 @@ +# Vector Search API C++ Client Library + +This directory contains an idiomatic C++ client library for the +[Vector Search API][cloud-service-docs]. + +The Vector Search API provides a fully-managed, highly performant, and scalable +vector database designed to power next-generation search, recommendation, and +generative AI applications. It allows you to store, index, and query your data +and its corresponding vector embeddings through a simple, intuitive interface. +With Vector Search, you can define custom schemas for your data, insert objects +with associated metadata, automatically generate embeddings from your data, and +perform fast approximate nearest neighbor (ANN) searches to find semantically +similar items at scale. + +While this library is **GA**, please note that the Google Cloud C++ client +libraries do **not** follow [Semantic Versioning](https://semver.org/). + +## Quickstart + +The [quickstart/](quickstart/README.md) directory contains a minimal environment +to get started using this client library in a larger project. The following +"Hello World" program is used in this quickstart, and should give you a taste of +this library. + + + +```cc +#include "google/cloud/vectorsearch/v1/vector_search_client.h" +#include "google/cloud/location.h" +#include + +int main(int argc, char* argv[]) try { + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << " project-id location-id\n"; + return 1; + } + + auto const location = google::cloud::Location(argv[1], argv[2]); + + namespace vectorsearch = ::google::cloud::vectorsearch_v1; + auto client = vectorsearch::VectorSearchServiceClient( + vectorsearch::MakeVectorSearchServiceConnection()); + + for (auto r : client.ListCollections(location.FullName())) { + if (!r) throw std::move(r).status(); + std::cout << r->DebugString() << "\n"; + } + + return 0; +} catch (google::cloud::Status const& status) { + std::cerr << "google::cloud::Status thrown: " << status << "\n"; + return 1; +} +``` + + + +## More Information + +- Official documentation about the [Vector Search API][cloud-service-docs] + service +- [Reference doxygen documentation][doxygen-link] for each release of this + client library +- Detailed header comments in our [public `.h`][source-link] files + +[cloud-service-docs]: https://docs.cloud.google.com/vertex-ai/docs/vector-search-2/overview +[doxygen-link]: https://cloud.google.com/cpp/docs/reference/vectorsearch/latest/ +[source-link]: https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/vectorsearch diff --git a/google/cloud/vectorsearch/doc/environment-variables.dox b/google/cloud/vectorsearch/doc/environment-variables.dox new file mode 100644 index 0000000000000..6f055899cd773 --- /dev/null +++ b/google/cloud/vectorsearch/doc/environment-variables.dox @@ -0,0 +1,57 @@ +/*! +@page vectorsearch-env Environment Variables + +A number of environment variables can be used to configure the behavior of +the library. There are also functions to configure this behavior in code. The +environment variables are convenient when troubleshooting problems. + +@section vectorsearch-env-endpoint Endpoint Overrides + + + +- `GOOGLE_CLOUD_CPP_DATA_OBJECT_SEARCH_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "vectorsearch.googleapis.com") + used by `MakeDataObjectSearchServiceConnection()`. + +- `GOOGLE_CLOUD_CPP_DATA_OBJECT_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "vectorsearch.googleapis.com") + used by `MakeDataObjectServiceConnection()`. + +- `GOOGLE_CLOUD_CPP_VECTOR_SEARCH_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "vectorsearch.googleapis.com") + used by `MakeVectorSearchServiceConnection()`. + + + +@see google::cloud::EndpointOption + +@section vectorsearch-env-logging Logging + +`GOOGLE_CLOUD_CPP_ENABLE_TRACING=rpc`: turns on tracing for most gRPC +calls. The library injects an additional Stub decorator that prints each gRPC +request and response. Unless you have configured your own logging backend, +you should also set `GOOGLE_CLOUD_CPP_ENABLE_CLOG` to produce any output on +the program's console. + +@see google::cloud::LoggingComponentsOption + +`GOOGLE_CLOUD_CPP_TRACING_OPTIONS=...`: modifies the behavior of gRPC tracing, +including whether messages will be output on multiple lines, or whether +string/bytes fields will be truncated. + +@see google::cloud::GrpcTracingOptionsOption + +`GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes`: turns on logging in the library, basically +the library always "logs" but the logging infrastructure has no backend to +actually print anything until the application sets a backend or they set this +environment variable. + +@see google::cloud::LogBackend +@see google::cloud::LogSink + +@section vectorsearch-env-project Setting the Default Project + +`GOOGLE_CLOUD_PROJECT=...`: is used in examples and integration tests to +configure the GCP project. This has no effect in the library. + +*/ diff --git a/google/cloud/vectorsearch/doc/main.dox b/google/cloud/vectorsearch/doc/main.dox new file mode 100644 index 0000000000000..720879a12c781 --- /dev/null +++ b/google/cloud/vectorsearch/doc/main.dox @@ -0,0 +1,63 @@ +/*! + +@mainpage Vector Search API C++ Client Library + +An idiomatic C++ client library for the [Vector Search API][cloud-service-docs]. + +The Vector Search API provides a fully-managed, highly performant, and +scalable vector database designed to power next-generation search, +recommendation, and generative AI applications. It allows you to store, +index, and query your data and its corresponding vector embeddings through +a simple, intuitive interface. With Vector Search, you can define custom +schemas for your data, insert objects with associated metadata, +automatically generate embeddings from your data, and perform fast +approximate nearest neighbor (ANN) searches to find semantically similar +items at scale. + +While this library is **GA**, please note that the Google Cloud C++ client libraries do **not** follow +[Semantic Versioning](https://semver.org/). + +@tableofcontents{HTML:2} + +## Quickstart + +The following shows the code that you'll run in the +`google/cloud/vectorsearch/quickstart/` directory, +which should give you a taste of the Vector Search API C++ client library API. + +@snippet quickstart.cc all + +## Main classes + + +This library offers multiple `*Client` classes, which are listed below. Each one +of these classes exposes all the RPCs for a service as member functions of the +class. This library groups multiple services because they are part of the same +product or are often used together. A typical example may be the administrative +and data plane operations for a single product. + +The library also has other classes that provide helpers, configuration +parameters, and infrastructure to mock the `*Client` classes when testing your +application. + +- [\c vectorsearch_v1::DataObjectServiceClient](@ref google::cloud::vectorsearch_v1::DataObjectServiceClient) +- [\c vectorsearch_v1::DataObjectSearchServiceClient](@ref google::cloud::vectorsearch_v1::DataObjectSearchServiceClient) +- [\c vectorsearch_v1::VectorSearchServiceClient](@ref google::cloud::vectorsearch_v1::VectorSearchServiceClient) + + +## More Information + +- @ref common-error-handling - describes how the library reports errors. +- @ref vectorsearch-override-endpoint - describes how to override the default + endpoint. +- @ref vectorsearch-override-authentication - describes how to change the + authentication credentials used by the library. +- @ref vectorsearch-override-retry - describes how to change the default retry + policies. +- @ref vectorsearch-env - describes environment variables that can configure the + behavior of the library. +- @ref vectorsearch-override-universe-domain - describes how to override the default universe domain. + +[cloud-service-docs]: https://docs.cloud.google.com/vertex-ai/docs/vector-search-2/overview + +*/ diff --git a/google/cloud/vectorsearch/doc/options.dox b/google/cloud/vectorsearch/doc/options.dox new file mode 100644 index 0000000000000..08cbecf25afc6 --- /dev/null +++ b/google/cloud/vectorsearch/doc/options.dox @@ -0,0 +1,10 @@ +/*! +@defgroup google-cloud-vectorsearch-options Vector Search API Configuration Options + +This library uses the same mechanism (`google::cloud::Options`) and the common +[options](@ref options) as all other C++ client libraries for its configuration. +Some `*Option` classes, which are only used in this library, are documented in +this page. + +@see @ref options - for an overview of client library configuration. +*/ diff --git a/google/cloud/vectorsearch/doc/override-authentication.dox b/google/cloud/vectorsearch/doc/override-authentication.dox new file mode 100644 index 0000000000000..93fe87dcab1e1 --- /dev/null +++ b/google/cloud/vectorsearch/doc/override-authentication.dox @@ -0,0 +1,53 @@ +/*! +@page vectorsearch-override-authentication How to Override the Authentication Credentials + +Unless otherwise configured, the client libraries use +[Application Default Credentials] to authenticate with Google Cloud Services. +While this works for most applications, in some cases you may need to override +this default. You can do so by providing the +[UnifiedCredentialsOption](@ref google::cloud::UnifiedCredentialsOption) +The following example shows how to explicitly load a service account key file: + + +@snippet data_object_client_samples.cc with-service-account + +Follow these links to find examples for other \c *Client classes: + +- [\c vectorsearch_v1::DataObjectServiceClient](@ref vectorsearch_v1::DataObjectServiceClient-service-account-snippet) +- [\c vectorsearch_v1::DataObjectSearchServiceClient](@ref vectorsearch_v1::DataObjectSearchServiceClient-service-account-snippet) +- [\c vectorsearch_v1::VectorSearchServiceClient](@ref vectorsearch_v1::VectorSearchServiceClient-service-account-snippet) + + + +Keep in mind that we chose this as an example because it is relatively easy to +understand. Consult the [Best practices for managing service account keys] +guide for more details. + +@see @ref guac - for more information on the factory functions to create +`google::cloud::Credentials` objects. + +[Best practices for managing service account keys]: https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys +[Application Default Credentials]: https://cloud.google.com/docs/authentication#adc + +*/ + +// + +/*! @page vectorsearch_v1::DataObjectServiceClient-service-account-snippet Override vectorsearch_v1::DataObjectServiceClient Authentication Defaults + +@snippet google/cloud/vectorsearch/v1/samples/data_object_client_samples.cc with-service-account + +*/ + +/*! @page vectorsearch_v1::DataObjectSearchServiceClient-service-account-snippet Override vectorsearch_v1::DataObjectSearchServiceClient Authentication Defaults + +@snippet google/cloud/vectorsearch/v1/samples/data_object_search_client_samples.cc with-service-account + +*/ + +/*! @page vectorsearch_v1::VectorSearchServiceClient-service-account-snippet Override vectorsearch_v1::VectorSearchServiceClient Authentication Defaults + +@snippet google/cloud/vectorsearch/v1/samples/vector_search_client_samples.cc with-service-account + +*/ +// diff --git a/google/cloud/vectorsearch/doc/override-endpoint.dox b/google/cloud/vectorsearch/doc/override-endpoint.dox new file mode 100644 index 0000000000000..257056cb46a8a --- /dev/null +++ b/google/cloud/vectorsearch/doc/override-endpoint.dox @@ -0,0 +1,43 @@ +/*! +@page vectorsearch-override-endpoint How to Override the Default Endpoint + +In some cases, you may need to override the default endpoint used by the client +library. Use the +[EndpointOption](@ref google::cloud::EndpointOption) when initializing the +client library to change this default. + + +For example, this will override the default endpoint for `vectorsearch_v1::DataObjectServiceClient`: + +@snippet data_object_client_samples.cc set-client-endpoint + +Follow these links to find examples for other \c *Client classes: + +- [\c vectorsearch_v1::DataObjectServiceClient](@ref vectorsearch_v1::DataObjectServiceClient-endpoint-snippet) +- [\c vectorsearch_v1::DataObjectSearchServiceClient](@ref vectorsearch_v1::DataObjectSearchServiceClient-endpoint-snippet) +- [\c vectorsearch_v1::VectorSearchServiceClient](@ref vectorsearch_v1::VectorSearchServiceClient-endpoint-snippet) + + + +*/ + +// + +/*! @page vectorsearch_v1::DataObjectServiceClient-endpoint-snippet Override vectorsearch_v1::DataObjectServiceClient Endpoint Configuration + +@snippet google/cloud/vectorsearch/v1/samples/data_object_client_samples.cc set-client-endpoint + +*/ + +/*! @page vectorsearch_v1::DataObjectSearchServiceClient-endpoint-snippet Override vectorsearch_v1::DataObjectSearchServiceClient Endpoint Configuration + +@snippet google/cloud/vectorsearch/v1/samples/data_object_search_client_samples.cc set-client-endpoint + +*/ + +/*! @page vectorsearch_v1::VectorSearchServiceClient-endpoint-snippet Override vectorsearch_v1::VectorSearchServiceClient Endpoint Configuration + +@snippet google/cloud/vectorsearch/v1/samples/vector_search_client_samples.cc set-client-endpoint + +*/ +// diff --git a/google/cloud/vectorsearch/doc/override-retry-policies.dox b/google/cloud/vectorsearch/doc/override-retry-policies.dox new file mode 100644 index 0000000000000..30b41fd07abf7 --- /dev/null +++ b/google/cloud/vectorsearch/doc/override-retry-policies.dox @@ -0,0 +1,134 @@ +/*! +@page vectorsearch-override-retry Override Retry, Backoff, and Idempotency Policies + +When it is safe to do so, the library automatically retries requests that fail +due to a transient error. The library then uses [exponential backoff] to backoff +before trying again. Which operations are considered safe to retry, which +errors are treated as transient failures, the details of the exponential backoff +algorithm, and for how long the library retries are all configurable via +policies. + +This document provides examples showing how to override the default policies. + +The policies can be set when the `*Connection` object is created. The library +provides default policies for any policy that is not set. The application can +also override some (or all) policies when the `*Client` object is created. This +can be useful if multiple `*Client` objects share the same `*Connection` object, +but you want different retry behavior in some of the clients. Finally, the +application can override some retry policies when calling a specific member +function. + +The library uses three different options to control the retry loop. The options +have per-client names. + +@section vectorsearch-override-retry-retry-policy Configuring the transient errors and retry duration + +The `*RetryPolicyOption` controls: + +- Which errors are to be treated as transient errors. +- How long the library will keep retrying transient errors. + +You can provide your own class for this option. The library also provides two +built-in policies: + +- `*LimitedErrorCountRetryPolicy`: stops retrying after a specified number + of transient errors. +- `*LimitedTimeRetryPolicy`: stops retrying after a specified time. + +Note that a library may have more than one version of these classes. Their name +match the `*Client` and `*Connection` object they are intended to be used +with. Some `*Client` objects treat different error codes as transient errors. +In most cases, only [kUnavailable](@ref google::cloud::StatusCode) is treated +as a transient error. + +@section vectorsearch-override-retry-backoff-policy Controlling the backoff algorithm + +The `*BackoffPolicyOption` controls how long the client library will wait +before retrying a request that failed with a transient error. You can provide +your own class for this option. + +The only built-in backoff policy is +[`ExponentialBackoffPolicy`](@ref google::cloud::ExponentialBackoffPolicy). +This class implements a truncated exponential backoff algorithm, with jitter. +In summary, it doubles the current backoff time after each failure. The actual +backoff time for an RPC is chosen at random, but never exceeds the current +backoff. The current backoff is doubled after each failure, but never exceeds +(or is "truncated") if it reaches a prescribed maximum. + +@section vectorsearch-override-retry-idempotency-policy Controlling which operations are retryable + +The `*IdempotencyPolicyOption` controls which requests are retryable, as some +requests are never safe to retry. + +Only one built-in idempotency policy is provided by the library. The name +matches the name of the client it is intended for. For example, `FooBarClient` +will use `FooBarIdempotencyPolicy`. This policy is very conservative. + +@section vectorsearch-override-retry-example Example + + +For example, this will override the retry policies for `vectorsearch_v1::DataObjectServiceClient`: + +@snippet data_object_client_samples.cc set-retry-policy + +This assumes you have created a custom idempotency policy. Such as: + +@snippet data_object_client_samples.cc custom-idempotency-policy + + +Follow these links to find examples for other \c *Client classes: + +- [\c vectorsearch_v1::DataObjectServiceClient](@ref vectorsearch_v1::DataObjectServiceClient-retry-snippet) +- [\c vectorsearch_v1::DataObjectSearchServiceClient](@ref vectorsearch_v1::DataObjectSearchServiceClient-retry-snippet) +- [\c vectorsearch_v1::VectorSearchServiceClient](@ref vectorsearch_v1::VectorSearchServiceClient-retry-snippet) + + + +@section vectorsearch-override-retry-more-information More Information + +@see google::cloud::Options +@see google::cloud::BackoffPolicy +@see google::cloud::ExponentialBackoffPolicy + +[exponential backoff]: https://en.wikipedia.org/wiki/Exponential_backoff + +*/ + +// + +/*! @page vectorsearch_v1::DataObjectServiceClient-retry-snippet Override vectorsearch_v1::DataObjectServiceClient Retry Policies + +This shows how to override the retry policies for vectorsearch_v1::DataObjectServiceClient: + +@snippet google/cloud/vectorsearch/v1/samples/data_object_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/vectorsearch/v1/samples/data_object_client_samples.cc custom-idempotency-policy + +*/ + +/*! @page vectorsearch_v1::DataObjectSearchServiceClient-retry-snippet Override vectorsearch_v1::DataObjectSearchServiceClient Retry Policies + +This shows how to override the retry policies for vectorsearch_v1::DataObjectSearchServiceClient: + +@snippet google/cloud/vectorsearch/v1/samples/data_object_search_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/vectorsearch/v1/samples/data_object_search_client_samples.cc custom-idempotency-policy + +*/ + +/*! @page vectorsearch_v1::VectorSearchServiceClient-retry-snippet Override vectorsearch_v1::VectorSearchServiceClient Retry Policies + +This shows how to override the retry policies for vectorsearch_v1::VectorSearchServiceClient: + +@snippet google/cloud/vectorsearch/v1/samples/vector_search_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/vectorsearch/v1/samples/vector_search_client_samples.cc custom-idempotency-policy + +*/ +// diff --git a/google/cloud/vectorsearch/doc/override-universe-domain.dox b/google/cloud/vectorsearch/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..b6c032a1cc314 --- /dev/null +++ b/google/cloud/vectorsearch/doc/override-universe-domain.dox @@ -0,0 +1,42 @@ +/*! +@page vectorsearch-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the +client library. Use `AddUniverseDomainOption` when initializing the client +library to change this default. + + +For example, this will override the default universe domain for `vectorsearch_v1::DataObjectServiceClient`: + +@snippet data_object_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c vectorsearch_v1::DataObjectServiceClient](@ref vectorsearch_v1::DataObjectServiceClient-universe-domain-snippet) +- [\c vectorsearch_v1::DataObjectSearchServiceClient](@ref vectorsearch_v1::DataObjectSearchServiceClient-universe-domain-snippet) +- [\c vectorsearch_v1::VectorSearchServiceClient](@ref vectorsearch_v1::VectorSearchServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page vectorsearch_v1::DataObjectServiceClient-universe-domain-snippet Override vectorsearch_v1::DataObjectServiceClient Universe Domain + +@snippet google/cloud/vectorsearch/v1/samples/data_object_client_samples.cc set-client-universe-domain + +*/ + +/*! @page vectorsearch_v1::DataObjectSearchServiceClient-universe-domain-snippet Override vectorsearch_v1::DataObjectSearchServiceClient Universe Domain + +@snippet google/cloud/vectorsearch/v1/samples/data_object_search_client_samples.cc set-client-universe-domain + +*/ + +/*! @page vectorsearch_v1::VectorSearchServiceClient-universe-domain-snippet Override vectorsearch_v1::VectorSearchServiceClient Universe Domain + +@snippet google/cloud/vectorsearch/v1/samples/vector_search_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/vectorsearch/quickstart/.bazelrc b/google/cloud/vectorsearch/quickstart/.bazelrc new file mode 100644 index 0000000000000..c884db46c2b4d --- /dev/null +++ b/google/cloud/vectorsearch/quickstart/.bazelrc @@ -0,0 +1,30 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Use host-OS-specific config lines from bazelrc files. +build --enable_platform_specific_config=true + +# The project requires C++ >= 14. By default Bazel adds `-std=c++0x` which +# disables C++14 features, even if the compilers defaults to C++ >= 14 +build:linux --cxxopt=-std=c++14 +build:macos --cxxopt=-std=c++14 +# Protobuf and gRPC require (or soon will require) C++14 to compile the "host" +# targets, such as protoc and the grpc plugin. +build:linux --host_cxxopt=-std=c++14 +build:macos --host_cxxopt=-std=c++14 + +# Do not create the convenience links. They are inconvenient when the build +# runs inside a docker image or if one builds a quickstart and then builds +# the project separately. +build --experimental_convenience_symlinks=ignore diff --git a/google/cloud/vectorsearch/quickstart/BUILD.bazel b/google/cloud/vectorsearch/quickstart/BUILD.bazel new file mode 100644 index 0000000000000..6ed87c84b25c6 --- /dev/null +++ b/google/cloud/vectorsearch/quickstart/BUILD.bazel @@ -0,0 +1,25 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache 2.0 + +cc_binary( + name = "quickstart", + srcs = [ + "quickstart.cc", + ], + deps = [ + "@google_cloud_cpp//:vectorsearch", + ], +) diff --git a/google/cloud/vectorsearch/quickstart/CMakeLists.txt b/google/cloud/vectorsearch/quickstart/CMakeLists.txt new file mode 100644 index 0000000000000..ec54e5bef567b --- /dev/null +++ b/google/cloud/vectorsearch/quickstart/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +# This file shows how to use the Vector Search API C++ client library from a +# larger CMake project. + +cmake_minimum_required(VERSION 3.22...3.31) +project(google-cloud-cpp-vectorsearch-quickstart CXX) + +find_package(google_cloud_cpp_vectorsearch REQUIRED) + +# MSVC requires some additional code to select the correct runtime library +if (VCPKG_TARGET_TRIPLET MATCHES "-static$") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +else () + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") +endif () + +# Define your targets. +add_executable(quickstart quickstart.cc) +target_link_libraries(quickstart google-cloud-cpp::vectorsearch) diff --git a/google/cloud/vectorsearch/quickstart/Makefile b/google/cloud/vectorsearch/quickstart/Makefile new file mode 100644 index 0000000000000..f5e6e5e5594eb --- /dev/null +++ b/google/cloud/vectorsearch/quickstart/Makefile @@ -0,0 +1,35 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This is a minimal Makefile to show how to use the Vector Search API C++ client +# for developers who use make(1) as their build system. + +# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for +# our tests, but applications would typically make them configurable parameters. +CXX=g++ +CXXFLAGS= +CXXLD=$(CXX) +BIN=. + +all: $(BIN)/quickstart + +# Configuration variables to compile and link against the Vector Search API C++ +# client library. +CLIENT_MODULE := google_cloud_cpp_vectorsearch +CLIENT_CXXFLAGS := $(shell pkg-config $(CLIENT_MODULE) --cflags) +CLIENT_CXXLDFLAGS := $(shell pkg-config $(CLIENT_MODULE) --libs-only-L) +CLIENT_LIBS := $(shell pkg-config $(CLIENT_MODULE) --libs-only-l) + +$(BIN)/quickstart: quickstart.cc + $(CXXLD) $(CXXFLAGS) $(CLIENT_CXXFLAGS) $(CLIENT_CXXLDFLAGS) -o $@ $^ $(CLIENT_LIBS) diff --git a/google/cloud/vectorsearch/quickstart/README.md b/google/cloud/vectorsearch/quickstart/README.md new file mode 100644 index 0000000000000..0b9f3d3b5507b --- /dev/null +++ b/google/cloud/vectorsearch/quickstart/README.md @@ -0,0 +1,135 @@ +# HOWTO: using the Vector Search API C++ client in your project + +This directory contains small examples showing how to use the Vector Search API +C++ client library in your own project. These instructions assume that you have +some experience as a C++ developer and that you have a working C++ toolchain +(compiler, linker, etc.) installed on your platform. + +- Packaging maintainers or developers who prefer to install the library in a + fixed directory (such as `/usr/local` or `/opt`) should consult the + [packaging guide](/doc/packaging.md). +- Developers who prefer using a package manager such as + [vcpkg](https://vcpkg.io), or [Conda](https://conda.io), should follow the + instructions for their package manager. +- Developers wanting to use the libraries as part of a larger CMake or Bazel + project should consult the current document. Note that there are similar + documents for each library in their corresponding directories. +- Developers wanting to compile the library just to run some examples or tests + should consult the + [building and installing](/README.md#building-and-installing) section of the + top-level README file. +- Contributors and developers to `google-cloud-cpp` should consult the guide to + [set up a development workstation][howto-setup-dev-workstation]. + +## Before you begin + +To run the quickstart examples you will need a working Google Cloud Platform +(GCP) project. + +## Configuring authentication for the C++ Client Library + +Like most Google Cloud Platform (GCP) services, Vector Search API requires that +your application authenticates with the service before accessing any data. If +you are not familiar with GCP authentication please take this opportunity to +review the [Authentication methods at Google][authentication-quickstart]. + +## Using with Bazel + +> :warning: If you are using Windows or macOS there are additional instructions +> at the end of this document. + +1. Install Bazel using [the instructions][bazel-install] from the `bazel.build` + website. + +1. Compile this example using Bazel: + + ```bash + cd $HOME/google-cloud-cpp/google/cloud/vectorsearch/quickstart + bazel build ... + ``` + + Note that Bazel automatically downloads and compiles all dependencies of the + project. As it is often the case with C++ libraries, compiling these + dependencies may take several minutes. + +1. Run the example, changing the placeholder(s) to appropriate values: + + ```bash + bazel run :quickstart -- [...] + ``` + +## Using with CMake + +> :warning: If you are using Windows or macOS there are additional instructions +> at the end of this document. + +1. Install CMake. The package managers for most Linux distributions include a + package for CMake. Likewise, you can install CMake on Windows using a package + manager such as [chocolatey][choco-cmake-link], and on macOS using + [homebrew][homebrew-cmake-link]. You can also obtain the software directly + from the [cmake.org](https://cmake.org/download/). + +1. Install the dependencies with your favorite tools. As an example, if you use + [vcpkg](https://github.com/Microsoft/vcpkg.git): + + ```bash + cd $HOME/vcpkg + ./vcpkg install google-cloud-cpp[core,vectorsearch] + ``` + + Note that, as it is often the case with C++ libraries, compiling these + dependencies may take several minutes. + +1. Configure CMake, if necessary, configure the directory where you installed + the dependencies: + + ```bash + cd $HOME/google-cloud-cpp/google/cloud/vectorsearch/quickstart + cmake -S . -B .build -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake --build .build + ``` + +1. Run the example, changing the placeholder(s) to appropriate values: + + ```bash + .build/quickstart [...] + ``` + +## Platform Specific Notes + +### macOS + +gRPC [requires][grpc-roots-pem-bug] an environment variable to configure the +trust store for SSL certificates, you can download and configure this using: + +```bash +curl -Lo roots.pem https://pki.google.com/roots.pem +export GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="$PWD/roots.pem" +``` + +### Windows + +Bazel tends to create very long file names and paths. You may need to use a +short directory to store the build output, such as `c:\b`, and instruct Bazel to +use it via: + +```shell +bazel --output_user_root=c:\b build ... +``` + +gRPC [requires][grpc-roots-pem-bug] an environment variable to configure the +trust store for SSL certificates, you can download and configure this using: + +```console +@powershell -NoProfile -ExecutionPolicy unrestricted -Command ^ + (new-object System.Net.WebClient).Downloadfile( ^ + 'https://pki.google.com/roots.pem', 'roots.pem') +set GRPC_DEFAULT_SSL_ROOTS_FILE_PATH=%cd%\roots.pem +``` + +[authentication-quickstart]: https://cloud.google.com/docs/authentication/client-libraries "Authenticate for using client libraries" +[bazel-install]: https://docs.bazel.build/versions/main/install.html +[choco-cmake-link]: https://chocolatey.org/packages/cmake +[grpc-roots-pem-bug]: https://github.com/grpc/grpc/issues/16571 +[homebrew-cmake-link]: https://formulae.brew.sh/formula/cmake +[howto-setup-dev-workstation]: /doc/contributor/howto-guide-setup-development-workstation.md diff --git a/google/cloud/vectorsearch/quickstart/WORKSPACE.bazel b/google/cloud/vectorsearch/quickstart/WORKSPACE.bazel new file mode 100644 index 0000000000000..81fc87e022c20 --- /dev/null +++ b/google/cloud/vectorsearch/quickstart/WORKSPACE.bazel @@ -0,0 +1,53 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A minimal WORKSPACE file showing how to use the Vector Search API +# C++ client library in Bazel-based projects. +workspace(name = "qs") + +# Add the necessary Starlark functions to fetch google-cloud-cpp. +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +# Fetch the Google Cloud C++ libraries. +# NOTE: Update this version and SHA256 as needed. +http_archive( + name = "google_cloud_cpp", + sha256 = "699955112a4c57ae9111fbadeff1698674a1762acd77daf36360e6dfc227dc93", + strip_prefix = "google-cloud-cpp-2.42.0", + url = "https://github.com/googleapis/google-cloud-cpp/archive/v2.42.0.tar.gz", +) + +load("@google_cloud_cpp//bazel:workspace0.bzl", "gl_cpp_workspace0") + +gl_cpp_workspace0() + +load("@google_cloud_cpp//bazel:workspace1.bzl", "gl_cpp_workspace1") + +gl_cpp_workspace1() + +load("@google_cloud_cpp//bazel:workspace2.bzl", "gl_cpp_workspace2") + +gl_cpp_workspace2() + +load("@google_cloud_cpp//bazel:workspace3.bzl", "gl_cpp_workspace3") + +gl_cpp_workspace3() + +load("@google_cloud_cpp//bazel:workspace4.bzl", "gl_cpp_workspace4") + +gl_cpp_workspace4() + +load("@google_cloud_cpp//bazel:workspace5.bzl", "gl_cpp_workspace5") + +gl_cpp_workspace5() diff --git a/google/cloud/vectorsearch/quickstart/quickstart.cc b/google/cloud/vectorsearch/quickstart/quickstart.cc new file mode 100644 index 0000000000000..5f73af5280f99 --- /dev/null +++ b/google/cloud/vectorsearch/quickstart/quickstart.cc @@ -0,0 +1,42 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! [all] +#include "google/cloud/vectorsearch/v1/vector_search_client.h" +#include "google/cloud/location.h" +#include + +int main(int argc, char* argv[]) try { + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << " project-id location-id\n"; + return 1; + } + + auto const location = google::cloud::Location(argv[1], argv[2]); + + namespace vectorsearch = ::google::cloud::vectorsearch_v1; + auto client = vectorsearch::VectorSearchServiceClient( + vectorsearch::MakeVectorSearchServiceConnection()); + + for (auto r : client.ListCollections(location.FullName())) { + if (!r) throw std::move(r).status(); + std::cout << r->DebugString() << "\n"; + } + + return 0; +} catch (google::cloud::Status const& status) { + std::cerr << "google::cloud::Status thrown: " << status << "\n"; + return 1; +} +//! [all] diff --git a/google/cloud/vectorsearch/v1/.repo-metadata.json b/google/cloud/vectorsearch/v1/.repo-metadata.json new file mode 100644 index 0000000000000..33e5d0489695b --- /dev/null +++ b/google/cloud/vectorsearch/v1/.repo-metadata.json @@ -0,0 +1,14 @@ +{ + "api_id": "vectorsearch.googleapis.com", + "api_shortname": "vectorsearch", + "client_documentation": "https://cloud.google.com/cpp/docs/reference/vectorsearch/latest", + "distribution_name": "google-cloud-cpp", + "issue_tracker": "https://issuetracker.google.com/issues?q=componentid:1899904%20status=open", + "language": "cpp", + "library_type": "GAPIC_AUTO", + "name_pretty": "Vector Search API", + "product_documentation": "https://docs.cloud.google.com/vertex-ai/docs/vector-search-2/overview", + "release_level": "stable", + "repo": "googleapis/google-cloud-cpp", + "requires_billing": true +} diff --git a/google/cloud/vectorsearch/v1/data_object_client.cc b/google/cloud/vectorsearch/v1/data_object_client.cc new file mode 100644 index 0000000000000..67f6b57d09ab7 --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_client.cc @@ -0,0 +1,234 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/data_object_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectServiceClient::DataObjectServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +DataObjectServiceClient::~DataObjectServiceClient() = default; + +StatusOr +DataObjectServiceClient::CreateDataObject( + std::string const& parent, + google::cloud::vectorsearch::v1::DataObject const& data_object, + std::string const& data_object_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::CreateDataObjectRequest request; + request.set_parent(parent); + *request.mutable_data_object() = data_object; + request.set_data_object_id(data_object_id); + return connection_->CreateDataObject(request); +} + +StatusOr +DataObjectServiceClient::CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateDataObject(request); +} + +StatusOr +DataObjectServiceClient::BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->BatchCreateDataObjects(request); +} + +StatusOr +DataObjectServiceClient::GetDataObject(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::GetDataObjectRequest request; + request.set_name(name); + return connection_->GetDataObject(request); +} + +StatusOr +DataObjectServiceClient::GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetDataObject(request); +} + +StatusOr +DataObjectServiceClient::UpdateDataObject( + google::cloud::vectorsearch::v1::DataObject const& data_object, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::UpdateDataObjectRequest request; + *request.mutable_data_object() = data_object; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateDataObject(request); +} + +StatusOr +DataObjectServiceClient::UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateDataObject(request); +} + +StatusOr +DataObjectServiceClient::BatchUpdateDataObjects( + std::string const& parent, + std::vector const& + requests, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest request; + request.set_parent(parent); + *request.mutable_requests() = {requests.begin(), requests.end()}; + return connection_->BatchUpdateDataObjects(request); +} + +StatusOr +DataObjectServiceClient::BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->BatchUpdateDataObjects(request); +} + +Status DataObjectServiceClient::DeleteDataObject(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::DeleteDataObjectRequest request; + request.set_name(name); + return connection_->DeleteDataObject(request); +} + +Status DataObjectServiceClient::DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteDataObject(request); +} + +Status DataObjectServiceClient::BatchDeleteDataObjects( + std::string const& parent, + std::vector const& + requests, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest request; + request.set_parent(parent); + *request.mutable_requests() = {requests.begin(), requests.end()}; + return connection_->BatchDeleteDataObjects(request); +} + +Status DataObjectServiceClient::BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->BatchDeleteDataObjects(request); +} + +StreamRange +DataObjectServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DataObjectServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange +DataObjectServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataObjectServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr DataObjectServiceClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr DataObjectServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataObjectServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataObjectServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataObjectServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataObjectServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/data_object_client.h b/google/cloud/vectorsearch/v1/data_object_client.h new file mode 100644 index 0000000000000..cb052a0a1a05e --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_client.h @@ -0,0 +1,829 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CLIENT_H + +#include "google/cloud/vectorsearch/v1/data_object_connection.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Service for creating and managing data objects. +/// +/// @par Equality +/// +/// Instances of this class created via copy-construction or copy-assignment +/// always compare equal. Instances created with equal +/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare +/// equal share the same underlying resources. +/// +/// @par Performance +/// +/// Creating a new instance of this class is a relatively expensive operation, +/// new objects establish new connections to the service. In contrast, +/// copy-construction, move-construction, and the corresponding assignment +/// operations are relatively efficient as the copies share all underlying +/// resources. +/// +/// @par Thread Safety +/// +/// Concurrent access to different instances of this class, even if they compare +/// equal, is guaranteed to work. Two or more threads operating on the same +/// instance of this class is not guaranteed to work. Since copy-construction +/// and move-construction is a relatively efficient operation, consider using +/// such a copy when using this class from multiple threads. +/// +class DataObjectServiceClient { + public: + explicit DataObjectServiceClient( + std::shared_ptr connection, + Options opts = {}); + ~DataObjectServiceClient(); + + ///@{ + /// @name Copy and move support + DataObjectServiceClient(DataObjectServiceClient const&) = default; + DataObjectServiceClient& operator=(DataObjectServiceClient const&) = default; + DataObjectServiceClient(DataObjectServiceClient&&) = default; + DataObjectServiceClient& operator=(DataObjectServiceClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(DataObjectServiceClient const& a, + DataObjectServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(DataObjectServiceClient const& a, + DataObjectServiceClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Creates a dataObject. + /// + /// @param parent Required. The resource name of the Collection to create the DataObject in. + /// Format: `projects/{project}/locations/{location}/collections/{collection}` + /// @param data_object Required. The DataObject to create. + /// @param data_object_id Required. The id of the dataObject to create. + /// The id must be 1-63 characters long, and comply with + /// [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). + /// Specifically, it must be 1-63 characters long and match the regular + /// expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.DataObject]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.CreateDataObjectRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L108} + /// [google.cloud.vectorsearch.v1.DataObject]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object.proto#L33} + /// + // clang-format on + StatusOr CreateDataObject( + std::string const& parent, + google::cloud::vectorsearch::v1::DataObject const& data_object, + std::string const& data_object_id, Options opts = {}); + + // clang-format off + /// + /// Creates a dataObject. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.CreateDataObjectRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.DataObject]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.CreateDataObjectRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L108} + /// [google.cloud.vectorsearch.v1.DataObject]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object.proto#L33} + /// + // clang-format on + StatusOr CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a batch of dataObjects. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.BatchCreateDataObjectsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.BatchCreateDataObjectsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.BatchCreateDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L131} + /// [google.cloud.vectorsearch.v1.BatchCreateDataObjectsResponse]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L151} + /// + // clang-format on + StatusOr + BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// Gets a data object. + /// + /// @param name Required. The name of the DataObject resource. + /// Format: + /// `projects/{project}/locations/{location}/collections/{collection}/dataObjects/{dataObject}` + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.DataObject]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DataObject]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object.proto#L33} + /// [google.cloud.vectorsearch.v1.GetDataObjectRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L159} + /// + // clang-format on + StatusOr GetDataObject( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets a data object. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.GetDataObjectRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.DataObject]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DataObject]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object.proto#L33} + /// [google.cloud.vectorsearch.v1.GetDataObjectRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L159} + /// + // clang-format on + StatusOr GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates a dataObject. + /// + /// @param data_object Required. The DataObject which replaces the resource on the server. + /// @param update_mask Optional. The update mask applies to the resource. See + /// [google.protobuf.FieldMask][google.protobuf.FieldMask]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.DataObject]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DataObject]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object.proto#L33} + /// [google.cloud.vectorsearch.v1.UpdateDataObjectRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L173} + /// [google.protobuf.FieldMask]: @googleapis_reference_link{google/protobuf/field_mask.proto#L242} + /// + // clang-format on + StatusOr UpdateDataObject( + google::cloud::vectorsearch::v1::DataObject const& data_object, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates a dataObject. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.UpdateDataObjectRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.DataObject]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DataObject]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object.proto#L33} + /// [google.cloud.vectorsearch.v1.UpdateDataObjectRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L173} + /// + // clang-format on + StatusOr UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates dataObjects in a batch. + /// + /// @param parent Required. The resource name of the Collection to update the DataObjects in. + /// Format: `projects/{project}/locations/{location}/collections/{collection}`. + /// The parent field in the UpdateDataObjectRequest messages must match this + /// field. + /// @param requests Required. The request message specifying the resources to update. + /// A maximum of 1000 DataObjects can be updated in a batch. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.BatchUpdateDataObjectsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.BatchUpdateDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L185} + /// [google.cloud.vectorsearch.v1.BatchUpdateDataObjectsResponse]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L205} + /// + // clang-format on + StatusOr + BatchUpdateDataObjects( + std::string const& parent, + std::vector< + google::cloud::vectorsearch::v1::UpdateDataObjectRequest> const& + requests, + Options opts = {}); + + // clang-format off + /// + /// Updates dataObjects in a batch. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.BatchUpdateDataObjectsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.BatchUpdateDataObjectsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.BatchUpdateDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L185} + /// [google.cloud.vectorsearch.v1.BatchUpdateDataObjectsResponse]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L205} + /// + // clang-format on + StatusOr + BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a dataObject. + /// + /// @param name Required. The name of the DataObject resource to be deleted. + /// Format: + /// `projects/{project}/locations/{location}/collections/{collection}/dataObjects/{dataObject}` + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DeleteDataObjectRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L209} + /// + // clang-format on + Status DeleteDataObject(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a dataObject. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.DeleteDataObjectRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DeleteDataObjectRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L209} + /// + // clang-format on + Status DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes dataObjects in a batch. + /// + /// @param parent Required. The resource name of the Collection to delete the DataObjects in. + /// Format: `projects/{project}/locations/{location}/collections/{collection}`. + /// @param requests Required. The request message specifying the resources to delete. + /// A maximum of 1000 DataObjects can be deleted in a batch. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.BatchDeleteDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L228} + /// + // clang-format on + Status BatchDeleteDataObjects( + std::string const& parent, + std::vector< + google::cloud::vectorsearch::v1::DeleteDataObjectRequest> const& + requests, + Options opts = {}); + + // clang-format off + /// + /// Deletes dataObjects in a batch. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.BatchDeleteDataObjectsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.BatchDeleteDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_service.proto#L228} + /// + // clang-format on + Status BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.longrunning.Operation], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L167} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.longrunning.Operation], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L167} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L160} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L160} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L219} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L219} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a + /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + /// `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L212} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L144} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L70} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a + /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + /// `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L212} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L144} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L70} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CLIENT_H diff --git a/google/cloud/vectorsearch/v1/data_object_connection.cc b/google/cloud/vectorsearch/v1/data_object_connection.cc new file mode 100644 index 0000000000000..002bdf4879c92 --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_connection.cc @@ -0,0 +1,140 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/data_object_connection.h" +#include "google/cloud/vectorsearch/v1/data_object_options.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_connection_impl.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_option_defaults.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_stub_factory.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectServiceConnection::~DataObjectServiceConnection() = default; + +StatusOr +DataObjectServiceConnection::CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataObjectServiceConnection::BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataObjectServiceConnection::GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataObjectServiceConnection::UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataObjectServiceConnection::BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataObjectServiceConnection::DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataObjectServiceConnection::BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +DataObjectServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataObjectServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +DataObjectServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataObjectServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataObjectServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataObjectServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr MakeDataObjectServiceConnection( + Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = vectorsearch_v1_internal::DataObjectServiceDefaultOptions( + std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = vectorsearch_v1_internal::CreateDefaultDataObjectServiceStub( + std::move(auth), options); + return vectorsearch_v1_internal::MakeDataObjectServiceTracingConnection( + std::make_shared< + vectorsearch_v1_internal::DataObjectServiceConnectionImpl>( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/data_object_connection.h b/google/cloud/vectorsearch/v1/data_object_connection.h new file mode 100644 index 0000000000000..8da3038216912 --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_connection.h @@ -0,0 +1,266 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/data_object_service.pb.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_retry_traits.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/internal/retry_policy_impl.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `DataObjectServiceConnection`. +class DataObjectServiceRetryPolicy : public ::google::cloud::RetryPolicy { + public: + /// Creates a new instance of the policy, reset to the initial state. + virtual std::unique_ptr clone() const = 0; +}; + +/** + * A retry policy for `DataObjectServiceConnection` based on counting errors. + * + * This policy stops retrying if: + * - An RPC returns a non-transient error. + * - More than a prescribed number of transient failures is detected. + * + * In this class the following status codes are treated as transient errors: + * - [`kUnavailable`](@ref google::cloud::StatusCode) + */ +class DataObjectServiceLimitedErrorCountRetryPolicy + : public DataObjectServiceRetryPolicy { + public: + /** + * Create an instance that tolerates up to @p maximum_failures transient + * errors. + * + * @note Disable the retry loop by providing an instance of this policy with + * @p maximum_failures == 0. + */ + explicit DataObjectServiceLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + DataObjectServiceLimitedErrorCountRetryPolicy( + DataObjectServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : DataObjectServiceLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + DataObjectServiceLimitedErrorCountRetryPolicy( + DataObjectServiceLimitedErrorCountRetryPolicy const& rhs) noexcept + : DataObjectServiceLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + + int maximum_failures() const { return impl_.maximum_failures(); } + + bool OnFailure(Status const& status) override { + return impl_.OnFailure(status); + } + bool IsExhausted() const override { return impl_.IsExhausted(); } + bool IsPermanentFailure(Status const& status) const override { + return impl_.IsPermanentFailure(status); + } + std::unique_ptr clone() const override { + return std::make_unique( + maximum_failures()); + } + + // This is provided only for backwards compatibility. + using BaseType = DataObjectServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + vectorsearch_v1_internal::DataObjectServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `DataObjectServiceConnection` based on elapsed time. + * + * This policy stops retrying if: + * - An RPC returns a non-transient error. + * - The elapsed time in the retry loop exceeds a prescribed duration. + * + * In this class the following status codes are treated as transient errors: + * - [`kUnavailable`](@ref google::cloud::StatusCode) + */ +class DataObjectServiceLimitedTimeRetryPolicy + : public DataObjectServiceRetryPolicy { + public: + /** + * Constructor given a `std::chrono::duration<>` object. + * + * @tparam DurationRep a placeholder to match the `Rep` tparam for @p + * duration's type. The semantics of this template parameter are + * documented in `std::chrono::duration<>`. In brief, the underlying + * arithmetic type used to store the number of ticks. For our purposes it + * is simply a formal parameter. + * @tparam DurationPeriod a placeholder to match the `Period` tparam for @p + * duration's type. The semantics of this template parameter are + * documented in `std::chrono::duration<>`. In brief, the length of the + * tick in seconds, expressed as a `std::ratio<>`. For our purposes it is + * simply a formal parameter. + * @param maximum_duration the maximum time allowed before the policy expires. + * While the application can express this time in any units they desire, + * the class truncates to milliseconds. + * + * @see https://en.cppreference.com/w/cpp/chrono/duration for more information + * about `std::chrono::duration`. + */ + template + explicit DataObjectServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + DataObjectServiceLimitedTimeRetryPolicy( + DataObjectServiceLimitedTimeRetryPolicy&& rhs) noexcept + : DataObjectServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + DataObjectServiceLimitedTimeRetryPolicy( + DataObjectServiceLimitedTimeRetryPolicy const& rhs) noexcept + : DataObjectServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + + std::chrono::milliseconds maximum_duration() const { + return impl_.maximum_duration(); + } + + bool OnFailure(Status const& status) override { + return impl_.OnFailure(status); + } + bool IsExhausted() const override { return impl_.IsExhausted(); } + bool IsPermanentFailure(Status const& status) const override { + return impl_.IsPermanentFailure(status); + } + std::unique_ptr clone() const override { + return std::make_unique( + maximum_duration()); + } + + // This is provided only for backwards compatibility. + using BaseType = DataObjectServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + vectorsearch_v1_internal::DataObjectServiceRetryTraits> + impl_; +}; + +/** + * The `DataObjectServiceConnection` object for `DataObjectServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `DataObjectServiceClient`. This allows users to inject custom + * behavior (e.g., with a Google Mock object) when writing tests that use + * objects of type `DataObjectServiceClient`. + * + * To create a concrete instance, see `MakeDataObjectServiceConnection()`. + * + * For mocking, see `vectorsearch_v1_mocks::MockDataObjectServiceConnection`. + */ +class DataObjectServiceConnection { + public: + virtual ~DataObjectServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StatusOr + CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request); + + virtual StatusOr< + google::cloud::vectorsearch::v1::BatchCreateDataObjectsResponse> + BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request); + + virtual StatusOr GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request); + + virtual StatusOr + UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request); + + virtual StatusOr< + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsResponse> + BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request); + + virtual Status DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request); + + virtual Status BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); +}; + +/** + * A factory function to construct an object of type + * `DataObjectServiceConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of + * DataObjectServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `DataObjectServiceConnection`. Expected options are any of the types + * in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::vectorsearch_v1::DataObjectServicePolicyOptionList` + * + * @note Unexpected options will be ignored. To log unexpected options instead, + * set `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment. + * + * @param options (optional) Configure the `DataObjectServiceConnection` created + * by this function. + */ +std::shared_ptr MakeDataObjectServiceConnection( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.cc b/google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..1f633597c3965 --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.cc @@ -0,0 +1,113 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +DataObjectServiceConnectionIdempotencyPolicy:: + ~DataObjectServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +DataObjectServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +DataObjectServiceConnectionIdempotencyPolicy::BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +DataObjectServiceConnectionIdempotencyPolicy::BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +DataObjectServiceConnectionIdempotencyPolicy::BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataObjectServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultDataObjectServiceConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.h b/google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.h new file mode 100644 index 0000000000000..12ecda5507d4c --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.h @@ -0,0 +1,93 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/data_object_service.grpc.pb.h" +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectServiceConnectionIdempotencyPolicy { + public: + virtual ~DataObjectServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() + const; + + virtual google::cloud::Idempotency CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request); + + virtual google::cloud::Idempotency BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request); + + virtual google::cloud::Idempotency GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request); + + virtual google::cloud::Idempotency UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request); + + virtual google::cloud::Idempotency BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request); + + virtual google::cloud::Idempotency DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request); + + virtual google::cloud::Idempotency BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); +}; + +std::unique_ptr +MakeDefaultDataObjectServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/vectorsearch/v1/data_object_options.h b/google/cloud/vectorsearch/v1/data_object_options.h new file mode 100644 index 0000000000000..4ad34569ad8f7 --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_options.h @@ -0,0 +1,76 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_OPTIONS_H + +#include "google/cloud/vectorsearch/v1/data_object_connection.h" +#include "google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct DataObjectServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct DataObjectServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct DataObjectServiceConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to DataObjectService. + * + * @ingroup google-cloud-vectorsearch-options + */ +using DataObjectServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_OPTIONS_H diff --git a/google/cloud/vectorsearch/v1/data_object_search_client.cc b/google/cloud/vectorsearch/v1/data_object_search_client.cc new file mode 100644 index 0000000000000..74f1ee52c0155 --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_search_client.cc @@ -0,0 +1,147 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/data_object_search_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectSearchServiceClient::DataObjectSearchServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +DataObjectSearchServiceClient::~DataObjectSearchServiceClient() = default; + +StreamRange +DataObjectSearchServiceClient::SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SearchDataObjects(std::move(request)); +} + +StreamRange +DataObjectSearchServiceClient::QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->QueryDataObjects(std::move(request)); +} + +StatusOr +DataObjectSearchServiceClient::AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->AggregateDataObjects(request); +} + +StatusOr +DataObjectSearchServiceClient::BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->BatchSearchDataObjects(request); +} + +StreamRange +DataObjectSearchServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DataObjectSearchServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange +DataObjectSearchServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +DataObjectSearchServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +DataObjectSearchServiceClient::GetOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +DataObjectSearchServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status DataObjectSearchServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status DataObjectSearchServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status DataObjectSearchServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status DataObjectSearchServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/data_object_search_client.h b/google/cloud/vectorsearch/v1/data_object_search_client.h new file mode 100644 index 0000000000000..b04957358563a --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_search_client.h @@ -0,0 +1,584 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CLIENT_H + +#include "google/cloud/vectorsearch/v1/data_object_search_connection.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Service for searching data objects. +/// +/// @par Equality +/// +/// Instances of this class created via copy-construction or copy-assignment +/// always compare equal. Instances created with equal +/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare +/// equal share the same underlying resources. +/// +/// @par Performance +/// +/// Creating a new instance of this class is a relatively expensive operation, +/// new objects establish new connections to the service. In contrast, +/// copy-construction, move-construction, and the corresponding assignment +/// operations are relatively efficient as the copies share all underlying +/// resources. +/// +/// @par Thread Safety +/// +/// Concurrent access to different instances of this class, even if they compare +/// equal, is guaranteed to work. Two or more threads operating on the same +/// instance of this class is not guaranteed to work. Since copy-construction +/// and move-construction is a relatively efficient operation, consider using +/// such a copy when using this class from multiple threads. +/// +class DataObjectSearchServiceClient { + public: + explicit DataObjectSearchServiceClient( + std::shared_ptr connection, + Options opts = {}); + ~DataObjectSearchServiceClient(); + + ///@{ + /// @name Copy and move support + DataObjectSearchServiceClient(DataObjectSearchServiceClient const&) = default; + DataObjectSearchServiceClient& operator=( + DataObjectSearchServiceClient const&) = default; + DataObjectSearchServiceClient(DataObjectSearchServiceClient&&) = default; + DataObjectSearchServiceClient& operator=(DataObjectSearchServiceClient&&) = + default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(DataObjectSearchServiceClient const& a, + DataObjectSearchServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(DataObjectSearchServiceClient const& a, + DataObjectSearchServiceClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Searches data objects. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.SearchDataObjectsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.vectorsearch.v1.SearchResult], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.SearchDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_search_service.proto#L246} + /// [google.cloud.vectorsearch.v1.SearchResult]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_search_service.proto#L283} + /// + // clang-format on + StreamRange SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Queries data objects. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.QueryDataObjectsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.vectorsearch.v1.DataObject], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DataObject]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object.proto#L33} + /// [google.cloud.vectorsearch.v1.QueryDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_search_service.proto#L333} + /// + // clang-format on + StreamRange QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Aggregates data objects. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.AggregateDataObjectsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.AggregateDataObjectsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.AggregateDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_search_service.proto#L305} + /// [google.cloud.vectorsearch.v1.AggregateDataObjectsResponse]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_search_service.proto#L325} + /// + // clang-format on + StatusOr + AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// Batch searches data objects. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.BatchSearchDataObjectsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.BatchSearchDataObjectsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.BatchSearchDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_search_service.proto#L377} + /// [google.cloud.vectorsearch.v1.BatchSearchDataObjectsResponse]: @googleapis_reference_link{google/cloud/vectorsearch/v1/data_object_search_service.proto#L444} + /// + // clang-format on + StatusOr + BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.longrunning.Operation], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L167} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.longrunning.Operation], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L167} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L160} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L160} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L219} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L219} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a + /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + /// `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L212} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L144} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L70} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a + /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + /// `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L212} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L144} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L70} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CLIENT_H diff --git a/google/cloud/vectorsearch/v1/data_object_search_connection.cc b/google/cloud/vectorsearch/v1/data_object_search_connection.cc new file mode 100644 index 0000000000000..b8d3aee11b7cb --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_search_connection.cc @@ -0,0 +1,130 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/data_object_search_connection.h" +#include "google/cloud/vectorsearch/v1/data_object_search_options.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectSearchServiceConnection::~DataObjectSearchServiceConnection() = + default; + +StreamRange +DataObjectSearchServiceConnection::SearchDataObjects( + google::cloud::vectorsearch::v1:: + SearchDataObjectsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StreamRange +DataObjectSearchServiceConnection::QueryDataObjects( + google::cloud::vectorsearch::v1:: + QueryDataObjectsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataObjectSearchServiceConnection::AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataObjectSearchServiceConnection::BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +DataObjectSearchServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataObjectSearchServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +DataObjectSearchServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataObjectSearchServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataObjectSearchServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status DataObjectSearchServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr +MakeDataObjectSearchServiceConnection(Options options) { + internal::CheckExpectedOptions( + options, __func__); + options = vectorsearch_v1_internal::DataObjectSearchServiceDefaultOptions( + std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = + vectorsearch_v1_internal::CreateDefaultDataObjectSearchServiceStub( + std::move(auth), options); + return vectorsearch_v1_internal::MakeDataObjectSearchServiceTracingConnection( + std::make_shared< + vectorsearch_v1_internal::DataObjectSearchServiceConnectionImpl>( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/data_object_search_connection.h b/google/cloud/vectorsearch/v1/data_object_search_connection.h new file mode 100644 index 0000000000000..04376bb9f909d --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_search_connection.h @@ -0,0 +1,263 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/data_object_search_service.pb.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_retry_traits.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/internal/retry_policy_impl.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `DataObjectSearchServiceConnection`. +class DataObjectSearchServiceRetryPolicy : public ::google::cloud::RetryPolicy { + public: + /// Creates a new instance of the policy, reset to the initial state. + virtual std::unique_ptr clone() const = 0; +}; + +/** + * A retry policy for `DataObjectSearchServiceConnection` based on counting + * errors. + * + * This policy stops retrying if: + * - An RPC returns a non-transient error. + * - More than a prescribed number of transient failures is detected. + * + * In this class the following status codes are treated as transient errors: + * - [`kUnavailable`](@ref google::cloud::StatusCode) + */ +class DataObjectSearchServiceLimitedErrorCountRetryPolicy + : public DataObjectSearchServiceRetryPolicy { + public: + /** + * Create an instance that tolerates up to @p maximum_failures transient + * errors. + * + * @note Disable the retry loop by providing an instance of this policy with + * @p maximum_failures == 0. + */ + explicit DataObjectSearchServiceLimitedErrorCountRetryPolicy( + int maximum_failures) + : impl_(maximum_failures) {} + + DataObjectSearchServiceLimitedErrorCountRetryPolicy( + DataObjectSearchServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : DataObjectSearchServiceLimitedErrorCountRetryPolicy( + rhs.maximum_failures()) {} + DataObjectSearchServiceLimitedErrorCountRetryPolicy( + DataObjectSearchServiceLimitedErrorCountRetryPolicy const& rhs) noexcept + : DataObjectSearchServiceLimitedErrorCountRetryPolicy( + rhs.maximum_failures()) {} + + int maximum_failures() const { return impl_.maximum_failures(); } + + bool OnFailure(Status const& status) override { + return impl_.OnFailure(status); + } + bool IsExhausted() const override { return impl_.IsExhausted(); } + bool IsPermanentFailure(Status const& status) const override { + return impl_.IsPermanentFailure(status); + } + std::unique_ptr clone() const override { + return std::make_unique< + DataObjectSearchServiceLimitedErrorCountRetryPolicy>( + maximum_failures()); + } + + // This is provided only for backwards compatibility. + using BaseType = DataObjectSearchServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + vectorsearch_v1_internal::DataObjectSearchServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `DataObjectSearchServiceConnection` based on elapsed time. + * + * This policy stops retrying if: + * - An RPC returns a non-transient error. + * - The elapsed time in the retry loop exceeds a prescribed duration. + * + * In this class the following status codes are treated as transient errors: + * - [`kUnavailable`](@ref google::cloud::StatusCode) + */ +class DataObjectSearchServiceLimitedTimeRetryPolicy + : public DataObjectSearchServiceRetryPolicy { + public: + /** + * Constructor given a `std::chrono::duration<>` object. + * + * @tparam DurationRep a placeholder to match the `Rep` tparam for @p + * duration's type. The semantics of this template parameter are + * documented in `std::chrono::duration<>`. In brief, the underlying + * arithmetic type used to store the number of ticks. For our purposes it + * is simply a formal parameter. + * @tparam DurationPeriod a placeholder to match the `Period` tparam for @p + * duration's type. The semantics of this template parameter are + * documented in `std::chrono::duration<>`. In brief, the length of the + * tick in seconds, expressed as a `std::ratio<>`. For our purposes it is + * simply a formal parameter. + * @param maximum_duration the maximum time allowed before the policy expires. + * While the application can express this time in any units they desire, + * the class truncates to milliseconds. + * + * @see https://en.cppreference.com/w/cpp/chrono/duration for more information + * about `std::chrono::duration`. + */ + template + explicit DataObjectSearchServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + DataObjectSearchServiceLimitedTimeRetryPolicy( + DataObjectSearchServiceLimitedTimeRetryPolicy&& rhs) noexcept + : DataObjectSearchServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + DataObjectSearchServiceLimitedTimeRetryPolicy( + DataObjectSearchServiceLimitedTimeRetryPolicy const& rhs) noexcept + : DataObjectSearchServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + + std::chrono::milliseconds maximum_duration() const { + return impl_.maximum_duration(); + } + + bool OnFailure(Status const& status) override { + return impl_.OnFailure(status); + } + bool IsExhausted() const override { return impl_.IsExhausted(); } + bool IsPermanentFailure(Status const& status) const override { + return impl_.IsPermanentFailure(status); + } + std::unique_ptr clone() const override { + return std::make_unique( + maximum_duration()); + } + + // This is provided only for backwards compatibility. + using BaseType = DataObjectSearchServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + vectorsearch_v1_internal::DataObjectSearchServiceRetryTraits> + impl_; +}; + +/** + * The `DataObjectSearchServiceConnection` object for + * `DataObjectSearchServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `DataObjectSearchServiceClient`. This allows users to inject custom + * behavior (e.g., with a Google Mock object) when writing tests that use + * objects of type `DataObjectSearchServiceClient`. + * + * To create a concrete instance, see `MakeDataObjectSearchServiceConnection()`. + * + * For mocking, see + * `vectorsearch_v1_mocks::MockDataObjectSearchServiceConnection`. + */ +class DataObjectSearchServiceConnection { + public: + virtual ~DataObjectSearchServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StreamRange + SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest request); + + virtual StreamRange + QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest request); + + virtual StatusOr< + google::cloud::vectorsearch::v1::AggregateDataObjectsResponse> + AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request); + + virtual StatusOr< + google::cloud::vectorsearch::v1::BatchSearchDataObjectsResponse> + BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); +}; + +/** + * A factory function to construct an object of type + * `DataObjectSearchServiceConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of + * DataObjectSearchServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `DataObjectSearchServiceConnection`. Expected options are any of the + * types in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::vectorsearch_v1::DataObjectSearchServicePolicyOptionList` + * + * @note Unexpected options will be ignored. To log unexpected options instead, + * set `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment. + * + * @param options (optional) Configure the `DataObjectSearchServiceConnection` + * created by this function. + */ +std::shared_ptr +MakeDataObjectSearchServiceConnection(Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.cc b/google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..81150b576e81e --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.cc @@ -0,0 +1,100 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +DataObjectSearchServiceConnectionIdempotencyPolicy:: + ~DataObjectSearchServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +DataObjectSearchServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique( + *this); +} + +Idempotency +DataObjectSearchServiceConnectionIdempotencyPolicy::SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest) { // NOLINT + return Idempotency::kNonIdempotent; +} + +Idempotency +DataObjectSearchServiceConnectionIdempotencyPolicy::QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest) { // NOLINT + return Idempotency::kNonIdempotent; +} + +Idempotency +DataObjectSearchServiceConnectionIdempotencyPolicy::AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency +DataObjectSearchServiceConnectionIdempotencyPolicy::BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataObjectSearchServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataObjectSearchServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataObjectSearchServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataObjectSearchServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataObjectSearchServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency DataObjectSearchServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultDataObjectSearchServiceConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.h b/google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.h new file mode 100644 index 0000000000000..f585f01718766 --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.h @@ -0,0 +1,83 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/data_object_search_service.grpc.pb.h" +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectSearchServiceConnectionIdempotencyPolicy { + public: + virtual ~DataObjectSearchServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr + clone() const; + + virtual google::cloud::Idempotency SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest request); + + virtual google::cloud::Idempotency QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest request); + + virtual google::cloud::Idempotency AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request); + + virtual google::cloud::Idempotency BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); +}; + +std::unique_ptr +MakeDefaultDataObjectSearchServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/vectorsearch/v1/data_object_search_options.h b/google/cloud/vectorsearch/v1/data_object_search_options.h new file mode 100644 index 0000000000000..45b7396c778d0 --- /dev/null +++ b/google/cloud/vectorsearch/v1/data_object_search_options.h @@ -0,0 +1,77 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_OPTIONS_H + +#include "google/cloud/vectorsearch/v1/data_object_search_connection.h" +#include "google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct DataObjectSearchServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct DataObjectSearchServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct DataObjectSearchServiceConnectionIdempotencyPolicyOption { + using Type = + std::shared_ptr; +}; + +/** + * The options applicable to DataObjectSearchService. + * + * @ingroup google-cloud-vectorsearch-options + */ +using DataObjectSearchServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_DATA_OBJECT_SEARCH_OPTIONS_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.cc b/google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.cc new file mode 100644 index 0000000000000..a6013fef9797a --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.cc @@ -0,0 +1,156 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.h" +#include "google/cloud/vectorsearch/v1/data_object_service.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectServiceAuth::DataObjectServiceAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr +DataObjectServiceAuth::CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateDataObject(context, options, request); +} + +StatusOr +DataObjectServiceAuth::BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->BatchCreateDataObjects(context, options, request); +} + +StatusOr +DataObjectServiceAuth::GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetDataObject(context, options, request); +} + +StatusOr +DataObjectServiceAuth::UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateDataObject(context, options, request); +} + +StatusOr +DataObjectServiceAuth::BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->BatchUpdateDataObjects(context, options, request); +} + +Status DataObjectServiceAuth::DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteDataObject(context, options, request); +} + +Status DataObjectServiceAuth::BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->BatchDeleteDataObjects(context, options, request); +} + +StatusOr +DataObjectServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DataObjectServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr +DataObjectServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr DataObjectServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataObjectServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataObjectServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.h b/google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.h new file mode 100644 index 0000000000000..c757a59224d7e --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.h @@ -0,0 +1,117 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_AUTH_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/version.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectServiceAuth : public DataObjectServiceStub { + public: + ~DataObjectServiceAuth() override = default; + DataObjectServiceAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) + override; + + StatusOr + BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) override; + + StatusOr GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) + override; + + StatusOr UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) + override; + + StatusOr + BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) override; + + Status DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) + override; + + Status BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr auth_; + std::shared_ptr child_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_AUTH_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_connection_impl.cc b/google/cloud/vectorsearch/v1/internal/data_object_connection_impl.cc new file mode 100644 index 0000000000000..d339120f63e26 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_connection_impl.cc @@ -0,0 +1,298 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_connection_impl.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_option_defaults.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/retry_loop.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN +namespace { + +std::unique_ptr retry_policy( + Options const& options) { + return options.get() + ->clone(); +} + +std::unique_ptr backoff_policy(Options const& options) { + return options.get() + ->clone(); +} + +std::unique_ptr +idempotency_policy(Options const& options) { + return options + .get< + vectorsearch_v1::DataObjectServiceConnectionIdempotencyPolicyOption>() + ->clone(); +} + +} // namespace + +DataObjectServiceConnectionImpl::DataObjectServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions( + std::move(options), DataObjectServiceConnection::options())) {} + +StatusOr +DataObjectServiceConnectionImpl::CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateDataObject(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& + request) { + return stub_->CreateDataObject(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataObjectServiceConnectionImpl::BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->BatchCreateDataObjects(request), + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + return stub_->BatchCreateDataObjects(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataObjectServiceConnectionImpl::GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetDataObject(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& + request) { + return stub_->GetDataObject(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataObjectServiceConnectionImpl::UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateDataObject(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& + request) { + return stub_->UpdateDataObject(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataObjectServiceConnectionImpl::BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->BatchUpdateDataObjects(request), + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + return stub_->BatchUpdateDataObjects(context, options, request); + }, + *current, request, __func__); +} + +Status DataObjectServiceConnectionImpl::DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteDataObject(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& + request) { + return stub_->DeleteDataObject(context, options, request); + }, + *current, request, __func__); +} + +Status DataObjectServiceConnectionImpl::BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->BatchDeleteDataObjects(request), + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + return stub_->BatchDeleteDataObjects(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +DataObjectServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataObjectServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +DataObjectServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataObjectServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataObjectServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataObjectServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/data_object_connection_impl.h b/google/cloud/vectorsearch/v1/internal/data_object_connection_impl.h new file mode 100644 index 0000000000000..02df83bc5b2ef --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_connection_impl.h @@ -0,0 +1,111 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_CONNECTION_IMPL_H + +#include "google/cloud/vectorsearch/v1/data_object_connection.h" +#include "google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/data_object_options.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_retry_traits.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectServiceConnectionImpl + : public vectorsearch_v1::DataObjectServiceConnection { + public: + ~DataObjectServiceConnectionImpl() override = default; + + DataObjectServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options); + + Options options() override { return options_; } + + StatusOr CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) + override; + + StatusOr + BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) override; + + StatusOr GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) + override; + + StatusOr UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) + override; + + StatusOr + BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) override; + + Status DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) + override; + + Status BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) override; + + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_CONNECTION_IMPL_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.cc b/google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.cc new file mode 100644 index 0000000000000..af8c2aaa13788 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.cc @@ -0,0 +1,210 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.h" +#include "google/cloud/vectorsearch/v1/data_object_service.grpc.pb.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectServiceLogging::DataObjectServiceLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +StatusOr +DataObjectServiceLogging::CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& + request) { + return child_->CreateDataObject(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectServiceLogging::BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + return child_->BatchCreateDataObjects(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectServiceLogging::GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& + request) { + return child_->GetDataObject(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectServiceLogging::UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& + request) { + return child_->UpdateDataObject(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectServiceLogging::BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + return child_->BatchUpdateDataObjects(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataObjectServiceLogging::DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& + request) { + return child_->DeleteDataObject(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataObjectServiceLogging::BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + return child_->BatchDeleteDataObjects(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataObjectServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataObjectServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataObjectServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.h b/google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.h new file mode 100644 index 0000000000000..72c6ae64d6f0c --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.h @@ -0,0 +1,117 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_LOGGING_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectServiceLogging : public DataObjectServiceStub { + public: + ~DataObjectServiceLogging() override = default; + DataObjectServiceLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const& components); + + StatusOr CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) + override; + + StatusOr + BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) override; + + StatusOr GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) + override; + + StatusOr UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) + override; + + StatusOr + BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) override; + + Status DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) + override; + + Status BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; + TracingOptions tracing_options_; +}; // DataObjectServiceLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_LOGGING_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.cc b/google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.cc new file mode 100644 index 0000000000000..e2d9bce0b4c81 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.cc @@ -0,0 +1,186 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.h" +#include "google/cloud/vectorsearch/v1/data_object_service.grpc.pb.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/internal/url_encode.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectServiceMetadata::DataObjectServiceMetadata( + std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header) + : child_(std::move(child)), + fixed_metadata_(std::move(fixed_metadata)), + api_client_header_( + api_client_header.empty() + ? google::cloud::internal::GeneratedLibClientHeader() + : std::move(api_client_header)) {} + +StatusOr +DataObjectServiceMetadata::CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateDataObject(context, options, request); +} + +StatusOr +DataObjectServiceMetadata::BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->BatchCreateDataObjects(context, options, request); +} + +StatusOr +DataObjectServiceMetadata::GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetDataObject(context, options, request); +} + +StatusOr +DataObjectServiceMetadata::UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) { + SetMetadata(context, options, + absl::StrCat("data_object.name=", + internal::UrlEncode(request.data_object().name()))); + return child_->UpdateDataObject(context, options, request); +} + +StatusOr +DataObjectServiceMetadata::BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->BatchUpdateDataObjects(context, options, request); +} + +Status DataObjectServiceMetadata::DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteDataObject(context, options, request); +} + +Status DataObjectServiceMetadata::BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->BatchDeleteDataObjects(context, options, request); +} + +StatusOr +DataObjectServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataObjectServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +DataObjectServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +DataObjectServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataObjectServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataObjectServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +void DataObjectServiceMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void DataObjectServiceMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options) { + google::cloud::internal::SetMetadata(context, options, fixed_metadata_, + api_client_header_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.h b/google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.h new file mode 100644 index 0000000000000..65804aab12477 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.h @@ -0,0 +1,123 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_METADATA_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectServiceMetadata : public DataObjectServiceStub { + public: + ~DataObjectServiceMetadata() override = default; + DataObjectServiceMetadata( + std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + StatusOr CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) + override; + + StatusOr + BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) override; + + StatusOr GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) + override; + + StatusOr UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) + override; + + StatusOr + BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) override; + + Status DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) + override; + + Status BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + void SetMetadata(grpc::ClientContext& context, Options const& options, + std::string const& request_params); + void SetMetadata(grpc::ClientContext& context, Options const& options); + + std::shared_ptr child_; + std::multimap fixed_metadata_; + std::string api_client_header_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_METADATA_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_option_defaults.cc b/google/cloud/vectorsearch/v1/internal/data_object_option_defaults.cc new file mode 100644 index 0000000000000..75bd4391d396f --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_option_defaults.cc @@ -0,0 +1,69 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_option_defaults.h" +#include "google/cloud/vectorsearch/v1/data_object_connection.h" +#include "google/cloud/vectorsearch/v1/data_object_options.h" +#include "google/cloud/internal/populate_common_options.h" +#include "google/cloud/internal/populate_grpc_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options DataObjectServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_DATA_OBJECT_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_DATA_OBJECT_SERVICE_AUTHORITY", + "vectorsearch.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + vectorsearch_v1::DataObjectServiceLimitedTimeRetryPolicy( + std::chrono::minutes(10)) + .clone()); + } + if (!options.has()) { + options.set( + ExponentialBackoffPolicy( + std::chrono::seconds(0), std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling, kBackoffScaling) + .clone()); + } + if (!options.has()) { + options.set< + vectorsearch_v1::DataObjectServiceConnectionIdempotencyPolicyOption>( + vectorsearch_v1:: + MakeDefaultDataObjectServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/data_object_option_defaults.h b/google/cloud/vectorsearch/v1/internal/data_object_option_defaults.h new file mode 100644 index 0000000000000..b572a074358f2 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options DataObjectServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_OPTION_DEFAULTS_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_retry_traits.h b/google/cloud/vectorsearch/v1/internal/data_object_retry_traits.h new file mode 100644 index 0000000000000..9e05e87806660 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct DataObjectServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_RETRY_TRAITS_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.cc new file mode 100644 index 0000000000000..fc7b32de06907 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.cc @@ -0,0 +1,132 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.h" +#include "google/cloud/vectorsearch/v1/data_object_search_service.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectSearchServiceAuth::DataObjectSearchServiceAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr +DataObjectSearchServiceAuth::SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SearchDataObjects(context, options, request); +} + +StatusOr +DataObjectSearchServiceAuth::QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->QueryDataObjects(context, options, request); +} + +StatusOr +DataObjectSearchServiceAuth::AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->AggregateDataObjects(context, options, request); +} + +StatusOr +DataObjectSearchServiceAuth::BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->BatchSearchDataObjects(context, options, request); +} + +StatusOr +DataObjectSearchServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +DataObjectSearchServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr +DataObjectSearchServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr +DataObjectSearchServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status DataObjectSearchServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status DataObjectSearchServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.h b/google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.h new file mode 100644 index 0000000000000..8b2b1701a921d --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.h @@ -0,0 +1,104 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_AUTH_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/version.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectSearchServiceAuth : public DataObjectSearchServiceStub { + public: + ~DataObjectSearchServiceAuth() override = default; + DataObjectSearchServiceAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr + SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) + override; + + StatusOr + QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) + override; + + StatusOr + AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) override; + + StatusOr + BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr auth_; + std::shared_ptr child_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_AUTH_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.cc new file mode 100644 index 0000000000000..1cd9f4f721cfc --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.cc @@ -0,0 +1,299 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/retry_loop.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN +namespace { + +std::unique_ptr +retry_policy(Options const& options) { + return options + .get() + ->clone(); +} + +std::unique_ptr backoff_policy(Options const& options) { + return options + .get() + ->clone(); +} + +std::unique_ptr< + vectorsearch_v1::DataObjectSearchServiceConnectionIdempotencyPolicy> +idempotency_policy(Options const& options) { + return options + .get() + ->clone(); +} + +} // namespace + +DataObjectSearchServiceConnectionImpl::DataObjectSearchServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions( + std::move(options), DataObjectSearchServiceConnection::options())) {} + +StreamRange +DataObjectSearchServiceConnectionImpl::SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->SearchDataObjects(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& + request) { + return stub->SearchDataObjects(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::vectorsearch::v1::SearchDataObjectsResponse r) { + std::vector result( + r.results().size()); + auto& messages = *r.mutable_results(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StreamRange +DataObjectSearchServiceConnectionImpl::QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->QueryDataObjects(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& + request) { + return stub->QueryDataObjects(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::vectorsearch::v1::QueryDataObjectsResponse r) { + std::vector result( + r.data_objects().size()); + auto& messages = *r.mutable_data_objects(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataObjectSearchServiceConnectionImpl::AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->AggregateDataObjects(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + return stub_->AggregateDataObjects(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataObjectSearchServiceConnectionImpl::BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->BatchSearchDataObjects(request), + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + return stub_->BatchSearchDataObjects(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +DataObjectSearchServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataObjectSearchServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +DataObjectSearchServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataObjectSearchServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataObjectSearchServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status DataObjectSearchServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.h b/google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.h new file mode 100644 index 0000000000000..526d24f579253 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.h @@ -0,0 +1,100 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_CONNECTION_IMPL_H + +#include "google/cloud/vectorsearch/v1/data_object_search_connection.h" +#include "google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/data_object_search_options.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_retry_traits.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectSearchServiceConnectionImpl + : public vectorsearch_v1::DataObjectSearchServiceConnection { + public: + ~DataObjectSearchServiceConnectionImpl() override = default; + + DataObjectSearchServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr + stub, + Options options); + + Options options() override { return options_; } + + StreamRange SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest request) + override; + + StreamRange QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest request) + override; + + StatusOr + AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) override; + + StatusOr + BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) override; + + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_CONNECTION_IMPL_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.cc new file mode 100644 index 0000000000000..9b5757f5d0453 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.cc @@ -0,0 +1,171 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.h" +#include "google/cloud/vectorsearch/v1/data_object_search_service.grpc.pb.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectSearchServiceLogging::DataObjectSearchServiceLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +StatusOr +DataObjectSearchServiceLogging::SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& + request) { + return child_->SearchDataObjects(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectSearchServiceLogging::QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& + request) { + return child_->QueryDataObjects(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectSearchServiceLogging::AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + return child_->AggregateDataObjects(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectSearchServiceLogging::BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + return child_->BatchSearchDataObjects(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectSearchServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectSearchServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectSearchServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataObjectSearchServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataObjectSearchServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status DataObjectSearchServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.h b/google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.h new file mode 100644 index 0000000000000..a1ded9d89c1ad --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.h @@ -0,0 +1,104 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_LOGGING_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectSearchServiceLogging : public DataObjectSearchServiceStub { + public: + ~DataObjectSearchServiceLogging() override = default; + DataObjectSearchServiceLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set const& components); + + StatusOr + SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) + override; + + StatusOr + QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) + override; + + StatusOr + AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) override; + + StatusOr + BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; + TracingOptions tracing_options_; +}; // DataObjectSearchServiceLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_LOGGING_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.cc new file mode 100644 index 0000000000000..ddf530ccd2e26 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.cc @@ -0,0 +1,159 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.h" +#include "google/cloud/vectorsearch/v1/data_object_search_service.grpc.pb.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/internal/url_encode.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectSearchServiceMetadata::DataObjectSearchServiceMetadata( + std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header) + : child_(std::move(child)), + fixed_metadata_(std::move(fixed_metadata)), + api_client_header_( + api_client_header.empty() + ? google::cloud::internal::GeneratedLibClientHeader() + : std::move(api_client_header)) {} + +StatusOr +DataObjectSearchServiceMetadata::SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->SearchDataObjects(context, options, request); +} + +StatusOr +DataObjectSearchServiceMetadata::QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->QueryDataObjects(context, options, request); +} + +StatusOr +DataObjectSearchServiceMetadata::AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AggregateDataObjects(context, options, request); +} + +StatusOr +DataObjectSearchServiceMetadata::BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->BatchSearchDataObjects(context, options, request); +} + +StatusOr +DataObjectSearchServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataObjectSearchServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +DataObjectSearchServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +DataObjectSearchServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status DataObjectSearchServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status DataObjectSearchServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +void DataObjectSearchServiceMetadata::SetMetadata( + grpc::ClientContext& context, Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void DataObjectSearchServiceMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options) { + google::cloud::internal::SetMetadata(context, options, fixed_metadata_, + api_client_header_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.h b/google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.h new file mode 100644 index 0000000000000..d3479fc8fb846 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.h @@ -0,0 +1,110 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_METADATA_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectSearchServiceMetadata : public DataObjectSearchServiceStub { + public: + ~DataObjectSearchServiceMetadata() override = default; + DataObjectSearchServiceMetadata( + std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + StatusOr + SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) + override; + + StatusOr + QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) + override; + + StatusOr + AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) override; + + StatusOr + BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + void SetMetadata(grpc::ClientContext& context, Options const& options, + std::string const& request_params); + void SetMetadata(grpc::ClientContext& context, Options const& options); + + std::shared_ptr child_; + std::multimap fixed_metadata_; + std::string api_client_header_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_METADATA_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.cc new file mode 100644 index 0000000000000..8277d6220fcad --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.cc @@ -0,0 +1,73 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.h" +#include "google/cloud/vectorsearch/v1/data_object_search_connection.h" +#include "google/cloud/vectorsearch/v1/data_object_search_options.h" +#include "google/cloud/internal/populate_common_options.h" +#include "google/cloud/internal/populate_grpc_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options DataObjectSearchServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), + "GOOGLE_CLOUD_CPP_DATA_OBJECT_SEARCH_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_DATA_OBJECT_SEARCH_SERVICE_AUTHORITY", + "vectorsearch.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options + .has()) { + options.set( + vectorsearch_v1::DataObjectSearchServiceLimitedTimeRetryPolicy( + std::chrono::minutes(10)) + .clone()); + } + if (!options.has< + vectorsearch_v1::DataObjectSearchServiceBackoffPolicyOption>()) { + options.set( + ExponentialBackoffPolicy( + std::chrono::seconds(0), std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling, kBackoffScaling) + .clone()); + } + if (!options.has< + vectorsearch_v1:: + DataObjectSearchServiceConnectionIdempotencyPolicyOption>()) { + options.set( + vectorsearch_v1:: + MakeDefaultDataObjectSearchServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.h b/google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.h new file mode 100644 index 0000000000000..61cea05cf1e3f --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options DataObjectSearchServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_OPTION_DEFAULTS_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_retry_traits.h b/google/cloud/vectorsearch/v1/internal/data_object_search_retry_traits.h new file mode 100644 index 0000000000000..6b5510db938c1 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct DataObjectSearchServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_RETRY_TRAITS_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_sources.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_sources.cc new file mode 100644 index 0000000000000..47d4f522b0748 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_sources.cc @@ -0,0 +1,32 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/vectorsearch/v1/data_object_search_client.cc" +#include "google/cloud/vectorsearch/v1/data_object_search_connection.cc" +#include "google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_connection_impl.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_option_defaults.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_stub.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_stub.cc new file mode 100644 index 0000000000000..9de0a5d71df46 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_stub.cc @@ -0,0 +1,162 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.h" +#include "google/cloud/vectorsearch/v1/data_object_search_service.grpc.pb.h" +#include "google/cloud/grpc_error_delegate.h" +#include "google/cloud/status_or.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectSearchServiceStub::~DataObjectSearchServiceStub() = default; + +StatusOr +DefaultDataObjectSearchServiceStub::SearchDataObjects( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) { + google::cloud::vectorsearch::v1::SearchDataObjectsResponse response; + auto status = grpc_stub_->SearchDataObjects(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectSearchServiceStub::QueryDataObjects( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) { + google::cloud::vectorsearch::v1::QueryDataObjectsResponse response; + auto status = grpc_stub_->QueryDataObjects(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectSearchServiceStub::AggregateDataObjects( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + google::cloud::vectorsearch::v1::AggregateDataObjectsResponse response; + auto status = grpc_stub_->AggregateDataObjects(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectSearchServiceStub::BatchSearchDataObjects( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + google::cloud::vectorsearch::v1::BatchSearchDataObjectsResponse response; + auto status = + grpc_stub_->BatchSearchDataObjects(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectSearchServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectSearchServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectSearchServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectSearchServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataObjectSearchServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataObjectSearchServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_stub.h b/google/cloud/vectorsearch/v1/internal/data_object_search_stub.h new file mode 100644 index 0000000000000..cb338f41bd8c7 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_stub.h @@ -0,0 +1,174 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_STUB_H + +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/data_object_search_service.grpc.pb.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectSearchServiceStub { + public: + virtual ~DataObjectSearchServiceStub() = 0; + + virtual StatusOr + SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& + request) = 0; + + virtual StatusOr + QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& + request) = 0; + + virtual StatusOr< + google::cloud::vectorsearch::v1::AggregateDataObjectsResponse> + AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) = 0; + + virtual StatusOr< + google::cloud::vectorsearch::v1::BatchSearchDataObjectsResponse> + BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; +}; + +class DefaultDataObjectSearchServiceStub : public DataObjectSearchServiceStub { + public: + explicit DefaultDataObjectSearchServiceStub( + std::unique_ptr + grpc_stub, + std::unique_ptr + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} + + StatusOr + SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) + override; + + StatusOr + QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) + override; + + StatusOr + AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) override; + + StatusOr + BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::unique_ptr< + google::cloud::vectorsearch::v1::DataObjectSearchService::StubInterface> + grpc_stub_; + std::unique_ptr + operations_stub_; + std::unique_ptr + locations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_STUB_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.cc new file mode 100644 index 0000000000000..8078d4825f7a5 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.cc @@ -0,0 +1,86 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.h" +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/data_object_search_service.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_auth_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_logging_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_metadata_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +CreateDefaultDataObjectSearchServiceStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::vectorsearch::v1::DataObjectSearchService::NewStub( + channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = + std::make_shared( + std::move(service_grpc_stub), std::move(service_operations_stub), + std::move(service_locations_stub)); + + if (auth->RequiresConfigureContext()) { + stub = std::make_shared(std::move(auth), + std::move(stub)); + } + stub = std::make_shared( + std::move(stub), std::multimap{}); + if (internal::Contains(options.get(), "rpc")) { + GCP_LOG(INFO) << "Enabled logging for gRPC calls"; + stub = std::make_shared( + std::move(stub), options.get(), + options.get()); + } + if (internal::TracingEnabled(options)) { + stub = MakeDataObjectSearchServiceTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.h b/google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.h new file mode 100644 index 0000000000000..db54d15dd7a6f --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_stub_factory.h @@ -0,0 +1,48 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_STUB_FACTORY_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +CreateDefaultDataObjectSearchServiceStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_STUB_FACTORY_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.cc new file mode 100644 index 0000000000000..ce0dd27d152ea --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.cc @@ -0,0 +1,151 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectSearchServiceTracingConnection:: + DataObjectSearchServiceTracingConnection( + std::shared_ptr + child) + : child_(std::move(child)) {} + +StreamRange +DataObjectSearchServiceTracingConnection::SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::SearchDataObjects"); + internal::OTelScope scope(span); + auto sr = child_->SearchDataObjects(std::move(request)); + return internal::MakeTracedStreamRange< + google::cloud::vectorsearch::v1::SearchResult>(std::move(span), + std::move(sr)); +} + +StreamRange +DataObjectSearchServiceTracingConnection::QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::QueryDataObjects"); + internal::OTelScope scope(span); + auto sr = child_->QueryDataObjects(std::move(request)); + return internal::MakeTracedStreamRange< + google::cloud::vectorsearch::v1::DataObject>(std::move(span), + std::move(sr)); +} + +StatusOr +DataObjectSearchServiceTracingConnection::AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::" + "AggregateDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->AggregateDataObjects(request)); +} + +StatusOr +DataObjectSearchServiceTracingConnection::BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::" + "BatchSearchDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->BatchSearchDataObjects(request)); +} + +StreamRange +DataObjectSearchServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataObjectSearchServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +DataObjectSearchServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataObjectSearchServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataObjectSearchServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataObjectSearchServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectSearchServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr +MakeDataObjectSearchServiceTracingConnection( + std::shared_ptr conn) { + if (internal::TracingEnabled(conn->options())) { + conn = std::make_shared( + std::move(conn)); + } + return conn; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.h b/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.h new file mode 100644 index 0000000000000..5a2df6477a956 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_connection.h @@ -0,0 +1,97 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_TRACING_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/data_object_search_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectSearchServiceTracingConnection + : public vectorsearch_v1::DataObjectSearchServiceConnection { + public: + ~DataObjectSearchServiceTracingConnection() override = default; + + explicit DataObjectSearchServiceTracingConnection( + std::shared_ptr + child); + + Options options() override { return child_->options(); } + + StreamRange SearchDataObjects( + google::cloud::vectorsearch::v1::SearchDataObjectsRequest request) + override; + + StreamRange QueryDataObjects( + google::cloud::vectorsearch::v1::QueryDataObjectsRequest request) + override; + + StatusOr + AggregateDataObjects( + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) override; + + StatusOr + BatchSearchDataObjects( + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) override; + + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; +}; + +/** + * Conditionally applies the tracing decorator to the given connection. + * + * The connection is only decorated if tracing is enabled (as determined by the + * connection's options). + */ +std::shared_ptr +MakeDataObjectSearchServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_TRACING_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.cc b/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.cc new file mode 100644 index 0000000000000..f3e7e4034af42 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.cc @@ -0,0 +1,174 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.h" +#include "google/cloud/internal/grpc_opentelemetry.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectSearchServiceTracingStub::DataObjectSearchServiceTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +StatusOr +DataObjectSearchServiceTracingStub::SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", + "SearchDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->SearchDataObjects(context, options, request)); +} + +StatusOr +DataObjectSearchServiceTracingStub::QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", + "QueryDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->QueryDataObjects(context, options, request)); +} + +StatusOr +DataObjectSearchServiceTracingStub::AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", + "AggregateDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->AggregateDataObjects(context, options, request)); +} + +StatusOr +DataObjectSearchServiceTracingStub::BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", + "BatchSearchDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->BatchSearchDataObjects(context, options, request)); +} + +StatusOr +DataObjectSearchServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataObjectSearchServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +DataObjectSearchServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataObjectSearchServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataObjectSearchServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataObjectSearchServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectSearchService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +std::shared_ptr +MakeDataObjectSearchServiceTracingStub( + std::shared_ptr stub) { + return std::make_shared(std::move(stub)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.h b/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.h new file mode 100644 index 0000000000000..7a2800087753b --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_search_tracing_stub.h @@ -0,0 +1,114 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_TRACING_STUB_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_search_stub.h" +#include "google/cloud/internal/trace_propagator.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectSearchServiceTracingStub : public DataObjectSearchServiceStub { + public: + ~DataObjectSearchServiceTracingStub() override = default; + + explicit DataObjectSearchServiceTracingStub( + std::shared_ptr child); + + StatusOr + SearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::SearchDataObjectsRequest const& request) + override; + + StatusOr + QueryDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::QueryDataObjectsRequest const& request) + override; + + StatusOr + AggregateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request) override; + + StatusOr + BatchSearchDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; + std::shared_ptr + propagator_; +}; + +/** + * Applies the tracing decorator to the given stub. + * + * The stub is only decorated if the library has been compiled with + * OpenTelemetry. + */ +std::shared_ptr +MakeDataObjectSearchServiceTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_SEARCH_TRACING_STUB_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_sources.cc b/google/cloud/vectorsearch/v1/internal/data_object_sources.cc new file mode 100644 index 0000000000000..c2fda11619c39 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_sources.cc @@ -0,0 +1,32 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/vectorsearch/v1/data_object_client.cc" +#include "google/cloud/vectorsearch/v1/data_object_connection.cc" +#include "google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_connection_impl.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_option_defaults.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_stub_factory.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.cc" +#include "google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/vectorsearch/v1/internal/data_object_stub.cc b/google/cloud/vectorsearch/v1/internal/data_object_stub.cc new file mode 100644 index 0000000000000..9c5308161e4cc --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_stub.cc @@ -0,0 +1,199 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.h" +#include "google/cloud/vectorsearch/v1/data_object_service.grpc.pb.h" +#include "google/cloud/grpc_error_delegate.h" +#include "google/cloud/status_or.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectServiceStub::~DataObjectServiceStub() = default; + +StatusOr +DefaultDataObjectServiceStub::CreateDataObject( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) { + google::cloud::vectorsearch::v1::DataObject response; + auto status = grpc_stub_->CreateDataObject(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectServiceStub::BatchCreateDataObjects( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + google::cloud::vectorsearch::v1::BatchCreateDataObjectsResponse response; + auto status = + grpc_stub_->BatchCreateDataObjects(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectServiceStub::GetDataObject( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) { + google::cloud::vectorsearch::v1::DataObject response; + auto status = grpc_stub_->GetDataObject(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectServiceStub::UpdateDataObject( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) { + google::cloud::vectorsearch::v1::DataObject response; + auto status = grpc_stub_->UpdateDataObject(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectServiceStub::BatchUpdateDataObjects( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsResponse response; + auto status = + grpc_stub_->BatchUpdateDataObjects(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataObjectServiceStub::DeleteDataObject( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteDataObject(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataObjectServiceStub::BatchDeleteDataObjects( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + google::protobuf::Empty response; + auto status = + grpc_stub_->BatchDeleteDataObjects(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultDataObjectServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataObjectServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultDataObjectServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultDataObjectServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_stub.h b/google/cloud/vectorsearch/v1/internal/data_object_stub.h new file mode 100644 index 0000000000000..a395372e6f57d --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_stub.h @@ -0,0 +1,201 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_STUB_H + +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/data_object_service.grpc.pb.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectServiceStub { + public: + virtual ~DataObjectServiceStub() = 0; + + virtual StatusOr + CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& + request) = 0; + + virtual StatusOr< + google::cloud::vectorsearch::v1::BatchCreateDataObjectsResponse> + BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) = 0; + + virtual StatusOr GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) = 0; + + virtual StatusOr + UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& + request) = 0; + + virtual StatusOr< + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsResponse> + BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) = 0; + + virtual Status DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& + request) = 0; + + virtual Status BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; +}; + +class DefaultDataObjectServiceStub : public DataObjectServiceStub { + public: + explicit DefaultDataObjectServiceStub( + std::unique_ptr< + google::cloud::vectorsearch::v1::DataObjectService::StubInterface> + grpc_stub, + std::unique_ptr + operations_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)), + locations_stub_(std::move(locations_stub)) {} + + StatusOr CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) + override; + + StatusOr + BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) override; + + StatusOr GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) + override; + + StatusOr UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) + override; + + StatusOr + BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) override; + + Status DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) + override; + + Status BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::unique_ptr< + google::cloud::vectorsearch::v1::DataObjectService::StubInterface> + grpc_stub_; + std::unique_ptr + operations_stub_; + std::unique_ptr + locations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_STUB_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_stub_factory.cc b/google/cloud/vectorsearch/v1/internal/data_object_stub_factory.cc new file mode 100644 index 0000000000000..86c019d018fba --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_stub_factory.cc @@ -0,0 +1,84 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_stub_factory.h" +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/data_object_service.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_auth_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_logging_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_metadata_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.h" +#include "google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultDataObjectServiceStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::vectorsearch::v1::DataObjectService::NewStub(channel); + auto service_operations_stub = + google::longrunning::Operations::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = + std::make_shared( + std::move(service_grpc_stub), std::move(service_operations_stub), + std::move(service_locations_stub)); + + if (auth->RequiresConfigureContext()) { + stub = std::make_shared(std::move(auth), + std::move(stub)); + } + stub = std::make_shared( + std::move(stub), std::multimap{}); + if (internal::Contains(options.get(), "rpc")) { + GCP_LOG(INFO) << "Enabled logging for gRPC calls"; + stub = std::make_shared( + std::move(stub), options.get(), + options.get()); + } + if (internal::TracingEnabled(options)) { + stub = MakeDataObjectServiceTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_stub_factory.h b/google/cloud/vectorsearch/v1/internal/data_object_stub_factory.h new file mode 100644 index 0000000000000..0a076ad074f5c --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_stub_factory.h @@ -0,0 +1,47 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_STUB_FACTORY_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultDataObjectServiceStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_STUB_FACTORY_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.cc b/google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.cc new file mode 100644 index 0000000000000..4403de7f4ae73 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.cc @@ -0,0 +1,167 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectServiceTracingConnection::DataObjectServiceTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StatusOr +DataObjectServiceTracingConnection::CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::CreateDataObject"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateDataObject(request)); +} + +StatusOr +DataObjectServiceTracingConnection::BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::BatchCreateDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->BatchCreateDataObjects(request)); +} + +StatusOr +DataObjectServiceTracingConnection::GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::GetDataObject"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetDataObject(request)); +} + +StatusOr +DataObjectServiceTracingConnection::UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::UpdateDataObject"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateDataObject(request)); +} + +StatusOr +DataObjectServiceTracingConnection::BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::BatchUpdateDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->BatchUpdateDataObjects(request)); +} + +Status DataObjectServiceTracingConnection::DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::DeleteDataObject"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteDataObject(request)); +} + +Status DataObjectServiceTracingConnection::BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::BatchDeleteDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->BatchDeleteDataObjects(request)); +} + +StreamRange +DataObjectServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataObjectServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +DataObjectServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataObjectServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status DataObjectServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status DataObjectServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::DataObjectServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr +MakeDataObjectServiceTracingConnection( + std::shared_ptr conn) { + if (internal::TracingEnabled(conn->options())) { + conn = + std::make_shared(std::move(conn)); + } + return conn; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.h b/google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.h new file mode 100644 index 0000000000000..6af0969c8b1f7 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_tracing_connection.h @@ -0,0 +1,108 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_TRACING_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/data_object_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectServiceTracingConnection + : public vectorsearch_v1::DataObjectServiceConnection { + public: + ~DataObjectServiceTracingConnection() override = default; + + explicit DataObjectServiceTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StatusOr CreateDataObject( + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) + override; + + StatusOr + BatchCreateDataObjects( + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) override; + + StatusOr GetDataObject( + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) + override; + + StatusOr UpdateDataObject( + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) + override; + + StatusOr + BatchUpdateDataObjects( + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) override; + + Status DeleteDataObject( + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) + override; + + Status BatchDeleteDataObjects( + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) override; + + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; +}; + +/** + * Conditionally applies the tracing decorator to the given connection. + * + * The connection is only decorated if tracing is enabled (as determined by the + * connection's options). + */ +std::shared_ptr +MakeDataObjectServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_TRACING_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.cc b/google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.cc new file mode 100644 index 0000000000000..2417a29128f82 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.cc @@ -0,0 +1,207 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.h" +#include "google/cloud/internal/grpc_opentelemetry.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DataObjectServiceTracingStub::DataObjectServiceTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +StatusOr +DataObjectServiceTracingStub::CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "CreateDataObject"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateDataObject(context, options, request)); +} + +StatusOr +DataObjectServiceTracingStub::BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.cloud.vectorsearch.v1.DataObjectService", + "BatchCreateDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->BatchCreateDataObjects(context, options, request)); +} + +StatusOr +DataObjectServiceTracingStub::GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "GetDataObject"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetDataObject(context, options, request)); +} + +StatusOr +DataObjectServiceTracingStub::UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "UpdateDataObject"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateDataObject(context, options, request)); +} + +StatusOr +DataObjectServiceTracingStub::BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.cloud.vectorsearch.v1.DataObjectService", + "BatchUpdateDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->BatchUpdateDataObjects(context, options, request)); +} + +Status DataObjectServiceTracingStub::DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "DeleteDataObject"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteDataObject(context, options, request)); +} + +Status DataObjectServiceTracingStub::BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.cloud.vectorsearch.v1.DataObjectService", + "BatchDeleteDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->BatchDeleteDataObjects(context, options, request)); +} + +StatusOr +DataObjectServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataObjectServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +DataObjectServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +DataObjectServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status DataObjectServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status DataObjectServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.DataObjectService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +std::shared_ptr MakeDataObjectServiceTracingStub( + std::shared_ptr stub) { + return std::make_shared(std::move(stub)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.h b/google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.h new file mode 100644 index 0000000000000..03a17af733f24 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/data_object_tracing_stub.h @@ -0,0 +1,126 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_TRACING_STUB_H + +#include "google/cloud/vectorsearch/v1/internal/data_object_stub.h" +#include "google/cloud/internal/trace_propagator.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class DataObjectServiceTracingStub : public DataObjectServiceStub { + public: + ~DataObjectServiceTracingStub() override = default; + + explicit DataObjectServiceTracingStub( + std::shared_ptr child); + + StatusOr CreateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request) + override; + + StatusOr + BatchCreateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request) override; + + StatusOr GetDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetDataObjectRequest const& request) + override; + + StatusOr UpdateDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request) + override; + + StatusOr + BatchUpdateDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request) override; + + Status DeleteDataObject( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request) + override; + + Status BatchDeleteDataObjects( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; + std::shared_ptr + propagator_; +}; + +/** + * Applies the tracing decorator to the given stub. + * + * The stub is only decorated if the library has been compiled with + * OpenTelemetry. + */ +std::shared_ptr MakeDataObjectServiceTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_DATA_OBJECT_TRACING_STUB_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.cc b/google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.cc new file mode 100644 index 0000000000000..c280fc019c45c --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.cc @@ -0,0 +1,337 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.h" +#include "google/cloud/vectorsearch/v1/vectorsearch_service.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +VectorSearchServiceAuth::VectorSearchServiceAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr +VectorSearchServiceAuth::ListCollections( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListCollections(context, options, request); +} + +StatusOr +VectorSearchServiceAuth::GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetCollection(context, options, request); +} + +future> +VectorSearchServiceAuth::AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + using ReturnType = StatusOr; + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) { + return make_ready_future(ReturnType(std::move(context).status())); + } + return child->AsyncCreateCollection(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr +VectorSearchServiceAuth::CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateCollection(context, options, request); +} + +future> +VectorSearchServiceAuth::AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + using ReturnType = StatusOr; + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) { + return make_ready_future(ReturnType(std::move(context).status())); + } + return child->AsyncUpdateCollection(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr +VectorSearchServiceAuth::UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateCollection(context, options, request); +} + +future> +VectorSearchServiceAuth::AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + using ReturnType = StatusOr; + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) { + return make_ready_future(ReturnType(std::move(context).status())); + } + return child->AsyncDeleteCollection(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr +VectorSearchServiceAuth::DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteCollection(context, options, request); +} + +StatusOr +VectorSearchServiceAuth::ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListIndexes(context, options, request); +} + +StatusOr +VectorSearchServiceAuth::GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIndex(context, options, request); +} + +future> +VectorSearchServiceAuth::AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + using ReturnType = StatusOr; + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) { + return make_ready_future(ReturnType(std::move(context).status())); + } + return child->AsyncCreateIndex(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr VectorSearchServiceAuth::CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateIndex(context, options, request); +} + +future> +VectorSearchServiceAuth::AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + using ReturnType = StatusOr; + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) { + return make_ready_future(ReturnType(std::move(context).status())); + } + return child->AsyncDeleteIndex(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr VectorSearchServiceAuth::DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteIndex(context, options, request); +} + +future> +VectorSearchServiceAuth::AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + using ReturnType = StatusOr; + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) { + return make_ready_future(ReturnType(std::move(context).status())); + } + return child->AsyncImportDataObjects(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr +VectorSearchServiceAuth::ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ImportDataObjects(context, options, request); +} + +StatusOr +VectorSearchServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +VectorSearchServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr +VectorSearchServiceAuth::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOperations(context, options, request); +} + +StatusOr VectorSearchServiceAuth::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetOperation(context, options, request); +} + +Status VectorSearchServiceAuth::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteOperation(context, options, request); +} + +Status VectorSearchServiceAuth::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CancelOperation(context, options, request); +} + +future> +VectorSearchServiceAuth::AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + using ReturnType = StatusOr; + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) { + return make_ready_future(ReturnType(std::move(context).status())); + } + return child->AsyncGetOperation(cq, *std::move(context), + std::move(options), request); + }); +} + +future VectorSearchServiceAuth::AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) return make_ready_future(std::move(context).status()); + return child->AsyncCancelOperation(cq, *std::move(context), + std::move(options), request); + }); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.h b/google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.h new file mode 100644 index 0000000000000..246d777a48cbe --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.h @@ -0,0 +1,184 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_AUTH_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class VectorSearchServiceAuth : public VectorSearchServiceStub { + public: + ~VectorSearchServiceAuth() override = default; + VectorSearchServiceAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr + ListCollections(grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& + request) override; + + StatusOr GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) + override; + + future> AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + StatusOr CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + future> AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + StatusOr UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + future> AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) + override; + + StatusOr GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) override; + + future> AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + StatusOr CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + future> AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + StatusOr DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + future> AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr auth_; + std::shared_ptr child_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_AUTH_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.cc b/google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.cc new file mode 100644 index 0000000000000..acbe1eb5526e7 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.cc @@ -0,0 +1,849 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/async_long_running_operation.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/retry_loop.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN +namespace { + +std::unique_ptr retry_policy( + Options const& options) { + return options.get() + ->clone(); +} + +std::unique_ptr backoff_policy(Options const& options) { + return options.get() + ->clone(); +} + +std::unique_ptr +idempotency_policy(Options const& options) { + return options + .get() + ->clone(); +} + +std::unique_ptr polling_policy(Options const& options) { + return options.get() + ->clone(); +} + +} // namespace + +VectorSearchServiceConnectionImpl::VectorSearchServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions( + std::move(options), VectorSearchServiceConnection::options())) {} + +StreamRange +VectorSearchServiceConnectionImpl::ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListCollections(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& + request) { + return stub->ListCollections(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::vectorsearch::v1::ListCollectionsResponse r) { + std::vector result( + r.collections().size()); + auto& messages = *r.mutable_collections(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VectorSearchServiceConnectionImpl::GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetCollection(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& + request) { + return stub_->GetCollection(context, options, request); + }, + *current, request, __func__); +} + +future> +VectorSearchServiceConnectionImpl::CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->CreateCollection(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::vectorsearch::v1::Collection>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& + request) { + return stub->AsyncCreateCollection(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::vectorsearch::v1::Collection>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +VectorSearchServiceConnectionImpl::CreateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateCollection(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& + request) { + return stub_->CreateCollection(context, options, request); + }, + *current, request, __func__); +} + +future> +VectorSearchServiceConnectionImpl::CreateCollection( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future< + StatusOr>( + internal::InvalidArgumentError( + "operation does not correspond to CreateCollection", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::vectorsearch::v1::Collection>( + background_->cq(), current, operation, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::vectorsearch::v1::Collection>, + polling_policy(*current), __func__); +} + +future> +VectorSearchServiceConnectionImpl::UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->UpdateCollection(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::vectorsearch::v1::Collection>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& + request) { + return stub->AsyncUpdateCollection(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::vectorsearch::v1::Collection>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +VectorSearchServiceConnectionImpl::UpdateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateCollection(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& + request) { + return stub_->UpdateCollection(context, options, request); + }, + *current, request, __func__); +} + +future> +VectorSearchServiceConnectionImpl::UpdateCollection( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future< + StatusOr>( + internal::InvalidArgumentError( + "operation does not correspond to UpdateCollection", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::vectorsearch::v1::Collection>( + background_->cq(), current, operation, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::vectorsearch::v1::Collection>, + polling_policy(*current), __func__); +} + +future> +VectorSearchServiceConnectionImpl::DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->DeleteCollection(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::vectorsearch::v1::OperationMetadata>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& + request) { + return stub->AsyncDeleteCollection(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultMetadata< + google::cloud::vectorsearch::v1::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +VectorSearchServiceConnectionImpl::DeleteCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteCollection(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& + request) { + return stub_->DeleteCollection(context, options, request); + }, + *current, request, __func__); +} + +future> +VectorSearchServiceConnectionImpl::DeleteCollection( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future< + StatusOr>( + internal::InvalidArgumentError( + "operation does not correspond to DeleteCollection", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::vectorsearch::v1::OperationMetadata>( + background_->cq(), current, operation, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultMetadata< + google::cloud::vectorsearch::v1::OperationMetadata>, + polling_policy(*current), __func__); +} + +StreamRange +VectorSearchServiceConnectionImpl::ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListIndexes(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& + request) { + return stub->ListIndexes(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::vectorsearch::v1::ListIndexesResponse r) { + std::vector result( + r.indexes().size()); + auto& messages = *r.mutable_indexes(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VectorSearchServiceConnectionImpl::GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIndex(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + return stub_->GetIndex(context, options, request); + }, + *current, request, __func__); +} + +future> +VectorSearchServiceConnectionImpl::CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->CreateIndex(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::vectorsearch::v1::Index>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + return stub->AsyncCreateIndex(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::vectorsearch::v1::Index>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +VectorSearchServiceConnectionImpl::CreateIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateIndex(request), + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + return stub_->CreateIndex(context, options, request); + }, + *current, request, __func__); +} + +future> +VectorSearchServiceConnectionImpl::CreateIndex( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to CreateIndex", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::vectorsearch::v1::Index>( + background_->cq(), current, operation, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::vectorsearch::v1::Index>, + polling_policy(*current), __func__); +} + +future> +VectorSearchServiceConnectionImpl::DeleteIndex( + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->DeleteIndex(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::vectorsearch::v1::OperationMetadata>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + return stub->AsyncDeleteIndex(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultMetadata< + google::cloud::vectorsearch::v1::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +VectorSearchServiceConnectionImpl::DeleteIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteIndex(request), + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + return stub_->DeleteIndex(context, options, request); + }, + *current, request, __func__); +} + +future> +VectorSearchServiceConnectionImpl::DeleteIndex( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future< + StatusOr>( + internal::InvalidArgumentError( + "operation does not correspond to DeleteIndex", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::vectorsearch::v1::OperationMetadata>( + background_->cq(), current, operation, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultMetadata< + google::cloud::vectorsearch::v1::OperationMetadata>, + polling_policy(*current), __func__); +} + +future> +VectorSearchServiceConnectionImpl::ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->ImportDataObjects(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::vectorsearch::v1::ImportDataObjectsResponse>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request) { + return stub->AsyncImportDataObjects(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::vectorsearch::v1::ImportDataObjectsResponse>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +VectorSearchServiceConnectionImpl::ImportDataObjects( + NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->ImportDataObjects(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request) { + return stub_->ImportDataObjects(context, options, request); + }, + *current, request, __func__); +} + +future> +VectorSearchServiceConnectionImpl::ImportDataObjects( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future< + StatusOr>( + internal::InvalidArgumentError( + "operation does not correspond to ImportDataObjects", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::vectorsearch::v1::ImportDataObjectsResponse>( + background_->cq(), current, operation, + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::vectorsearch::v1::ImportDataObjectsResponse>, + polling_policy(*current), __func__); +} + +StreamRange +VectorSearchServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VectorSearchServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +VectorSearchServiceConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VectorSearchServiceConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VectorSearchServiceConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(context, options, request); + }, + *current, request, __func__); +} + +Status VectorSearchServiceConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(context, options, request); + }, + *current, request, __func__); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.h b/google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.h new file mode 100644 index 0000000000000..014921e6aa6b2 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.h @@ -0,0 +1,173 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_CONNECTION_IMPL_H + +#include "google/cloud/vectorsearch/v1/internal/vector_search_retry_traits.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.h" +#include "google/cloud/vectorsearch/v1/vector_search_connection.h" +#include "google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/vector_search_options.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class VectorSearchServiceConnectionImpl + : public vectorsearch_v1::VectorSearchServiceConnection { + public: + ~VectorSearchServiceConnectionImpl() override = default; + + VectorSearchServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options); + + Options options() override { return options_; } + + StreamRange ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest request) override; + + StatusOr GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) + override; + + future> + CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + StatusOr CreateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + future> + CreateCollection(google::longrunning::Operation const& operation) override; + + future> + UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + StatusOr UpdateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + future> + UpdateCollection(google::longrunning::Operation const& operation) override; + + future> + DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr DeleteCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + future> + DeleteCollection(google::longrunning::Operation const& operation) override; + + StreamRange ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest request) override; + + StatusOr GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const& request) override; + + future> CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + StatusOr CreateIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + future> CreateIndex( + google::longrunning::Operation const& operation) override; + + future> + DeleteIndex(google::cloud::vectorsearch::v1::DeleteIndexRequest const& + request) override; + + StatusOr DeleteIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + future> + DeleteIndex(google::longrunning::Operation const& operation) override; + + future> + ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ImportDataObjects( + NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + future> + ImportDataObjects(google::longrunning::Operation const& operation) override; + + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_CONNECTION_IMPL_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.cc b/google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.cc new file mode 100644 index 0000000000000..1ad6540483ab0 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.cc @@ -0,0 +1,394 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.h" +#include "google/cloud/vectorsearch/v1/vectorsearch_service.grpc.pb.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +VectorSearchServiceLogging::VectorSearchServiceLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +StatusOr +VectorSearchServiceLogging::ListCollections( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& + request) { + return child_->ListCollections(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& + request) { + return child_->GetCollection(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +VectorSearchServiceLogging::AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& + request) { + return child_->AsyncCreateCollection(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& + request) { + return child_->CreateCollection(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +VectorSearchServiceLogging::AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& + request) { + return child_->AsyncUpdateCollection(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& + request) { + return child_->UpdateCollection(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +VectorSearchServiceLogging::AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& + request) { + return child_->AsyncDeleteCollection(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& + request) { + return child_->DeleteCollection(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) { + return child_->ListIndexes(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + return child_->GetIndex(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +VectorSearchServiceLogging::AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + return google::cloud::internal::LogWrapper( + [this]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + return child_->AsyncCreateIndex(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + return child_->CreateIndex(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +VectorSearchServiceLogging::AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + return google::cloud::internal::LogWrapper( + [this]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + return child_->AsyncDeleteIndex(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + return child_->DeleteIndex(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +VectorSearchServiceLogging::AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request) { + return child_->AsyncImportDataObjects(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request) { + return child_->ImportDataObjects(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VectorSearchServiceLogging::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VectorSearchServiceLogging::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status VectorSearchServiceLogging::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +VectorSearchServiceLogging::AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return child_->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +future VectorSearchServiceLogging::AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return child_->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.h b/google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.h new file mode 100644 index 0000000000000..a5fa586409937 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.h @@ -0,0 +1,184 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_LOGGING_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class VectorSearchServiceLogging : public VectorSearchServiceStub { + public: + ~VectorSearchServiceLogging() override = default; + VectorSearchServiceLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const& components); + + StatusOr + ListCollections(grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& + request) override; + + StatusOr GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) + override; + + future> AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + StatusOr CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + future> AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + StatusOr UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + future> AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) + override; + + StatusOr GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) override; + + future> AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + StatusOr CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + future> AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + StatusOr DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + future> AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; + TracingOptions tracing_options_; +}; // VectorSearchServiceLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_LOGGING_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.cc b/google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.cc new file mode 100644 index 0000000000000..3c3959d191712 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.cc @@ -0,0 +1,308 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.h" +#include "google/cloud/vectorsearch/v1/vectorsearch_service.grpc.pb.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/internal/url_encode.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" +#include +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +VectorSearchServiceMetadata::VectorSearchServiceMetadata( + std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header) + : child_(std::move(child)), + fixed_metadata_(std::move(fixed_metadata)), + api_client_header_( + api_client_header.empty() + ? google::cloud::internal::GeneratedLibClientHeader() + : std::move(api_client_header)) {} + +StatusOr +VectorSearchServiceMetadata::ListCollections( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListCollections(context, options, request); +} + +StatusOr +VectorSearchServiceMetadata::GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetCollection(context, options, request); +} + +future> +VectorSearchServiceMetadata::AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AsyncCreateCollection(cq, std::move(context), + std::move(options), request); +} + +StatusOr +VectorSearchServiceMetadata::CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateCollection(context, options, request); +} + +future> +VectorSearchServiceMetadata::AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("collection.name=", + internal::UrlEncode(request.collection().name()))); + return child_->AsyncUpdateCollection(cq, std::move(context), + std::move(options), request); +} + +StatusOr +VectorSearchServiceMetadata::UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("collection.name=", + internal::UrlEncode(request.collection().name()))); + return child_->UpdateCollection(context, options, request); +} + +future> +VectorSearchServiceMetadata::AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncDeleteCollection(cq, std::move(context), + std::move(options), request); +} + +StatusOr +VectorSearchServiceMetadata::DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteCollection(context, options, request); +} + +StatusOr +VectorSearchServiceMetadata::ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListIndexes(context, options, request); +} + +StatusOr +VectorSearchServiceMetadata::GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetIndex(context, options, request); +} + +future> +VectorSearchServiceMetadata::AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AsyncCreateIndex(cq, std::move(context), std::move(options), + request); +} + +StatusOr +VectorSearchServiceMetadata::CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateIndex(context, options, request); +} + +future> +VectorSearchServiceMetadata::AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncDeleteIndex(cq, std::move(context), std::move(options), + request); +} + +StatusOr +VectorSearchServiceMetadata::DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteIndex(context, options, request); +} + +future> +VectorSearchServiceMetadata::AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncImportDataObjects(cq, std::move(context), + std::move(options), request); +} + +StatusOr +VectorSearchServiceMetadata::ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ImportDataObjects(context, options, request); +} + +StatusOr +VectorSearchServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +VectorSearchServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +VectorSearchServiceMetadata::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListOperations(context, options, request); +} + +StatusOr +VectorSearchServiceMetadata::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetOperation(context, options, request); +} + +Status VectorSearchServiceMetadata::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteOperation(context, options, request); +} + +Status VectorSearchServiceMetadata::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->CancelOperation(context, options, request); +} + +future> +VectorSearchServiceMetadata::AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncGetOperation(cq, std::move(context), std::move(options), + request); +} + +future VectorSearchServiceMetadata::AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); +} + +void VectorSearchServiceMetadata::SetMetadata( + grpc::ClientContext& context, Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void VectorSearchServiceMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options) { + google::cloud::internal::SetMetadata(context, options, fixed_metadata_, + api_client_header_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.h b/google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.h new file mode 100644 index 0000000000000..4b4aa64d9769f --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.h @@ -0,0 +1,190 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_METADATA_DECORATOR_H + +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class VectorSearchServiceMetadata : public VectorSearchServiceStub { + public: + ~VectorSearchServiceMetadata() override = default; + VectorSearchServiceMetadata( + std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + StatusOr + ListCollections(grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& + request) override; + + StatusOr GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) + override; + + future> AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + StatusOr CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + future> AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + StatusOr UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + future> AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) + override; + + StatusOr GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) override; + + future> AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + StatusOr CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + future> AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + StatusOr DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + future> AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + void SetMetadata(grpc::ClientContext& context, Options const& options, + std::string const& request_params); + void SetMetadata(grpc::ClientContext& context, Options const& options); + + std::shared_ptr child_; + std::multimap fixed_metadata_; + std::string api_client_header_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_METADATA_DECORATOR_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.cc b/google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.cc new file mode 100644 index 0000000000000..176de7508fbcb --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.cc @@ -0,0 +1,83 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.h" +#include "google/cloud/vectorsearch/v1/vector_search_connection.h" +#include "google/cloud/vectorsearch/v1/vector_search_options.h" +#include "google/cloud/internal/populate_common_options.h" +#include "google/cloud/internal/populate_grpc_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options VectorSearchServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_VECTOR_SEARCH_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_VECTOR_SEARCH_SERVICE_AUTHORITY", + "vectorsearch.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + vectorsearch_v1::VectorSearchServiceLimitedTimeRetryPolicy( + std::chrono::minutes(10)) + .clone()); + } + if (!options.has()) { + options.set( + ExponentialBackoffPolicy( + std::chrono::seconds(0), std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling, kBackoffScaling) + .clone()); + } + if (!options.has()) { + options.set( + GenericPollingPolicy< + vectorsearch_v1::VectorSearchServiceRetryPolicyOption::Type, + vectorsearch_v1::VectorSearchServiceBackoffPolicyOption::Type>( + options + .get() + ->clone(), + ExponentialBackoffPolicy(std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling) + .clone()) + .clone()); + } + if (!options + .has()) { + options.set< + vectorsearch_v1::VectorSearchServiceConnectionIdempotencyPolicyOption>( + vectorsearch_v1:: + MakeDefaultVectorSearchServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.h b/google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.h new file mode 100644 index 0000000000000..374f6d6e30e03 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options VectorSearchServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_OPTION_DEFAULTS_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_retry_traits.h b/google/cloud/vectorsearch/v1/internal/vector_search_retry_traits.h new file mode 100644 index 0000000000000..556931d49e8d1 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct VectorSearchServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_RETRY_TRAITS_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_sources.cc b/google/cloud/vectorsearch/v1/internal/vector_search_sources.cc new file mode 100644 index 0000000000000..ffadc86c9f417 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_sources.cc @@ -0,0 +1,32 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.cc" +#include "google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.cc" +#include "google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.cc" +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.cc" +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.cc" +#include "google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.cc" +#include "google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.cc" +#include "google/cloud/vectorsearch/v1/vector_search_client.cc" +#include "google/cloud/vectorsearch/v1/vector_search_connection.cc" +#include "google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_stub.cc b/google/cloud/vectorsearch/v1/internal/vector_search_stub.cc new file mode 100644 index 0000000000000..ac4dd2e676984 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_stub.cc @@ -0,0 +1,383 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.h" +#include "google/cloud/vectorsearch/v1/vectorsearch_service.grpc.pb.h" +#include "google/cloud/grpc_error_delegate.h" +#include "google/cloud/status_or.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +VectorSearchServiceStub::~VectorSearchServiceStub() = default; + +StatusOr +DefaultVectorSearchServiceStub::ListCollections( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& request) { + google::cloud::vectorsearch::v1::ListCollectionsResponse response; + auto status = grpc_stub_->ListCollections(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVectorSearchServiceStub::GetCollection( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) { + google::cloud::vectorsearch::v1::Collection response; + auto status = grpc_stub_->GetCollection(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultVectorSearchServiceStub::AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::vectorsearch::v1::CreateCollectionRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncCreateCollection(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultVectorSearchServiceStub::CreateCollection( + grpc::ClientContext& context, Options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->CreateCollection(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultVectorSearchServiceStub::AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::vectorsearch::v1::UpdateCollectionRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncUpdateCollection(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultVectorSearchServiceStub::UpdateCollection( + grpc::ClientContext& context, Options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->UpdateCollection(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultVectorSearchServiceStub::AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::vectorsearch::v1::DeleteCollectionRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncDeleteCollection(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultVectorSearchServiceStub::DeleteCollection( + grpc::ClientContext& context, Options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->DeleteCollection(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVectorSearchServiceStub::ListIndexes( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) { + google::cloud::vectorsearch::v1::ListIndexesResponse response; + auto status = grpc_stub_->ListIndexes(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVectorSearchServiceStub::GetIndex( + grpc::ClientContext& context, Options const&, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + google::cloud::vectorsearch::v1::Index response; + auto status = grpc_stub_->GetIndex(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultVectorSearchServiceStub::AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::vectorsearch::v1::CreateIndexRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncCreateIndex(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultVectorSearchServiceStub::CreateIndex( + grpc::ClientContext& context, Options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->CreateIndex(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultVectorSearchServiceStub::AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::vectorsearch::v1::DeleteIndexRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncDeleteIndex(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultVectorSearchServiceStub::DeleteIndex( + grpc::ClientContext& context, Options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->DeleteIndex(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultVectorSearchServiceStub::AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::vectorsearch::v1::ImportDataObjectsRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncImportDataObjects(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultVectorSearchServiceStub::ImportDataObjects( + grpc::ClientContext& context, Options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->ImportDataObjects(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVectorSearchServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVectorSearchServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVectorSearchServiceStub::ListOperations( + grpc::ClientContext& context, Options const&, + google::longrunning::ListOperationsRequest const& request) { + google::longrunning::ListOperationsResponse response; + auto status = operations_stub_->ListOperations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVectorSearchServiceStub::GetOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::GetOperationRequest const& request) { + google::longrunning::Operation response; + auto status = operations_stub_->GetOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultVectorSearchServiceStub::DeleteOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::DeleteOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->DeleteOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +Status DefaultVectorSearchServiceStub::CancelOperation( + grpc::ClientContext& context, Options const&, + google::longrunning::CancelOperationRequest const& request) { + google::protobuf::Empty response; + auto status = operations_stub_->CancelOperation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +future> +DefaultVectorSearchServiceStub::AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + google::cloud::internal::ImmutableOptions, + google::longrunning::GetOperationRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::longrunning::GetOperationRequest const& request, + grpc::CompletionQueue* cq) { + return operations_stub_->AsyncGetOperation(context, request, cq); + }, + request, std::move(context)); +} + +future DefaultVectorSearchServiceStub::AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + google::cloud::internal::ImmutableOptions, + google::longrunning::CancelOperationRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::longrunning::CancelOperationRequest const& request, + grpc::CompletionQueue* cq) { + return operations_stub_->AsyncCancelOperation(context, request, + cq); + }, + request, std::move(context)) + .then([](future> f) { + return f.get().status(); + }); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_stub.h b/google/cloud/vectorsearch/v1/internal/vector_search_stub.h new file mode 100644 index 0000000000000..4e241a59739dc --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_stub.h @@ -0,0 +1,331 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_STUB_H + +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/vectorsearch_service.grpc.pb.h" +#include "google/cloud/completion_queue.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class VectorSearchServiceStub { + public: + virtual ~VectorSearchServiceStub() = 0; + + virtual StatusOr + ListCollections(grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& + request) = 0; + + virtual StatusOr GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) = 0; + + virtual future> + AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& + request) = 0; + + virtual StatusOr CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& + request) = 0; + + virtual future> + AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& + request) = 0; + + virtual StatusOr UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& + request) = 0; + + virtual future> + AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& + request) = 0; + + virtual StatusOr DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& + request) = 0; + + virtual StatusOr + ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) = 0; + + virtual StatusOr GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) = 0; + + virtual future> AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) = 0; + + virtual StatusOr CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) = 0; + + virtual future> AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) = 0; + + virtual StatusOr DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) = 0; + + virtual future> + AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request) = 0; + + virtual StatusOr ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) = 0; +}; + +class DefaultVectorSearchServiceStub : public VectorSearchServiceStub { + public: + DefaultVectorSearchServiceStub( + std::unique_ptr< + google::cloud::vectorsearch::v1::VectorSearchService::StubInterface> + grpc_stub, + std::unique_ptr + locations_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_stub_(std::move(operations_stub)) {} + + StatusOr + ListCollections(grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& + request) override; + + StatusOr GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) + override; + + future> AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + StatusOr CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + future> AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + StatusOr UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + future> AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) + override; + + StatusOr GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) override; + + future> AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + StatusOr CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + future> AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + StatusOr DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + future> AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::unique_ptr< + google::cloud::vectorsearch::v1::VectorSearchService::StubInterface> + grpc_stub_; + std::unique_ptr + locations_stub_; + std::unique_ptr + operations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_STUB_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.cc b/google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.cc new file mode 100644 index 0000000000000..148be690cf568 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.cc @@ -0,0 +1,82 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.h" +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_auth_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_logging_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_metadata_decorator.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.h" +#include "google/cloud/vectorsearch/v1/vectorsearch_service.grpc.pb.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultVectorSearchServiceStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::vectorsearch::v1::VectorSearchService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub), + google::longrunning::Operations::NewStub(channel)); + + if (auth->RequiresConfigureContext()) { + stub = std::make_shared(std::move(auth), + std::move(stub)); + } + stub = std::make_shared( + std::move(stub), std::multimap{}); + if (internal::Contains(options.get(), "rpc")) { + GCP_LOG(INFO) << "Enabled logging for gRPC calls"; + stub = std::make_shared( + std::move(stub), options.get(), + options.get()); + } + if (internal::TracingEnabled(options)) { + stub = MakeVectorSearchServiceTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.h b/google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.h new file mode 100644 index 0000000000000..14b82d4f65d78 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.h @@ -0,0 +1,47 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_STUB_FACTORY_H + +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultVectorSearchServiceStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_STUB_FACTORY_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.cc b/google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.cc new file mode 100644 index 0000000000000..326fc70bd89b8 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.cc @@ -0,0 +1,320 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +VectorSearchServiceTracingConnection::VectorSearchServiceTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StreamRange +VectorSearchServiceTracingConnection::ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::ListCollections"); + internal::OTelScope scope(span); + auto sr = child_->ListCollections(std::move(request)); + return internal::MakeTracedStreamRange< + google::cloud::vectorsearch::v1::Collection>(std::move(span), + std::move(sr)); +} + +StatusOr +VectorSearchServiceTracingConnection::GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::GetCollection"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetCollection(request)); +} + +future> +VectorSearchServiceTracingConnection::CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::CreateCollection"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateCollection(request)); +} + +StatusOr +VectorSearchServiceTracingConnection::CreateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::CreateCollection"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->CreateCollection(NoAwaitTag{}, request)); +} + +future> +VectorSearchServiceTracingConnection::CreateCollection( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::CreateCollection"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->CreateCollection(operation)); +} + +future> +VectorSearchServiceTracingConnection::UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::UpdateCollection"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->UpdateCollection(request)); +} + +StatusOr +VectorSearchServiceTracingConnection::UpdateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::UpdateCollection"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->UpdateCollection(NoAwaitTag{}, request)); +} + +future> +VectorSearchServiceTracingConnection::UpdateCollection( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::UpdateCollection"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->UpdateCollection(operation)); +} + +future> +VectorSearchServiceTracingConnection::DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::DeleteCollection"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteCollection(request)); +} + +StatusOr +VectorSearchServiceTracingConnection::DeleteCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::DeleteCollection"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->DeleteCollection(NoAwaitTag{}, request)); +} + +future> +VectorSearchServiceTracingConnection::DeleteCollection( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::DeleteCollection"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->DeleteCollection(operation)); +} + +StreamRange +VectorSearchServiceTracingConnection::ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::ListIndexes"); + internal::OTelScope scope(span); + auto sr = child_->ListIndexes(std::move(request)); + return internal::MakeTracedStreamRange< + google::cloud::vectorsearch::v1::Index>(std::move(span), std::move(sr)); +} + +StatusOr +VectorSearchServiceTracingConnection::GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::GetIndex"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIndex(request)); +} + +future> +VectorSearchServiceTracingConnection::CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::CreateIndex"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateIndex(request)); +} + +StatusOr +VectorSearchServiceTracingConnection::CreateIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::CreateIndex"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->CreateIndex(NoAwaitTag{}, request)); +} + +future> +VectorSearchServiceTracingConnection::CreateIndex( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::CreateIndex"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateIndex(operation)); +} + +future> +VectorSearchServiceTracingConnection::DeleteIndex( + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::DeleteIndex"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteIndex(request)); +} + +StatusOr +VectorSearchServiceTracingConnection::DeleteIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::DeleteIndex"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->DeleteIndex(NoAwaitTag{}, request)); +} + +future> +VectorSearchServiceTracingConnection::DeleteIndex( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::DeleteIndex"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteIndex(operation)); +} + +future> +VectorSearchServiceTracingConnection::ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::ImportDataObjects"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->ImportDataObjects(request)); +} + +StatusOr +VectorSearchServiceTracingConnection::ImportDataObjects( + NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::ImportDataObjects"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->ImportDataObjects(NoAwaitTag{}, request)); +} + +future> +VectorSearchServiceTracingConnection::ImportDataObjects( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::ImportDataObjects"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->ImportDataObjects(operation)); +} + +StreamRange +VectorSearchServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VectorSearchServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +VectorSearchServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VectorSearchServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status VectorSearchServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status VectorSearchServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "vectorsearch_v1::VectorSearchServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr +MakeVectorSearchServiceTracingConnection( + std::shared_ptr conn) { + if (internal::TracingEnabled(conn->options())) { + conn = + std::make_shared(std::move(conn)); + } + return conn; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.h b/google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.h new file mode 100644 index 0000000000000..82f90b5cb49db --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.h @@ -0,0 +1,167 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_TRACING_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/vector_search_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class VectorSearchServiceTracingConnection + : public vectorsearch_v1::VectorSearchServiceConnection { + public: + ~VectorSearchServiceTracingConnection() override = default; + + explicit VectorSearchServiceTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StreamRange ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest request) override; + + StatusOr GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) + override; + + future> + CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + StatusOr CreateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + future> + CreateCollection(google::longrunning::Operation const& operation) override; + + future> + UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + StatusOr UpdateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + future> + UpdateCollection(google::longrunning::Operation const& operation) override; + + future> + DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr DeleteCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + future> + DeleteCollection(google::longrunning::Operation const& operation) override; + + StreamRange ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest request) override; + + StatusOr GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const& request) override; + + future> CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + StatusOr CreateIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + future> CreateIndex( + google::longrunning::Operation const& operation) override; + + future> + DeleteIndex(google::cloud::vectorsearch::v1::DeleteIndexRequest const& + request) override; + + StatusOr DeleteIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + future> + DeleteIndex(google::longrunning::Operation const& operation) override; + + future> + ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ImportDataObjects( + NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + future> + ImportDataObjects(google::longrunning::Operation const& operation) override; + + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; +}; + +/** + * Conditionally applies the tracing decorator to the given connection. + * + * The connection is only decorated if tracing is enabled (as determined by the + * connection's options). + */ +std::shared_ptr +MakeVectorSearchServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_TRACING_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.cc b/google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.cc new file mode 100644 index 0000000000000..367ab8a4f6829 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.cc @@ -0,0 +1,352 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.h" +#include "google/cloud/internal/grpc_opentelemetry.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +VectorSearchServiceTracingStub::VectorSearchServiceTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +StatusOr +VectorSearchServiceTracingStub::ListCollections( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "ListCollections"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListCollections(context, options, request)); +} + +StatusOr +VectorSearchServiceTracingStub::GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "GetCollection"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetCollection(context, options, request)); +} + +future> +VectorSearchServiceTracingStub::AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "CreateCollection"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncCreateCollection(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +VectorSearchServiceTracingStub::CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "CreateCollection"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateCollection(context, options, request)); +} + +future> +VectorSearchServiceTracingStub::AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "UpdateCollection"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncUpdateCollection(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +VectorSearchServiceTracingStub::UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "UpdateCollection"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateCollection(context, options, request)); +} + +future> +VectorSearchServiceTracingStub::AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "DeleteCollection"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncDeleteCollection(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +VectorSearchServiceTracingStub::DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "DeleteCollection"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteCollection(context, options, request)); +} + +StatusOr +VectorSearchServiceTracingStub::ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "ListIndexes"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListIndexes(context, options, request)); +} + +StatusOr +VectorSearchServiceTracingStub::GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "GetIndex"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIndex(context, options, request)); +} + +future> +VectorSearchServiceTracingStub::AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "CreateIndex"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncCreateIndex(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +VectorSearchServiceTracingStub::CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "CreateIndex"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateIndex(context, options, request)); +} + +future> +VectorSearchServiceTracingStub::AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "DeleteIndex"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncDeleteIndex(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +VectorSearchServiceTracingStub::DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "DeleteIndex"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteIndex(context, options, request)); +} + +future> +VectorSearchServiceTracingStub::AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "ImportDataObjects"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncImportDataObjects(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +VectorSearchServiceTracingStub::ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "ImportDataObjects"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->ImportDataObjects(context, options, request)); +} + +StatusOr +VectorSearchServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +VectorSearchServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +VectorSearchServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +VectorSearchServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status VectorSearchServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status VectorSearchServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vectorsearch.v1.VectorSearchService", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +future> +VectorSearchServiceTracingStub::AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.longrunning.Operations", "GetOperation"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncGetOperation(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +future VectorSearchServiceTracingStub::AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.longrunning.Operations", + "CancelOperation"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncCancelOperation(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +std::shared_ptr MakeVectorSearchServiceTracingStub( + std::shared_ptr stub) { + return std::make_shared(std::move(stub)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.h b/google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.h new file mode 100644 index 0000000000000..60b86874b01c3 --- /dev/null +++ b/google/cloud/vectorsearch/v1/internal/vector_search_tracing_stub.h @@ -0,0 +1,192 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_TRACING_STUB_H + +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub.h" +#include "google/cloud/internal/trace_propagator.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace vectorsearch_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class VectorSearchServiceTracingStub : public VectorSearchServiceStub { + public: + ~VectorSearchServiceTracingStub() override = default; + + explicit VectorSearchServiceTracingStub( + std::shared_ptr child); + + StatusOr + ListCollections(grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListCollectionsRequest const& + request) override; + + StatusOr GetCollection( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetCollectionRequest const& request) + override; + + future> AsyncCreateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + StatusOr CreateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request) + override; + + future> AsyncUpdateCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + StatusOr UpdateCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request) + override; + + future> AsyncDeleteCollection( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr DeleteCollection( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request) + override; + + StatusOr ListIndexes( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::ListIndexesRequest const& request) + override; + + StatusOr GetIndex( + grpc::ClientContext& context, Options const& options, + google::cloud::vectorsearch::v1::GetIndexRequest const& request) override; + + future> AsyncCreateIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + StatusOr CreateIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request) + override; + + future> AsyncDeleteIndex( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + StatusOr DeleteIndex( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request) + override; + + future> AsyncImportDataObjects( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ImportDataObjects( + grpc::ClientContext& context, Options options, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request) + override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; + std::shared_ptr + propagator_; +}; + +/** + * Applies the tracing decorator to the given stub. + * + * The stub is only decorated if the library has been compiled with + * OpenTelemetry. + */ +std::shared_ptr MakeVectorSearchServiceTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_INTERNAL_VECTOR_SEARCH_TRACING_STUB_H diff --git a/google/cloud/vectorsearch/v1/mocks/mock_data_object_connection.h b/google/cloud/vectorsearch/v1/mocks/mock_data_object_connection.h new file mode 100644 index 0000000000000..896c2dd740c65 --- /dev/null +++ b/google/cloud/vectorsearch/v1/mocks/mock_data_object_connection.h @@ -0,0 +1,119 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_DATA_OBJECT_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_DATA_OBJECT_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/data_object_connection.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `DataObjectServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `DataObjectServiceClient`. To do so, + * construct an object of type `DataObjectServiceClient` with an instance of + * this class. Then use the Google Test framework functions to program the + * behavior of this mock. + * + * @see [This example][bq-mock] for how to test your application with GoogleTest. + * While the example showcases types from the BigQuery library, the underlying + * principles apply for any pair of `*Client` and `*Connection`. + * + * [bq-mock]: @cloud_cpp_docs_link{bigquery,bigquery-read-mock} + */ +class MockDataObjectServiceConnection + : public vectorsearch_v1::DataObjectServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD( + StatusOr, CreateDataObject, + (google::cloud::vectorsearch::v1::CreateDataObjectRequest const& request), + (override)); + + MOCK_METHOD( + StatusOr, + BatchCreateDataObjects, + (google::cloud::vectorsearch::v1::BatchCreateDataObjectsRequest const& + request), + (override)); + + MOCK_METHOD( + StatusOr, GetDataObject, + (google::cloud::vectorsearch::v1::GetDataObjectRequest const& request), + (override)); + + MOCK_METHOD( + StatusOr, UpdateDataObject, + (google::cloud::vectorsearch::v1::UpdateDataObjectRequest const& request), + (override)); + + MOCK_METHOD( + StatusOr, + BatchUpdateDataObjects, + (google::cloud::vectorsearch::v1::BatchUpdateDataObjectsRequest const& + request), + (override)); + + MOCK_METHOD( + Status, DeleteDataObject, + (google::cloud::vectorsearch::v1::DeleteDataObjectRequest const& request), + (override)); + + MOCK_METHOD( + Status, BatchDeleteDataObjects, + (google::cloud::vectorsearch::v1::BatchDeleteDataObjectsRequest const& + request), + (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_DATA_OBJECT_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/mocks/mock_data_object_search_connection.h b/google/cloud/vectorsearch/v1/mocks/mock_data_object_search_connection.h new file mode 100644 index 0000000000000..e1dd8d385ff21 --- /dev/null +++ b/google/cloud/vectorsearch/v1/mocks/mock_data_object_search_connection.h @@ -0,0 +1,105 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_DATA_OBJECT_SEARCH_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_DATA_OBJECT_SEARCH_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/data_object_search_connection.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `DataObjectSearchServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `DataObjectSearchServiceClient`. To + * do so, construct an object of type `DataObjectSearchServiceClient` with an + * instance of this class. Then use the Google Test framework functions to + * program the behavior of this mock. + * + * @see [This example][bq-mock] for how to test your application with GoogleTest. + * While the example showcases types from the BigQuery library, the underlying + * principles apply for any pair of `*Client` and `*Connection`. + * + * [bq-mock]: @cloud_cpp_docs_link{bigquery,bigquery-read-mock} + */ +class MockDataObjectSearchServiceConnection + : public vectorsearch_v1::DataObjectSearchServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD( + (StreamRange), + SearchDataObjects, + (google::cloud::vectorsearch::v1::SearchDataObjectsRequest request), + (override)); + + MOCK_METHOD( + (StreamRange), + QueryDataObjects, + (google::cloud::vectorsearch::v1::QueryDataObjectsRequest request), + (override)); + + MOCK_METHOD( + StatusOr, + AggregateDataObjects, + (google::cloud::vectorsearch::v1::AggregateDataObjectsRequest const& + request), + (override)); + + MOCK_METHOD( + StatusOr, + BatchSearchDataObjects, + (google::cloud::vectorsearch::v1::BatchSearchDataObjectsRequest const& + request), + (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_DATA_OBJECT_SEARCH_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/mocks/mock_vector_search_connection.h b/google/cloud/vectorsearch/v1/mocks/mock_vector_search_connection.h new file mode 100644 index 0000000000000..8edbbdbd84e56 --- /dev/null +++ b/google/cloud/vectorsearch/v1/mocks/mock_vector_search_connection.h @@ -0,0 +1,337 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_VECTOR_SEARCH_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_VECTOR_SEARCH_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/vector_search_connection.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `VectorSearchServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `VectorSearchServiceClient`. To do + * so, construct an object of type `VectorSearchServiceClient` with an instance + * of this class. Then use the Google Test framework functions to program the + * behavior of this mock. + * + * @see [This example][bq-mock] for how to test your application with GoogleTest. + * While the example showcases types from the BigQuery library, the underlying + * principles apply for any pair of `*Client` and `*Connection`. + * + * [bq-mock]: @cloud_cpp_docs_link{bigquery,bigquery-read-mock} + */ +class MockVectorSearchServiceConnection + : public vectorsearch_v1::VectorSearchServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD((StreamRange), + ListCollections, + (google::cloud::vectorsearch::v1::ListCollectionsRequest request), + (override)); + + MOCK_METHOD( + StatusOr, GetCollection, + (google::cloud::vectorsearch::v1::GetCollectionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreateCollection(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + CreateCollection, + (google::cloud::vectorsearch::v1::CreateCollectionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, CreateCollection(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, CreateCollection, + (NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, CreateCollection(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + CreateCollection, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// UpdateCollection(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + UpdateCollection, + (google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, UpdateCollection(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, UpdateCollection, + (NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, UpdateCollection(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + UpdateCollection, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeleteCollection(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeleteCollection, + (google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeleteCollection(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, DeleteCollection, + (NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, DeleteCollection(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeleteCollection, (google::longrunning::Operation const& operation), + (override)); + + MOCK_METHOD((StreamRange), + ListIndexes, + (google::cloud::vectorsearch::v1::ListIndexesRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetIndex, + (google::cloud::vectorsearch::v1::GetIndexRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreateIndex(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, CreateIndex, + (google::cloud::vectorsearch::v1::CreateIndexRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, CreateIndex(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, CreateIndex, + (NoAwaitTag, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, CreateIndex(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + CreateIndex, (google::longrunning::Operation const& operation), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeleteIndex(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeleteIndex, + (google::cloud::vectorsearch::v1::DeleteIndexRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeleteIndex(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, DeleteIndex, + (NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, DeleteIndex(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeleteIndex, (google::longrunning::Operation const& operation), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// ImportDataObjects(Matcher(_))) + /// @endcode + MOCK_METHOD( + future< + StatusOr>, + ImportDataObjects, + (google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, ImportDataObjects(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, ImportDataObjects, + (NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// ImportDataObjects(Matcher(_))) + /// @endcode + MOCK_METHOD( + future< + StatusOr>, + ImportDataObjects, (google::longrunning::Operation const& operation), + (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_MOCKS_MOCK_VECTOR_SEARCH_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/samples/data_object_client_samples.cc b/google/cloud/vectorsearch/v1/samples/data_object_client_samples.cc new file mode 100644 index 0000000000000..74f7cd695fba9 --- /dev/null +++ b/google/cloud/vectorsearch/v1/samples/data_object_client_samples.cc @@ -0,0 +1,186 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_service.proto + +#include "google/cloud/vectorsearch/v1/data_object_client.h" +#include "google/cloud/vectorsearch/v1/data_object_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/data_object_options.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/getenv.h" +#include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" +#include +#include +#include +#include + +// clang-format off +// main-dox-marker: vectorsearch_v1::DataObjectServiceClient +// clang-format on +namespace { + +void SetClientEndpoint(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-endpoint"}; + } + //! [set-client-endpoint] + // This configuration is common with Private Google Access: + // https://cloud.google.com/vpc/docs/private-google-access + auto options = google::cloud::Options{}.set( + "private.googleapis.com"); + auto vpc_client = google::cloud::vectorsearch_v1::DataObjectServiceClient( + google::cloud::vectorsearch_v1::MakeDataObjectServiceConnection(options)); + //! [set-client-endpoint] +} + +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::vectorsearch_v1::DataObjectServiceClient( + google::cloud::vectorsearch_v1::MakeDataObjectServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::vectorsearch_v1:: + DataObjectServiceConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr + clone() const override { + return std::make_unique(*this); + } + // Override inherited functions to define as needed. +}; +//! [custom-idempotency-policy] + +void SetRetryPolicy(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-retry-policy"}; + } + //! [set-retry-policy] + auto options = + google::cloud::Options{} + .set( + CustomIdempotencyPolicy().clone()) + .set( + google::cloud::vectorsearch_v1:: + DataObjectServiceLimitedErrorCountRetryPolicy(3) + .clone()) + .set( + google::cloud::ExponentialBackoffPolicy( + /*initial_delay=*/std::chrono::milliseconds(200), + /*maximum_delay=*/std::chrono::seconds(45), + /*scaling=*/2.0) + .clone()); + auto connection = + google::cloud::vectorsearch_v1::MakeDataObjectServiceConnection(options); + + // c1 and c2 share the same retry policies + auto c1 = google::cloud::vectorsearch_v1::DataObjectServiceClient(connection); + auto c2 = google::cloud::vectorsearch_v1::DataObjectServiceClient(connection); + + // You can override any of the policies in a new client. This new client + // will share the policies from c1 (or c2) *except* for the retry policy. + auto c3 = google::cloud::vectorsearch_v1::DataObjectServiceClient( + connection, google::cloud::Options{} + .set( + google::cloud::vectorsearch_v1:: + DataObjectServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::vectorsearch_v1::DataObjectServiceLimitedErrorCountRetryPolicy(10).clone())); + //! [set-retry-policy] +} + +void WithServiceAccount(std::vector const& argv) { + if (argv.size() != 1 || argv[0] == "--help") { + throw google::cloud::testing_util::Usage{"with-service-account "}; + } + //! [with-service-account] + [](std::string const& keyfile) { + auto is = std::ifstream(keyfile); + is.exceptions(std::ios::badbit); // Minimal error handling in examples + auto contents = std::string(std::istreambuf_iterator(is.rdbuf()), {}); + auto options = + google::cloud::Options{}.set( + google::cloud::MakeServiceAccountCredentials(contents)); + return google::cloud::vectorsearch_v1::DataObjectServiceClient( + google::cloud::vectorsearch_v1::MakeDataObjectServiceConnection( + options)); + } + //! [with-service-account] + (argv.at(0)); +} + +void AutoRun(std::vector const& argv) { + namespace examples = ::google::cloud::testing_util; + using ::google::cloud::internal::GetEnv; + if (!argv.empty()) throw examples::Usage{"auto"}; + examples::CheckEnvironmentVariablesAreSet( + {"GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE"}); + auto const keyfile = + GetEnv("GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE").value(); + + std::cout << "\nRunning SetClientEndpoint() example" << std::endl; + SetClientEndpoint({}); + + std::cout << "\nRunning SetRetryPolicy() example" << std::endl; + SetRetryPolicy({}); + + std::cout << "\nRunning WithServiceAccount() example" << std::endl; + WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); +} + +} // namespace + +int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) + google::cloud::testing_util::Example example({ + {"set-client-endpoint", SetClientEndpoint}, + {"set-retry-policy", SetRetryPolicy}, + {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, + {"auto", AutoRun}, + }); + return example.Run(argc, argv); +} diff --git a/google/cloud/vectorsearch/v1/samples/data_object_search_client_samples.cc b/google/cloud/vectorsearch/v1/samples/data_object_search_client_samples.cc new file mode 100644 index 0000000000000..a9bc15563481e --- /dev/null +++ b/google/cloud/vectorsearch/v1/samples/data_object_search_client_samples.cc @@ -0,0 +1,192 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/data_object_search_service.proto + +#include "google/cloud/vectorsearch/v1/data_object_search_client.h" +#include "google/cloud/vectorsearch/v1/data_object_search_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/data_object_search_options.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/getenv.h" +#include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" +#include +#include +#include +#include + +// clang-format off +// main-dox-marker: vectorsearch_v1::DataObjectSearchServiceClient +// clang-format on +namespace { + +void SetClientEndpoint(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-endpoint"}; + } + //! [set-client-endpoint] + // This configuration is common with Private Google Access: + // https://cloud.google.com/vpc/docs/private-google-access + auto options = google::cloud::Options{}.set( + "private.googleapis.com"); + auto vpc_client = + google::cloud::vectorsearch_v1::DataObjectSearchServiceClient( + google::cloud::vectorsearch_v1::MakeDataObjectSearchServiceConnection( + options)); + //! [set-client-endpoint] +} + +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::vectorsearch_v1::DataObjectSearchServiceClient( + google::cloud::vectorsearch_v1::MakeDataObjectSearchServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::vectorsearch_v1:: + DataObjectSearchServiceConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr + clone() const override { + return std::make_unique(*this); + } + // Override inherited functions to define as needed. +}; +//! [custom-idempotency-policy] + +void SetRetryPolicy(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-retry-policy"}; + } + //! [set-retry-policy] + auto options = + google::cloud::Options{} + .set( + CustomIdempotencyPolicy().clone()) + .set( + google::cloud::vectorsearch_v1:: + DataObjectSearchServiceLimitedErrorCountRetryPolicy(3) + .clone()) + .set( + google::cloud::ExponentialBackoffPolicy( + /*initial_delay=*/std::chrono::milliseconds(200), + /*maximum_delay=*/std::chrono::seconds(45), + /*scaling=*/2.0) + .clone()); + auto connection = + google::cloud::vectorsearch_v1::MakeDataObjectSearchServiceConnection( + options); + + // c1 and c2 share the same retry policies + auto c1 = + google::cloud::vectorsearch_v1::DataObjectSearchServiceClient(connection); + auto c2 = + google::cloud::vectorsearch_v1::DataObjectSearchServiceClient(connection); + + // You can override any of the policies in a new client. This new client + // will share the policies from c1 (or c2) *except* for the retry policy. + auto c3 = google::cloud::vectorsearch_v1::DataObjectSearchServiceClient( + connection, google::cloud::Options{} + .set( + google::cloud::vectorsearch_v1:: + DataObjectSearchServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::vectorsearch_v1::DataObjectSearchServiceLimitedErrorCountRetryPolicy(10).clone())); + //! [set-retry-policy] +} + +void WithServiceAccount(std::vector const& argv) { + if (argv.size() != 1 || argv[0] == "--help") { + throw google::cloud::testing_util::Usage{"with-service-account "}; + } + //! [with-service-account] + [](std::string const& keyfile) { + auto is = std::ifstream(keyfile); + is.exceptions(std::ios::badbit); // Minimal error handling in examples + auto contents = std::string(std::istreambuf_iterator(is.rdbuf()), {}); + auto options = + google::cloud::Options{}.set( + google::cloud::MakeServiceAccountCredentials(contents)); + return google::cloud::vectorsearch_v1::DataObjectSearchServiceClient( + google::cloud::vectorsearch_v1::MakeDataObjectSearchServiceConnection( + options)); + } + //! [with-service-account] + (argv.at(0)); +} + +void AutoRun(std::vector const& argv) { + namespace examples = ::google::cloud::testing_util; + using ::google::cloud::internal::GetEnv; + if (!argv.empty()) throw examples::Usage{"auto"}; + examples::CheckEnvironmentVariablesAreSet( + {"GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE"}); + auto const keyfile = + GetEnv("GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE").value(); + + std::cout << "\nRunning SetClientEndpoint() example" << std::endl; + SetClientEndpoint({}); + + std::cout << "\nRunning SetRetryPolicy() example" << std::endl; + SetRetryPolicy({}); + + std::cout << "\nRunning WithServiceAccount() example" << std::endl; + WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); +} + +} // namespace + +int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) + google::cloud::testing_util::Example example({ + {"set-client-endpoint", SetClientEndpoint}, + {"set-retry-policy", SetRetryPolicy}, + {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, + {"auto", AutoRun}, + }); + return example.Run(argc, argv); +} diff --git a/google/cloud/vectorsearch/v1/samples/vector_search_client_samples.cc b/google/cloud/vectorsearch/v1/samples/vector_search_client_samples.cc new file mode 100644 index 0000000000000..7659fcc6878d7 --- /dev/null +++ b/google/cloud/vectorsearch/v1/samples/vector_search_client_samples.cc @@ -0,0 +1,240 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/vector_search_client.h" +#include "google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/vector_search_options.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/getenv.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" +#include +#include +#include +#include + +// clang-format off +// main-dox-marker: vectorsearch_v1::VectorSearchServiceClient +// lro-marker: true +// clang-format on +namespace { + +void SetClientEndpoint(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-endpoint"}; + } + //! [set-client-endpoint] + // This configuration is common with Private Google Access: + // https://cloud.google.com/vpc/docs/private-google-access + auto options = google::cloud::Options{}.set( + "private.googleapis.com"); + auto vpc_client = google::cloud::vectorsearch_v1::VectorSearchServiceClient( + google::cloud::vectorsearch_v1::MakeVectorSearchServiceConnection( + options)); + //! [set-client-endpoint] +} + +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::vectorsearch_v1::VectorSearchServiceClient( + google::cloud::vectorsearch_v1::MakeVectorSearchServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::vectorsearch_v1:: + VectorSearchServiceConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr + clone() const override { + return std::make_unique(*this); + } + // Override inherited functions to define as needed. +}; +//! [custom-idempotency-policy] + +void SetRetryPolicy(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-retry-policy"}; + } + //! [set-retry-policy] + auto options = + google::cloud::Options{} + .set( + CustomIdempotencyPolicy().clone()) + .set( + google::cloud::vectorsearch_v1:: + VectorSearchServiceLimitedErrorCountRetryPolicy(3) + .clone()) + .set( + google::cloud::ExponentialBackoffPolicy( + /*initial_delay=*/std::chrono::milliseconds(200), + /*maximum_delay=*/std::chrono::seconds(45), + /*scaling=*/2.0) + .clone()); + auto connection = + google::cloud::vectorsearch_v1::MakeVectorSearchServiceConnection( + options); + + // c1 and c2 share the same retry policies + auto c1 = + google::cloud::vectorsearch_v1::VectorSearchServiceClient(connection); + auto c2 = + google::cloud::vectorsearch_v1::VectorSearchServiceClient(connection); + + // You can override any of the policies in a new client. This new client + // will share the policies from c1 (or c2) *except* for the retry policy. + auto c3 = google::cloud::vectorsearch_v1::VectorSearchServiceClient( + connection, google::cloud::Options{} + .set( + google::cloud::vectorsearch_v1:: + VectorSearchServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::vectorsearch_v1::VectorSearchServiceLimitedErrorCountRetryPolicy(10).clone())); + //! [set-retry-policy] +} + +void SetPollingPolicy(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-policy-policy"}; + } + //! [set-polling-policy] + + // The polling policy controls how the client waits for long-running + // operations. `GenericPollingPolicy<>` combines existing policies. + // In this case, keep polling until the operation completes (with success + // or error) or 45 minutes, whichever happens first. Initially pause for + // 10 seconds between polling requests, increasing the pause by a factor + // of 4 until it becomes 2 minutes. + auto options = + google::cloud::Options{} + .set( + google::cloud::GenericPollingPolicy< + google::cloud::vectorsearch_v1:: + VectorSearchServiceRetryPolicyOption::Type, + google::cloud::vectorsearch_v1:: + VectorSearchServiceBackoffPolicyOption::Type>( + google::cloud::vectorsearch_v1:: + VectorSearchServiceLimitedTimeRetryPolicy( + /*maximum_duration=*/std::chrono::minutes(45)) + .clone(), + google::cloud::ExponentialBackoffPolicy( + /*initial_delay=*/std::chrono::seconds(10), + /*maximum_delay=*/std::chrono::minutes(2), + /*scaling=*/4.0) + .clone()) + .clone()); + + auto connection = + google::cloud::vectorsearch_v1::MakeVectorSearchServiceConnection( + options); + + // c1 and c2 share the same polling policies. + auto c1 = + google::cloud::vectorsearch_v1::VectorSearchServiceClient(connection); + auto c2 = + google::cloud::vectorsearch_v1::VectorSearchServiceClient(connection); + //! [set-polling-policy] +} + +void WithServiceAccount(std::vector const& argv) { + if (argv.size() != 1 || argv[0] == "--help") { + throw google::cloud::testing_util::Usage{"with-service-account "}; + } + //! [with-service-account] + [](std::string const& keyfile) { + auto is = std::ifstream(keyfile); + is.exceptions(std::ios::badbit); // Minimal error handling in examples + auto contents = std::string(std::istreambuf_iterator(is.rdbuf()), {}); + auto options = + google::cloud::Options{}.set( + google::cloud::MakeServiceAccountCredentials(contents)); + return google::cloud::vectorsearch_v1::VectorSearchServiceClient( + google::cloud::vectorsearch_v1::MakeVectorSearchServiceConnection( + options)); + } + //! [with-service-account] + (argv.at(0)); +} + +void AutoRun(std::vector const& argv) { + namespace examples = ::google::cloud::testing_util; + using ::google::cloud::internal::GetEnv; + if (!argv.empty()) throw examples::Usage{"auto"}; + examples::CheckEnvironmentVariablesAreSet( + {"GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE"}); + auto const keyfile = + GetEnv("GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE").value(); + + std::cout << "\nRunning SetClientEndpoint() example" << std::endl; + SetClientEndpoint({}); + + std::cout << "\nRunning SetRetryPolicy() example" << std::endl; + SetRetryPolicy({}); + + std::cout << "\nRunning SetPollingPolicy() example" << std::endl; + SetPollingPolicy({}); + + std::cout << "\nRunning WithServiceAccount() example" << std::endl; + WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); +} + +} // namespace + +int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) + google::cloud::testing_util::Example example({ + {"set-client-endpoint", SetClientEndpoint}, + {"set-retry-policy", SetRetryPolicy}, + {"set-polling-policy", SetPollingPolicy}, + {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, + {"auto", AutoRun}, + }); + return example.Run(argc, argv); +} diff --git a/google/cloud/vectorsearch/v1/vector_search_client.cc b/google/cloud/vectorsearch/v1/vector_search_client.cc new file mode 100644 index 0000000000000..129b299a743f4 --- /dev/null +++ b/google/cloud/vectorsearch/v1/vector_search_client.cc @@ -0,0 +1,428 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/vector_search_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +VectorSearchServiceClient::VectorSearchServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +VectorSearchServiceClient::~VectorSearchServiceClient() = default; + +StreamRange +VectorSearchServiceClient::ListCollections(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::ListCollectionsRequest request; + request.set_parent(parent); + return connection_->ListCollections(request); +} + +StreamRange +VectorSearchServiceClient::ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListCollections(std::move(request)); +} + +StatusOr +VectorSearchServiceClient::GetCollection(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::GetCollectionRequest request; + request.set_name(name); + return connection_->GetCollection(request); +} + +StatusOr +VectorSearchServiceClient::GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetCollection(request); +} + +future> +VectorSearchServiceClient::CreateCollection( + std::string const& parent, + google::cloud::vectorsearch::v1::Collection const& collection, + std::string const& collection_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::CreateCollectionRequest request; + request.set_parent(parent); + *request.mutable_collection() = collection; + request.set_collection_id(collection_id); + return connection_->CreateCollection(request); +} + +StatusOr +VectorSearchServiceClient::CreateCollection( + NoAwaitTag, std::string const& parent, + google::cloud::vectorsearch::v1::Collection const& collection, + std::string const& collection_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::CreateCollectionRequest request; + request.set_parent(parent); + *request.mutable_collection() = collection; + request.set_collection_id(collection_id); + return connection_->CreateCollection(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateCollection(request); +} + +StatusOr +VectorSearchServiceClient::CreateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateCollection(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::CreateCollection( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateCollection(operation); +} + +future> +VectorSearchServiceClient::UpdateCollection( + google::cloud::vectorsearch::v1::Collection const& collection, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::UpdateCollectionRequest request; + *request.mutable_collection() = collection; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateCollection(request); +} + +StatusOr +VectorSearchServiceClient::UpdateCollection( + NoAwaitTag, google::cloud::vectorsearch::v1::Collection const& collection, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::UpdateCollectionRequest request; + *request.mutable_collection() = collection; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateCollection(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateCollection(request); +} + +StatusOr +VectorSearchServiceClient::UpdateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateCollection(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::UpdateCollection( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateCollection(operation); +} + +future> +VectorSearchServiceClient::DeleteCollection(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::DeleteCollectionRequest request; + request.set_name(name); + return connection_->DeleteCollection(request); +} + +StatusOr +VectorSearchServiceClient::DeleteCollection(NoAwaitTag, std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::DeleteCollectionRequest request; + request.set_name(name); + return connection_->DeleteCollection(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteCollection(request); +} + +StatusOr +VectorSearchServiceClient::DeleteCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteCollection(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::DeleteCollection( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteCollection(operation); +} + +StreamRange +VectorSearchServiceClient::ListIndexes(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::ListIndexesRequest request; + request.set_parent(parent); + return connection_->ListIndexes(request); +} + +StreamRange +VectorSearchServiceClient::ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListIndexes(std::move(request)); +} + +StatusOr +VectorSearchServiceClient::GetIndex(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::GetIndexRequest request; + request.set_name(name); + return connection_->GetIndex(request); +} + +StatusOr +VectorSearchServiceClient::GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIndex(request); +} + +future> +VectorSearchServiceClient::CreateIndex( + std::string const& parent, + google::cloud::vectorsearch::v1::Index const& index, + std::string const& index_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::CreateIndexRequest request; + request.set_parent(parent); + *request.mutable_index() = index; + request.set_index_id(index_id); + return connection_->CreateIndex(request); +} + +StatusOr VectorSearchServiceClient::CreateIndex( + NoAwaitTag, std::string const& parent, + google::cloud::vectorsearch::v1::Index const& index, + std::string const& index_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::CreateIndexRequest request; + request.set_parent(parent); + *request.mutable_index() = index; + request.set_index_id(index_id); + return connection_->CreateIndex(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateIndex(request); +} + +StatusOr VectorSearchServiceClient::CreateIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateIndex(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::CreateIndex( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateIndex(operation); +} + +future> +VectorSearchServiceClient::DeleteIndex(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::DeleteIndexRequest request; + request.set_name(name); + return connection_->DeleteIndex(request); +} + +StatusOr VectorSearchServiceClient::DeleteIndex( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::vectorsearch::v1::DeleteIndexRequest request; + request.set_name(name); + return connection_->DeleteIndex(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::DeleteIndex( + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteIndex(request); +} + +StatusOr VectorSearchServiceClient::DeleteIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteIndex(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::DeleteIndex( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteIndex(operation); +} + +future> +VectorSearchServiceClient::ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ImportDataObjects(request); +} + +StatusOr +VectorSearchServiceClient::ImportDataObjects( + NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ImportDataObjects(NoAwaitTag{}, request); +} + +future> +VectorSearchServiceClient::ImportDataObjects( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ImportDataObjects(operation); +} + +StreamRange +VectorSearchServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +VectorSearchServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange +VectorSearchServiceClient::ListOperations(std::string const& name, + std::string const& filter, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange +VectorSearchServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr +VectorSearchServiceClient::GetOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr +VectorSearchServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status VectorSearchServiceClient::DeleteOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status VectorSearchServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status VectorSearchServiceClient::CancelOperation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status VectorSearchServiceClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/vector_search_client.h b/google/cloud/vectorsearch/v1/vector_search_client.h new file mode 100644 index 0000000000000..97121e262ecf7 --- /dev/null +++ b/google/cloud/vectorsearch/v1/vector_search_client.h @@ -0,0 +1,1385 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CLIENT_H + +#include "google/cloud/vectorsearch/v1/vector_search_connection.h" +#include "google/cloud/future.h" +#include "google/cloud/no_await_tag.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// VectorSearchService provides methods for managing Collection resources, and +/// Collection Index resources. The primary resources offered by this service +/// are Collections which are a container for a set of related JSON data +/// objects, and Collection Indexes which enable efficient ANN search across +/// data objects within a Collection. +/// +/// @par Equality +/// +/// Instances of this class created via copy-construction or copy-assignment +/// always compare equal. Instances created with equal +/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare +/// equal share the same underlying resources. +/// +/// @par Performance +/// +/// Creating a new instance of this class is a relatively expensive operation, +/// new objects establish new connections to the service. In contrast, +/// copy-construction, move-construction, and the corresponding assignment +/// operations are relatively efficient as the copies share all underlying +/// resources. +/// +/// @par Thread Safety +/// +/// Concurrent access to different instances of this class, even if they compare +/// equal, is guaranteed to work. Two or more threads operating on the same +/// instance of this class is not guaranteed to work. Since copy-construction +/// and move-construction is a relatively efficient operation, consider using +/// such a copy when using this class from multiple threads. +/// +class VectorSearchServiceClient { + public: + explicit VectorSearchServiceClient( + std::shared_ptr connection, + Options opts = {}); + ~VectorSearchServiceClient(); + + ///@{ + /// @name Copy and move support + VectorSearchServiceClient(VectorSearchServiceClient const&) = default; + VectorSearchServiceClient& operator=(VectorSearchServiceClient const&) = + default; + VectorSearchServiceClient(VectorSearchServiceClient&&) = default; + VectorSearchServiceClient& operator=(VectorSearchServiceClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(VectorSearchServiceClient const& a, + VectorSearchServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(VectorSearchServiceClient const& a, + VectorSearchServiceClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Lists Collections in a given project and location. + /// + /// @param parent Required. Parent value for ListCollectionsRequest + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.vectorsearch.v1.Collection], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Collection]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L165} + /// [google.cloud.vectorsearch.v1.ListCollectionsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L233} + /// + // clang-format on + StreamRange ListCollections( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists Collections in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.ListCollectionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.vectorsearch.v1.Collection], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Collection]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L165} + /// [google.cloud.vectorsearch.v1.ListCollectionsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L233} + /// + // clang-format on + StreamRange ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Collection. + /// + /// @param name Required. Name of the resource + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.Collection]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Collection]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L165} + /// [google.cloud.vectorsearch.v1.GetCollectionRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L270} + /// + // clang-format on + StatusOr GetCollection( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Collection. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.GetCollectionRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.Collection]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Collection]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L165} + /// [google.cloud.vectorsearch.v1.GetCollectionRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L270} + /// + // clang-format on + StatusOr GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new Collection in a given project and location. + /// + /// @param parent Required. Value for parent. + /// @param collection Required. The resource being created + /// @param collection_id Required. ID of the Collection to create. + /// The id must be 1-63 characters long, and comply with + /// [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). + /// Specifically, it must be 1-63 characters long and match the regular + /// expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.Collection] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Collection]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L165} + /// [google.cloud.vectorsearch.v1.CreateCollectionRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L281} + /// + // clang-format on + future> + CreateCollection( + std::string const& parent, + google::cloud::vectorsearch::v1::Collection const& collection, + std::string const& collection_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateCollection + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr CreateCollection( + NoAwaitTag, std::string const& parent, + google::cloud::vectorsearch::v1::Collection const& collection, + std::string const& collection_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new Collection in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.CreateCollectionRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.Collection] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Collection]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L165} + /// [google.cloud.vectorsearch.v1.CreateCollectionRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L281} + /// + // clang-format on + future> + CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateCollection + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr CreateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateCollection + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> + CreateCollection(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Updates the parameters of a single Collection. + /// + /// @param collection Required. The resource being updated + /// @param update_mask Optional. Field mask is used to specify the fields to be overwritten in the + /// Collection resource by the update. + /// The fields specified in the update_mask are relative to the resource, not + /// the full request. A field will be overwritten if it is in the mask. If the + /// user does not provide a mask then all fields present in the request will be + /// overwritten. + /// @n + /// 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 + /// 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`. + /// @n + /// If `*` is provided in the update_mask, full replacement will be performed. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.Collection] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Collection]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L165} + /// [google.cloud.vectorsearch.v1.UpdateCollectionRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L320} + /// + // clang-format on + future> + UpdateCollection( + google::cloud::vectorsearch::v1::Collection const& collection, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateCollection + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr UpdateCollection( + NoAwaitTag, google::cloud::vectorsearch::v1::Collection const& collection, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the parameters of a single Collection. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.UpdateCollectionRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.Collection] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Collection]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L165} + /// [google.cloud.vectorsearch.v1.UpdateCollectionRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L320} + /// + // clang-format on + future> + UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateCollection + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr UpdateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateCollection + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> + UpdateCollection(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Deletes a single Collection. + /// + /// @param name Required. Name of the resource + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.OperationMetadata] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DeleteCollectionRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L364} + /// [google.cloud.vectorsearch.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L567} + /// + // clang-format on + future> + DeleteCollection(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteCollection + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr DeleteCollection( + NoAwaitTag, std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a single Collection. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.DeleteCollectionRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.OperationMetadata] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DeleteCollectionRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L364} + /// [google.cloud.vectorsearch.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L567} + /// + // clang-format on + future> + DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteCollection + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr DeleteCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteCollection + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> + DeleteCollection(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Lists Indexes in a given project and location. + /// + /// @param parent Required. Parent value for ListIndexesRequest + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.vectorsearch.v1.Index], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Index]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L393} + /// [google.cloud.vectorsearch.v1.ListIndexesRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L523} + /// + // clang-format on + StreamRange ListIndexes( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists Indexes in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.ListIndexesRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.vectorsearch.v1.Index], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.Index]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L393} + /// [google.cloud.vectorsearch.v1.ListIndexesRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L523} + /// + // clang-format on + StreamRange ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest request, + Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Index. + /// + /// @param name Required. Name of the resource + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.Index]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.GetIndexRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L556} + /// [google.cloud.vectorsearch.v1.Index]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L393} + /// + // clang-format on + StatusOr GetIndex( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Index. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.GetIndexRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.vectorsearch.v1.Index]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.GetIndexRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L556} + /// [google.cloud.vectorsearch.v1.Index]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L393} + /// + // clang-format on + StatusOr GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new Index in a given project and location. + /// + /// @param parent Required. The resource name of the Collection for which to create the + /// Index. Format: + /// `projects/{project}/locations/{location}/collections/{collection}` + /// @param index Required. The resource being created + /// @param index_id Required. ID of the Index to create. + /// The id must be 1-63 characters long, and comply with + /// [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). + /// Specifically, it must be 1-63 characters long and match the regular + /// expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.Index] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.CreateIndexRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L451} + /// [google.cloud.vectorsearch.v1.Index]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L393} + /// + // clang-format on + future> CreateIndex( + std::string const& parent, + google::cloud::vectorsearch::v1::Index const& index, + std::string const& index_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateIndex + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr CreateIndex( + NoAwaitTag, std::string const& parent, + google::cloud::vectorsearch::v1::Index const& index, + std::string const& index_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new Index in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.CreateIndexRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.Index] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.CreateIndexRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L451} + /// [google.cloud.vectorsearch.v1.Index]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L393} + /// + // clang-format on + future> CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateIndex + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr CreateIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateIndex + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> CreateIndex( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Deletes a single Index. + /// + /// @param name Required. The resource name of the Index to delete. + /// Format: + /// `projects/{project}/locations/{location}/collections/{collection}/indexes/{index}` + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.OperationMetadata] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DeleteIndexRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L492} + /// [google.cloud.vectorsearch.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L567} + /// + // clang-format on + future> + DeleteIndex(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteIndex + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr DeleteIndex(NoAwaitTag, + std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Deletes a single Index. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.DeleteIndexRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.OperationMetadata] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.DeleteIndexRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L492} + /// [google.cloud.vectorsearch.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L567} + /// + // clang-format on + future> + DeleteIndex( + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteIndex + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr DeleteIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteIndex + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> + DeleteIndex(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Initiates a Long-Running Operation to import DataObjects into a Collection. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.vectorsearch.v1.ImportDataObjectsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.vectorsearch.v1.ImportDataObjectsResponse] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.vectorsearch.v1.ImportDataObjectsRequest]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L599} + /// [google.cloud.vectorsearch.v1.ImportDataObjectsResponse]: @googleapis_reference_link{google/cloud/vectorsearch/v1/vectorsearch_service.proto#L652} + /// + // clang-format on + future> + ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief ImportDataObjects + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr ImportDataObjects( + NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief ImportDataObjects + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> + ImportDataObjects(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.longrunning.Operation], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L167} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.longrunning.Operation], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L167} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L160} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L160} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L219} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L219} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a + /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + /// `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L212} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L144} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L70} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a + /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + /// `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L212} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L144} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L70} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L38} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CLIENT_H diff --git a/google/cloud/vectorsearch/v1/vector_search_connection.cc b/google/cloud/vectorsearch/v1/vector_search_connection.cc new file mode 100644 index 0000000000000..bb9fe85f9cf9f --- /dev/null +++ b/google/cloud/vectorsearch/v1/vector_search_connection.cc @@ -0,0 +1,270 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/vector_search_connection.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_connection_impl.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_option_defaults.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_stub_factory.h" +#include "google/cloud/vectorsearch/v1/internal/vector_search_tracing_connection.h" +#include "google/cloud/vectorsearch/v1/vector_search_options.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +VectorSearchServiceConnection::~VectorSearchServiceConnection() = default; + +StreamRange +VectorSearchServiceConnection::ListCollections( + google::cloud::vectorsearch::v1:: + ListCollectionsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +VectorSearchServiceConnection::GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +VectorSearchServiceConnection::CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +VectorSearchServiceConnection::CreateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::CreateCollection( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +VectorSearchServiceConnection::UpdateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::UpdateCollection( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +VectorSearchServiceConnection::DeleteCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::DeleteCollection( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +VectorSearchServiceConnection::ListIndexes( + google::cloud::vectorsearch::v1:: + ListIndexesRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +VectorSearchServiceConnection::GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +VectorSearchServiceConnection::CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +VectorSearchServiceConnection::CreateIndex( + NoAwaitTag, google::cloud::vectorsearch::v1::CreateIndexRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::CreateIndex( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::DeleteIndex( + google::cloud::vectorsearch::v1::DeleteIndexRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +VectorSearchServiceConnection::DeleteIndex( + NoAwaitTag, google::cloud::vectorsearch::v1::DeleteIndexRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::DeleteIndex( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +VectorSearchServiceConnection::ImportDataObjects( + NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +VectorSearchServiceConnection::ImportDataObjects( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +VectorSearchServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +VectorSearchServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +VectorSearchServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +VectorSearchServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VectorSearchServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status VectorSearchServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr +MakeVectorSearchServiceConnection(Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = vectorsearch_v1_internal::VectorSearchServiceDefaultOptions( + std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = vectorsearch_v1_internal::CreateDefaultVectorSearchServiceStub( + std::move(auth), options); + return vectorsearch_v1_internal::MakeVectorSearchServiceTracingConnection( + std::make_shared< + vectorsearch_v1_internal::VectorSearchServiceConnectionImpl>( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/vector_search_connection.h b/google/cloud/vectorsearch/v1/vector_search_connection.h new file mode 100644 index 0000000000000..5474eca0cd326 --- /dev/null +++ b/google/cloud/vectorsearch/v1/vector_search_connection.h @@ -0,0 +1,322 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CONNECTION_H + +#include "google/cloud/vectorsearch/v1/internal/vector_search_retry_traits.h" +#include "google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.h" +#include "google/cloud/vectorsearch/v1/vectorsearch_service.pb.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/future.h" +#include "google/cloud/internal/retry_policy_impl.h" +#include "google/cloud/no_await_tag.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `VectorSearchServiceConnection`. +class VectorSearchServiceRetryPolicy : public ::google::cloud::RetryPolicy { + public: + /// Creates a new instance of the policy, reset to the initial state. + virtual std::unique_ptr clone() const = 0; +}; + +/** + * A retry policy for `VectorSearchServiceConnection` based on counting errors. + * + * This policy stops retrying if: + * - An RPC returns a non-transient error. + * - More than a prescribed number of transient failures is detected. + * + * In this class the following status codes are treated as transient errors: + * - [`kUnavailable`](@ref google::cloud::StatusCode) + */ +class VectorSearchServiceLimitedErrorCountRetryPolicy + : public VectorSearchServiceRetryPolicy { + public: + /** + * Create an instance that tolerates up to @p maximum_failures transient + * errors. + * + * @note Disable the retry loop by providing an instance of this policy with + * @p maximum_failures == 0. + */ + explicit VectorSearchServiceLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + VectorSearchServiceLimitedErrorCountRetryPolicy( + VectorSearchServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : VectorSearchServiceLimitedErrorCountRetryPolicy( + rhs.maximum_failures()) {} + VectorSearchServiceLimitedErrorCountRetryPolicy( + VectorSearchServiceLimitedErrorCountRetryPolicy const& rhs) noexcept + : VectorSearchServiceLimitedErrorCountRetryPolicy( + rhs.maximum_failures()) {} + + int maximum_failures() const { return impl_.maximum_failures(); } + + bool OnFailure(Status const& status) override { + return impl_.OnFailure(status); + } + bool IsExhausted() const override { return impl_.IsExhausted(); } + bool IsPermanentFailure(Status const& status) const override { + return impl_.IsPermanentFailure(status); + } + std::unique_ptr clone() const override { + return std::make_unique( + maximum_failures()); + } + + // This is provided only for backwards compatibility. + using BaseType = VectorSearchServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + vectorsearch_v1_internal::VectorSearchServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `VectorSearchServiceConnection` based on elapsed time. + * + * This policy stops retrying if: + * - An RPC returns a non-transient error. + * - The elapsed time in the retry loop exceeds a prescribed duration. + * + * In this class the following status codes are treated as transient errors: + * - [`kUnavailable`](@ref google::cloud::StatusCode) + */ +class VectorSearchServiceLimitedTimeRetryPolicy + : public VectorSearchServiceRetryPolicy { + public: + /** + * Constructor given a `std::chrono::duration<>` object. + * + * @tparam DurationRep a placeholder to match the `Rep` tparam for @p + * duration's type. The semantics of this template parameter are + * documented in `std::chrono::duration<>`. In brief, the underlying + * arithmetic type used to store the number of ticks. For our purposes it + * is simply a formal parameter. + * @tparam DurationPeriod a placeholder to match the `Period` tparam for @p + * duration's type. The semantics of this template parameter are + * documented in `std::chrono::duration<>`. In brief, the length of the + * tick in seconds, expressed as a `std::ratio<>`. For our purposes it is + * simply a formal parameter. + * @param maximum_duration the maximum time allowed before the policy expires. + * While the application can express this time in any units they desire, + * the class truncates to milliseconds. + * + * @see https://en.cppreference.com/w/cpp/chrono/duration for more information + * about `std::chrono::duration`. + */ + template + explicit VectorSearchServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + VectorSearchServiceLimitedTimeRetryPolicy( + VectorSearchServiceLimitedTimeRetryPolicy&& rhs) noexcept + : VectorSearchServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + VectorSearchServiceLimitedTimeRetryPolicy( + VectorSearchServiceLimitedTimeRetryPolicy const& rhs) noexcept + : VectorSearchServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + + std::chrono::milliseconds maximum_duration() const { + return impl_.maximum_duration(); + } + + bool OnFailure(Status const& status) override { + return impl_.OnFailure(status); + } + bool IsExhausted() const override { return impl_.IsExhausted(); } + bool IsPermanentFailure(Status const& status) const override { + return impl_.IsPermanentFailure(status); + } + std::unique_ptr clone() const override { + return std::make_unique( + maximum_duration()); + } + + // This is provided only for backwards compatibility. + using BaseType = VectorSearchServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + vectorsearch_v1_internal::VectorSearchServiceRetryTraits> + impl_; +}; + +/** + * The `VectorSearchServiceConnection` object for `VectorSearchServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `VectorSearchServiceClient`. This allows users to inject custom + * behavior (e.g., with a Google Mock object) when writing tests that use + * objects of type `VectorSearchServiceClient`. + * + * To create a concrete instance, see `MakeVectorSearchServiceConnection()`. + * + * For mocking, see `vectorsearch_v1_mocks::MockVectorSearchServiceConnection`. + */ +class VectorSearchServiceConnection { + public: + virtual ~VectorSearchServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StreamRange + ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest request); + + virtual StatusOr GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const& request); + + virtual future> + CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request); + + virtual StatusOr CreateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request); + + virtual future> + CreateCollection(google::longrunning::Operation const& operation); + + virtual future> + UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request); + + virtual StatusOr UpdateCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request); + + virtual future> + UpdateCollection(google::longrunning::Operation const& operation); + + virtual future> + DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request); + + virtual StatusOr DeleteCollection( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request); + + virtual future> + DeleteCollection(google::longrunning::Operation const& operation); + + virtual StreamRange ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest request); + + virtual StatusOr GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const& request); + + virtual future> CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const& request); + + virtual StatusOr CreateIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::CreateIndexRequest const& request); + + virtual future> CreateIndex( + google::longrunning::Operation const& operation); + + virtual future> + DeleteIndex( + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request); + + virtual StatusOr DeleteIndex( + NoAwaitTag, + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request); + + virtual future> + DeleteIndex(google::longrunning::Operation const& operation); + + virtual future< + StatusOr> + ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request); + + virtual StatusOr ImportDataObjects( + NoAwaitTag, + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request); + + virtual future< + StatusOr> + ImportDataObjects(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); +}; + +/** + * A factory function to construct an object of type + * `VectorSearchServiceConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of + * VectorSearchServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `VectorSearchServiceConnection`. Expected options are any of the + * types in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::vectorsearch_v1::VectorSearchServicePolicyOptionList` + * + * @note Unexpected options will be ignored. To log unexpected options instead, + * set `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment. + * + * @param options (optional) Configure the `VectorSearchServiceConnection` + * created by this function. + */ +std::shared_ptr +MakeVectorSearchServiceConnection(Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CONNECTION_H diff --git a/google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.cc b/google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..34db7a316c1c0 --- /dev/null +++ b/google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.cc @@ -0,0 +1,126 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#include "google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +VectorSearchServiceConnectionIdempotencyPolicy:: + ~VectorSearchServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +VectorSearchServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique( + *this); +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::DeleteIndex( + google::cloud::vectorsearch::v1::DeleteIndexRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency VectorSearchServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultVectorSearchServiceConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.h b/google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.h new file mode 100644 index 0000000000000..8edd95db39019 --- /dev/null +++ b/google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.h @@ -0,0 +1,99 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/vectorsearch/v1/vectorsearch_service.grpc.pb.h" +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class VectorSearchServiceConnectionIdempotencyPolicy { + public: + virtual ~VectorSearchServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr + clone() const; + + virtual google::cloud::Idempotency ListCollections( + google::cloud::vectorsearch::v1::ListCollectionsRequest request); + + virtual google::cloud::Idempotency GetCollection( + google::cloud::vectorsearch::v1::GetCollectionRequest const& request); + + virtual google::cloud::Idempotency CreateCollection( + google::cloud::vectorsearch::v1::CreateCollectionRequest const& request); + + virtual google::cloud::Idempotency UpdateCollection( + google::cloud::vectorsearch::v1::UpdateCollectionRequest const& request); + + virtual google::cloud::Idempotency DeleteCollection( + google::cloud::vectorsearch::v1::DeleteCollectionRequest const& request); + + virtual google::cloud::Idempotency ListIndexes( + google::cloud::vectorsearch::v1::ListIndexesRequest request); + + virtual google::cloud::Idempotency GetIndex( + google::cloud::vectorsearch::v1::GetIndexRequest const& request); + + virtual google::cloud::Idempotency CreateIndex( + google::cloud::vectorsearch::v1::CreateIndexRequest const& request); + + virtual google::cloud::Idempotency DeleteIndex( + google::cloud::vectorsearch::v1::DeleteIndexRequest const& request); + + virtual google::cloud::Idempotency ImportDataObjects( + google::cloud::vectorsearch::v1::ImportDataObjectsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); +}; + +std::unique_ptr +MakeDefaultVectorSearchServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/vectorsearch/v1/vector_search_options.h b/google/cloud/vectorsearch/v1/vector_search_options.h new file mode 100644 index 0000000000000..21dd04e9e3193 --- /dev/null +++ b/google/cloud/vectorsearch/v1/vector_search_options.h @@ -0,0 +1,87 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/vectorsearch/v1/vectorsearch_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_OPTIONS_H + +#include "google/cloud/vectorsearch/v1/vector_search_connection.h" +#include "google/cloud/vectorsearch/v1/vector_search_connection_idempotency_policy.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace vectorsearch_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct VectorSearchServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct VectorSearchServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct VectorSearchServiceConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the long-running operations + * polling policy. + * + * @ingroup google-cloud-vectorsearch-options + */ +struct VectorSearchServicePollingPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to VectorSearchService. + * + * @ingroup google-cloud-vectorsearch-options + */ +using VectorSearchServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace vectorsearch_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VECTORSEARCH_V1_VECTOR_SEARCH_OPTIONS_H diff --git a/libraries.bzl b/libraries.bzl index 5793bb3b65b23..9b2056800800f 100644 --- a/libraries.bzl +++ b/libraries.bzl @@ -246,6 +246,7 @@ GOOGLE_CLOUD_CPP_GA_LIBRARIES = [ "tpu", "trace", "translate", + "vectorsearch", "video", "videointelligence", "vision",