diff --git a/README.md b/README.md index dfc4673ea5a65..96cd5f3bd33f6 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,9 @@ See each library's `README.md` file for more information about: - [Certificate Manager API](google/cloud/certificatemanager/README.md) [[quickstart]](google/cloud/certificatemanager/quickstart/README.md) [[reference]](https://cloud.google.com/cpp/docs/reference/certificatemanager/latest) +- [Gemini Enterprise for Customer Experience API](google/cloud/ces/README.md) + [[quickstart]](google/cloud/ces/quickstart/README.md) + [[reference]](https://cloud.google.com/cpp/docs/reference/ces/latest) - [Cloud Channel API](google/cloud/channel/README.md) [[quickstart]](google/cloud/channel/quickstart/README.md) [[reference]](https://cloud.google.com/cpp/docs/reference/channel/latest) diff --git a/ci/abi-dumps/google_cloud_cpp_ces.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_ces.expected.abi.dump.gz new file mode 100644 index 0000000000000..44f5238bdc097 Binary files /dev/null and b/ci/abi-dumps/google_cloud_cpp_ces.expected.abi.dump.gz differ diff --git a/ci/etc/expected_install_directories b/ci/etc/expected_install_directories index cc929e54a07cf..f79126b8dfe5f 100644 --- a/ci/etc/expected_install_directories +++ b/ci/etc/expected_install_directories @@ -171,6 +171,10 @@ ./include/google/cloud/certificatemanager/v1 ./include/google/cloud/certificatemanager/v1/internal ./include/google/cloud/certificatemanager/v1/mocks +./include/google/cloud/ces +./include/google/cloud/ces/v1 +./include/google/cloud/ces/v1/internal +./include/google/cloud/ces/v1/mocks ./include/google/cloud/channel ./include/google/cloud/channel/v1 ./include/google/cloud/channel/v1/internal @@ -1326,6 +1330,8 @@ ./lib64/cmake/google_cloud_cpp_binaryauthorization_mocks ./lib64/cmake/google_cloud_cpp_certificatemanager ./lib64/cmake/google_cloud_cpp_certificatemanager_mocks +./lib64/cmake/google_cloud_cpp_ces +./lib64/cmake/google_cloud_cpp_ces_mocks ./lib64/cmake/google_cloud_cpp_channel ./lib64/cmake/google_cloud_cpp_channel_mocks ./lib64/cmake/google_cloud_cpp_chronicle diff --git a/cmake/GoogleCloudCppFeatures.cmake b/cmake/GoogleCloudCppFeatures.cmake index 15186185f8408..25561b78911d0 100644 --- a/cmake/GoogleCloudCppFeatures.cmake +++ b/cmake/GoogleCloudCppFeatures.cmake @@ -67,6 +67,7 @@ set(GOOGLE_CLOUD_CPP_GA_LIBRARIES "billing" "binaryauthorization" "certificatemanager" + "ces" "channel" "chronicle" "cloudbuild" diff --git a/external/googleapis/protodeps/ces.deps b/external/googleapis/protodeps/ces.deps new file mode 100644 index 0000000000000..3a69eb58546e0 --- /dev/null +++ b/external/googleapis/protodeps/ces.deps @@ -0,0 +1,8 @@ +@googleapis//google/api:annotations_proto +@googleapis//google/api:client_proto +@googleapis//google/api:field_behavior_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/ces.list b/external/googleapis/protolists/ces.list new file mode 100644 index 0000000000000..119ce2e7b685f --- /dev/null +++ b/external/googleapis/protolists/ces.list @@ -0,0 +1,38 @@ +@googleapis//google/cloud/ces/v1:agent.proto +@googleapis//google/cloud/ces/v1:agent_service.proto +@googleapis//google/cloud/ces/v1:agent_transfers.proto +@googleapis//google/cloud/ces/v1:app.proto +@googleapis//google/cloud/ces/v1:app_version.proto +@googleapis//google/cloud/ces/v1:auth.proto +@googleapis//google/cloud/ces/v1:bigquery_export.proto +@googleapis//google/cloud/ces/v1:changelog.proto +@googleapis//google/cloud/ces/v1:client_function.proto +@googleapis//google/cloud/ces/v1:common.proto +@googleapis//google/cloud/ces/v1:connector_tool.proto +@googleapis//google/cloud/ces/v1:connector_toolset.proto +@googleapis//google/cloud/ces/v1:conversation.proto +@googleapis//google/cloud/ces/v1:data_store.proto +@googleapis//google/cloud/ces/v1:data_store_tool.proto +@googleapis//google/cloud/ces/v1:deployment.proto +@googleapis//google/cloud/ces/v1:example.proto +@googleapis//google/cloud/ces/v1:fakes.proto +@googleapis//google/cloud/ces/v1:file_search_tool.proto +@googleapis//google/cloud/ces/v1:google_search_tool.proto +@googleapis//google/cloud/ces/v1:guardrail.proto +@googleapis//google/cloud/ces/v1:mcp_tool.proto +@googleapis//google/cloud/ces/v1:mcp_toolset.proto +@googleapis//google/cloud/ces/v1:omnichannel.proto +@googleapis//google/cloud/ces/v1:omnichannel_service.proto +@googleapis//google/cloud/ces/v1:open_api_tool.proto +@googleapis//google/cloud/ces/v1:open_api_toolset.proto +@googleapis//google/cloud/ces/v1:python_function.proto +@googleapis//google/cloud/ces/v1:schema.proto +@googleapis//google/cloud/ces/v1:search_suggestions.proto +@googleapis//google/cloud/ces/v1:session_service.proto +@googleapis//google/cloud/ces/v1:system_tool.proto +@googleapis//google/cloud/ces/v1:tool.proto +@googleapis//google/cloud/ces/v1:tool_service.proto +@googleapis//google/cloud/ces/v1:toolset.proto +@googleapis//google/cloud/ces/v1:toolset_tool.proto +@googleapis//google/cloud/ces/v1:widget_service.proto +@googleapis//google/cloud/ces/v1:widget_tool.proto diff --git a/external/googleapis/update_libraries.sh b/external/googleapis/update_libraries.sh index 0ff46efc06183..3a1370e92a8d9 100755 --- a/external/googleapis/update_libraries.sh +++ b/external/googleapis/update_libraries.sh @@ -93,6 +93,7 @@ declare -A -r LIBRARIES=( "@googleapis//google/cloud/certificatemanager/logging/v1:logging_cc_grpc" \ "@googleapis//google/cloud/certificatemanager/v1:certificatemanager_cc_grpc" )" + ["ces"]="@googleapis//google/cloud/ces/v1:ces_cc_grpc" ["channel"]="@googleapis//google/cloud/channel/v1:channel_cc_grpc" ["chronicle"]="@googleapis//google/cloud/chronicle/v1:chronicle_cc_grpc" ["cloudbuild"]="$( diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index fe4be3c266e6f..210c7b6e89a6f 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -666,6 +666,35 @@ service { retryable_status_codes: ["kUnavailable"] } +# CES +service { + service_proto_path: "google/cloud/ces/v1/agent_service.proto" + product_path: "google/cloud/ces/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] +} + +service { + service_proto_path: "google/cloud/ces/v1/widget_service.proto" + product_path: "google/cloud/ces/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] +} + +service { + service_proto_path: "google/cloud/ces/v1/tool_service.proto" + product_path: "google/cloud/ces/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] +} + +service { + service_proto_path: "google/cloud/ces/v1/session_service.proto" + product_path: "google/cloud/ces/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] +} + # Chronicle service { service_proto_path: "google/cloud/chronicle/v1/entity.proto" diff --git a/generator/internal/format_method_comments.cc b/generator/internal/format_method_comments.cc index 5b67477b08db3..b94c00e60ea78 100644 --- a/generator/internal/format_method_comments.cc +++ b/generator/internal/format_method_comments.cc @@ -192,9 +192,10 @@ MethodCommentSubstitution substitutions[] = { {kDialogflowEsConversationsProto, kDialogflowEsConversationsCpp}, // From google/cloud/visionai/v1/warehouse.proto + // From google/cloud/ces/v1/session_service.proto // The "---" are transformed into a element which breaks our docs // process. - {R"""(--- General Rules ---)""", R"""(General Rules:)"""}, + {R"""(---)""", R"""(-)"""}, // Add Doxygen-style comments {"\n", "\n ///"}, diff --git a/google/cloud/ces/BUILD.bazel b/google/cloud/ces/BUILD.bazel new file mode 100644 index 0000000000000..64030d2315962 --- /dev/null +++ b/google/cloud/ces/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/ces/v1:ces_cc_grpc", +] + +cc_gapic_library( + name = "ces", + googleapis_deps = googleapis_deps, + service_dirs = service_dirs, +) diff --git a/google/cloud/ces/CMakeLists.txt b/google/cloud/ces/CMakeLists.txt new file mode 100644 index 0000000000000..58fb7bc79cdee --- /dev/null +++ b/google/cloud/ces/CMakeLists.txt @@ -0,0 +1,36 @@ +# ~~~ +# 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( + ces "Gemini Enterprise for Customer Experience API" SERVICE_DIRS "v1/") + +if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS) + add_executable(ces_quickstart "quickstart/quickstart.cc") + target_link_libraries(ces_quickstart PRIVATE google-cloud-cpp::ces) + google_cloud_cpp_add_common_options(ces_quickstart) + add_test( + NAME ces_quickstart + COMMAND + cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake" + $ GOOGLE_CLOUD_PROJECT + GOOGLE_CLOUD_CPP_TEST_REGION) + set_tests_properties( + ces_quickstart + PROPERTIES LABELS "integration-test;quickstart" PASS_REGULAR_EXPRESSION + "Permanent error.*gcloud-cpp.retry.function=ListApps") +endif () diff --git a/google/cloud/ces/README.md b/google/cloud/ces/README.md new file mode 100644 index 0000000000000..22706c2382515 --- /dev/null +++ b/google/cloud/ces/README.md @@ -0,0 +1,58 @@ +# Gemini Enterprise for Customer Experience API C++ Client Library + +This directory contains an idiomatic C++ client library for the +[Gemini Enterprise for Customer Experience API][cloud-service-docs]. + +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/ces/v1/agent_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 ces = ::google::cloud::ces_v1; + auto client = ces::AgentServiceClient(ces::MakeAgentServiceConnection()); + + for (auto r : client.ListApps(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 + [Gemini Enterprise for Customer Experience 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/customer-engagement-ai/conversational-agents/ps +[doxygen-link]: https://cloud.google.com/cpp/docs/reference/ces/latest/ +[source-link]: https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/ces diff --git a/google/cloud/ces/doc/environment-variables.dox b/google/cloud/ces/doc/environment-variables.dox new file mode 100644 index 0000000000000..dabca87b6c348 --- /dev/null +++ b/google/cloud/ces/doc/environment-variables.dox @@ -0,0 +1,61 @@ +/*! +@page ces-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 ces-env-endpoint Endpoint Overrides + + + +- `GOOGLE_CLOUD_CPP_AGENT_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "ces.googleapis.com") + used by `MakeAgentServiceConnection()`. + +- `GOOGLE_CLOUD_CPP_SESSION_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "ces.googleapis.com") + used by `MakeSessionServiceConnection()`. + +- `GOOGLE_CLOUD_CPP_TOOL_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "ces.googleapis.com") + used by `MakeToolServiceConnection()`. + +- `GOOGLE_CLOUD_CPP_WIDGET_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "ces.googleapis.com") + used by `MakeWidgetServiceConnection()`. + + + +@see google::cloud::EndpointOption + +@section ces-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 ces-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/ces/doc/main.dox b/google/cloud/ces/doc/main.dox new file mode 100644 index 0000000000000..edda9ef02d7f2 --- /dev/null +++ b/google/cloud/ces/doc/main.dox @@ -0,0 +1,56 @@ +/*! + +@mainpage Gemini Enterprise for Customer Experience API C++ Client Library + +An idiomatic C++ client library for the [Gemini Enterprise for Customer Experience API][cloud-service-docs]. + + + +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/ces/quickstart/` directory, +which should give you a taste of the Gemini Enterprise for Customer Experience 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 ces_v1::AgentServiceClient](@ref google::cloud::ces_v1::AgentServiceClient) +- [\c ces_v1::SessionServiceClient](@ref google::cloud::ces_v1::SessionServiceClient) +- [\c ces_v1::ToolServiceClient](@ref google::cloud::ces_v1::ToolServiceClient) +- [\c ces_v1::WidgetServiceClient](@ref google::cloud::ces_v1::WidgetServiceClient) + + +## More Information + +- @ref common-error-handling - describes how the library reports errors. +- @ref ces-override-endpoint - describes how to override the default + endpoint. +- @ref ces-override-authentication - describes how to change the + authentication credentials used by the library. +- @ref ces-override-retry - describes how to change the default retry + policies. +- @ref ces-env - describes environment variables that can configure the + behavior of the library. +- @ref ces-override-universe-domain - describes how to override the default universe domain. + +[cloud-service-docs]: https://docs.cloud.google.com/customer-engagement-ai/conversational-agents/ps + +*/ diff --git a/google/cloud/ces/doc/options.dox b/google/cloud/ces/doc/options.dox new file mode 100644 index 0000000000000..86dc0ecaf31ab --- /dev/null +++ b/google/cloud/ces/doc/options.dox @@ -0,0 +1,10 @@ +/*! +@defgroup google-cloud-ces-options Gemini Enterprise for Customer Experience 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/ces/doc/override-authentication.dox b/google/cloud/ces/doc/override-authentication.dox new file mode 100644 index 0000000000000..c966661a1ed76 --- /dev/null +++ b/google/cloud/ces/doc/override-authentication.dox @@ -0,0 +1,60 @@ +/*! +@page ces-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 agent_client_samples.cc with-service-account + +Follow these links to find examples for other \c *Client classes: + +- [\c ces_v1::AgentServiceClient](@ref ces_v1::AgentServiceClient-service-account-snippet) +- [\c ces_v1::SessionServiceClient](@ref ces_v1::SessionServiceClient-service-account-snippet) +- [\c ces_v1::ToolServiceClient](@ref ces_v1::ToolServiceClient-service-account-snippet) +- [\c ces_v1::WidgetServiceClient](@ref ces_v1::WidgetServiceClient-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 ces_v1::AgentServiceClient-service-account-snippet Override ces_v1::AgentServiceClient Authentication Defaults + +@snippet google/cloud/ces/v1/samples/agent_client_samples.cc with-service-account + +*/ + +/*! @page ces_v1::SessionServiceClient-service-account-snippet Override ces_v1::SessionServiceClient Authentication Defaults + +@snippet google/cloud/ces/v1/samples/session_client_samples.cc with-service-account + +*/ + +/*! @page ces_v1::ToolServiceClient-service-account-snippet Override ces_v1::ToolServiceClient Authentication Defaults + +@snippet google/cloud/ces/v1/samples/tool_client_samples.cc with-service-account + +*/ + +/*! @page ces_v1::WidgetServiceClient-service-account-snippet Override ces_v1::WidgetServiceClient Authentication Defaults + +@snippet google/cloud/ces/v1/samples/widget_client_samples.cc with-service-account + +*/ +// diff --git a/google/cloud/ces/doc/override-endpoint.dox b/google/cloud/ces/doc/override-endpoint.dox new file mode 100644 index 0000000000000..818fb9eeb73b8 --- /dev/null +++ b/google/cloud/ces/doc/override-endpoint.dox @@ -0,0 +1,50 @@ +/*! +@page ces-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 `ces_v1::AgentServiceClient`: + +@snippet agent_client_samples.cc set-client-endpoint + +Follow these links to find examples for other \c *Client classes: + +- [\c ces_v1::AgentServiceClient](@ref ces_v1::AgentServiceClient-endpoint-snippet) +- [\c ces_v1::SessionServiceClient](@ref ces_v1::SessionServiceClient-endpoint-snippet) +- [\c ces_v1::ToolServiceClient](@ref ces_v1::ToolServiceClient-endpoint-snippet) +- [\c ces_v1::WidgetServiceClient](@ref ces_v1::WidgetServiceClient-endpoint-snippet) + + + +*/ + +// + +/*! @page ces_v1::AgentServiceClient-endpoint-snippet Override ces_v1::AgentServiceClient Endpoint Configuration + +@snippet google/cloud/ces/v1/samples/agent_client_samples.cc set-client-endpoint + +*/ + +/*! @page ces_v1::SessionServiceClient-endpoint-snippet Override ces_v1::SessionServiceClient Endpoint Configuration + +@snippet google/cloud/ces/v1/samples/session_client_samples.cc set-client-endpoint + +*/ + +/*! @page ces_v1::ToolServiceClient-endpoint-snippet Override ces_v1::ToolServiceClient Endpoint Configuration + +@snippet google/cloud/ces/v1/samples/tool_client_samples.cc set-client-endpoint + +*/ + +/*! @page ces_v1::WidgetServiceClient-endpoint-snippet Override ces_v1::WidgetServiceClient Endpoint Configuration + +@snippet google/cloud/ces/v1/samples/widget_client_samples.cc set-client-endpoint + +*/ +// diff --git a/google/cloud/ces/doc/override-retry-policies.dox b/google/cloud/ces/doc/override-retry-policies.dox new file mode 100644 index 0000000000000..5e15b48437254 --- /dev/null +++ b/google/cloud/ces/doc/override-retry-policies.dox @@ -0,0 +1,151 @@ +/*! +@page ces-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 ces-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 ces-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 ces-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 ces-override-retry-example Example + + +For example, this will override the retry policies for `ces_v1::AgentServiceClient`: + +@snippet agent_client_samples.cc set-retry-policy + +This assumes you have created a custom idempotency policy. Such as: + +@snippet agent_client_samples.cc custom-idempotency-policy + +This will override the polling policies for `ces_v1::AgentServiceClient` + +@snippet agent_client_samples.cc set-polling-policy + + +Follow these links to find examples for other \c *Client classes: + +- [\c ces_v1::AgentServiceClient](@ref ces_v1::AgentServiceClient-retry-snippet) +- [\c ces_v1::SessionServiceClient](@ref ces_v1::SessionServiceClient-retry-snippet) +- [\c ces_v1::ToolServiceClient](@ref ces_v1::ToolServiceClient-retry-snippet) +- [\c ces_v1::WidgetServiceClient](@ref ces_v1::WidgetServiceClient-retry-snippet) + + + +@section ces-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 ces_v1::AgentServiceClient-retry-snippet Override ces_v1::AgentServiceClient Retry Policies + +This shows how to override the retry policies for ces_v1::AgentServiceClient: + +@snippet google/cloud/ces/v1/samples/agent_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/ces/v1/samples/agent_client_samples.cc custom-idempotency-policy + +*/ + +/*! @page ces_v1::SessionServiceClient-retry-snippet Override ces_v1::SessionServiceClient Retry Policies + +This shows how to override the retry policies for ces_v1::SessionServiceClient: + +@snippet google/cloud/ces/v1/samples/session_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/ces/v1/samples/session_client_samples.cc custom-idempotency-policy + +*/ + +/*! @page ces_v1::ToolServiceClient-retry-snippet Override ces_v1::ToolServiceClient Retry Policies + +This shows how to override the retry policies for ces_v1::ToolServiceClient: + +@snippet google/cloud/ces/v1/samples/tool_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/ces/v1/samples/tool_client_samples.cc custom-idempotency-policy + +*/ + +/*! @page ces_v1::WidgetServiceClient-retry-snippet Override ces_v1::WidgetServiceClient Retry Policies + +This shows how to override the retry policies for ces_v1::WidgetServiceClient: + +@snippet google/cloud/ces/v1/samples/widget_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/ces/v1/samples/widget_client_samples.cc custom-idempotency-policy + +*/ +// diff --git a/google/cloud/ces/doc/override-universe-domain.dox b/google/cloud/ces/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5ff301d359767 --- /dev/null +++ b/google/cloud/ces/doc/override-universe-domain.dox @@ -0,0 +1,49 @@ +/*! +@page ces-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 `ces_v1::AgentServiceClient`: + +@snippet agent_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c ces_v1::AgentServiceClient](@ref ces_v1::AgentServiceClient-universe-domain-snippet) +- [\c ces_v1::SessionServiceClient](@ref ces_v1::SessionServiceClient-universe-domain-snippet) +- [\c ces_v1::ToolServiceClient](@ref ces_v1::ToolServiceClient-universe-domain-snippet) +- [\c ces_v1::WidgetServiceClient](@ref ces_v1::WidgetServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page ces_v1::AgentServiceClient-universe-domain-snippet Override ces_v1::AgentServiceClient Universe Domain + +@snippet google/cloud/ces/v1/samples/agent_client_samples.cc set-client-universe-domain + +*/ + +/*! @page ces_v1::SessionServiceClient-universe-domain-snippet Override ces_v1::SessionServiceClient Universe Domain + +@snippet google/cloud/ces/v1/samples/session_client_samples.cc set-client-universe-domain + +*/ + +/*! @page ces_v1::ToolServiceClient-universe-domain-snippet Override ces_v1::ToolServiceClient Universe Domain + +@snippet google/cloud/ces/v1/samples/tool_client_samples.cc set-client-universe-domain + +*/ + +/*! @page ces_v1::WidgetServiceClient-universe-domain-snippet Override ces_v1::WidgetServiceClient Universe Domain + +@snippet google/cloud/ces/v1/samples/widget_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/ces/quickstart/.bazelrc b/google/cloud/ces/quickstart/.bazelrc new file mode 100644 index 0000000000000..c884db46c2b4d --- /dev/null +++ b/google/cloud/ces/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/ces/quickstart/BUILD.bazel b/google/cloud/ces/quickstart/BUILD.bazel new file mode 100644 index 0000000000000..b2dff227bed3b --- /dev/null +++ b/google/cloud/ces/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//:ces", + ], +) diff --git a/google/cloud/ces/quickstart/CMakeLists.txt b/google/cloud/ces/quickstart/CMakeLists.txt new file mode 100644 index 0000000000000..a7e65582e2519 --- /dev/null +++ b/google/cloud/ces/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 Gemini Enterprise for Customer Experience API +# C++ client library from a larger CMake project. + +cmake_minimum_required(VERSION 3.22...3.31) +project(google-cloud-cpp-ces-quickstart CXX) + +find_package(google_cloud_cpp_ces 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::ces) diff --git a/google/cloud/ces/quickstart/Makefile b/google/cloud/ces/quickstart/Makefile new file mode 100644 index 0000000000000..25de5e91ee8c4 --- /dev/null +++ b/google/cloud/ces/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 Gemini Enterprise for Customer Experience 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 Gemini Enterprise for Customer Experience API C++ +# client library. +CLIENT_MODULE := google_cloud_cpp_ces +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/ces/quickstart/README.md b/google/cloud/ces/quickstart/README.md new file mode 100644 index 0000000000000..dbabddbe94053 --- /dev/null +++ b/google/cloud/ces/quickstart/README.md @@ -0,0 +1,137 @@ +# HOWTO: using the Gemini Enterprise for Customer Experience API C++ client in your project + +This directory contains small examples showing how to use the Gemini Enterprise +for Customer Experience 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, Gemini Enterprise for Customer +Experience 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/ces/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,ces] + ``` + + 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/ces/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/ces/quickstart/WORKSPACE.bazel b/google/cloud/ces/quickstart/WORKSPACE.bazel new file mode 100644 index 0000000000000..d54072a7cc7af --- /dev/null +++ b/google/cloud/ces/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 Gemini Enterprise for Customer Experience 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/ces/quickstart/quickstart.cc b/google/cloud/ces/quickstart/quickstart.cc new file mode 100644 index 0000000000000..d44947feeff5d --- /dev/null +++ b/google/cloud/ces/quickstart/quickstart.cc @@ -0,0 +1,41 @@ +// 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/ces/v1/agent_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 ces = ::google::cloud::ces_v1; + auto client = ces::AgentServiceClient(ces::MakeAgentServiceConnection()); + + for (auto r : client.ListApps(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/ces/v1/.repo-metadata.json b/google/cloud/ces/v1/.repo-metadata.json new file mode 100644 index 0000000000000..1c8a196aa718b --- /dev/null +++ b/google/cloud/ces/v1/.repo-metadata.json @@ -0,0 +1,14 @@ +{ + "api_id": "ces.googleapis.com", + "api_shortname": "ces", + "client_documentation": "https://cloud.google.com/cpp/docs/reference/ces/latest", + "distribution_name": "google-cloud-cpp", + "issue_tracker": "https://issuetracker.google.com/issues?q=componentid:1157150%20status=open", + "language": "cpp", + "library_type": "GAPIC_AUTO", + "name_pretty": "Gemini Enterprise for Customer Experience API", + "product_documentation": "https://docs.cloud.google.com/customer-engagement-ai/conversational-agents/ps", + "release_level": "stable", + "repo": "googleapis/google-cloud-cpp", + "requires_billing": true +} diff --git a/google/cloud/ces/v1/agent_client.cc b/google/cloud/ces/v1/agent_client.cc new file mode 100644 index 0000000000000..615a0c041a50b --- /dev/null +++ b/google/cloud/ces/v1/agent_client.cc @@ -0,0 +1,1087 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/agent_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AgentServiceClient::AgentServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +AgentServiceClient::~AgentServiceClient() = default; + +StreamRange AgentServiceClient::ListApps( + std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListAppsRequest request; + request.set_parent(parent); + return connection_->ListApps(request); +} + +StreamRange AgentServiceClient::ListApps( + google::cloud::ces::v1::ListAppsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListApps(std::move(request)); +} + +StatusOr AgentServiceClient::GetApp( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetAppRequest request; + request.set_name(name); + return connection_->GetApp(request); +} + +StatusOr AgentServiceClient::GetApp( + google::cloud::ces::v1::GetAppRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetApp(request); +} + +future> AgentServiceClient::CreateApp( + std::string const& parent, google::cloud::ces::v1::App const& app, + std::string const& app_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateAppRequest request; + request.set_parent(parent); + *request.mutable_app() = app; + request.set_app_id(app_id); + return connection_->CreateApp(request); +} + +StatusOr AgentServiceClient::CreateApp( + NoAwaitTag, std::string const& parent, + google::cloud::ces::v1::App const& app, std::string const& app_id, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateAppRequest request; + request.set_parent(parent); + *request.mutable_app() = app; + request.set_app_id(app_id); + return connection_->CreateApp(NoAwaitTag{}, request); +} + +future> AgentServiceClient::CreateApp( + std::string const& parent, google::cloud::ces::v1::App const& app, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateAppRequest request; + request.set_parent(parent); + *request.mutable_app() = app; + return connection_->CreateApp(request); +} + +StatusOr AgentServiceClient::CreateApp( + NoAwaitTag, std::string const& parent, + google::cloud::ces::v1::App const& app, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateAppRequest request; + request.set_parent(parent); + *request.mutable_app() = app; + return connection_->CreateApp(NoAwaitTag{}, request); +} + +future> AgentServiceClient::CreateApp( + google::cloud::ces::v1::CreateAppRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateApp(request); +} + +StatusOr AgentServiceClient::CreateApp( + NoAwaitTag, google::cloud::ces::v1::CreateAppRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateApp(NoAwaitTag{}, request); +} + +future> AgentServiceClient::CreateApp( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateApp(operation); +} + +StatusOr AgentServiceClient::UpdateApp( + google::cloud::ces::v1::App const& app, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::UpdateAppRequest request; + *request.mutable_app() = app; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateApp(request); +} + +StatusOr AgentServiceClient::UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateApp(request); +} + +future> +AgentServiceClient::DeleteApp(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteAppRequest request; + request.set_name(name); + return connection_->DeleteApp(request); +} + +StatusOr AgentServiceClient::DeleteApp( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteAppRequest request; + request.set_name(name); + return connection_->DeleteApp(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteApp(request); +} + +StatusOr AgentServiceClient::DeleteApp( + NoAwaitTag, google::cloud::ces::v1::DeleteAppRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteApp(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::DeleteApp(google::longrunning::Operation const& operation, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteApp(operation); +} + +future> +AgentServiceClient::ExportApp(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ExportAppRequest request; + request.set_name(name); + return connection_->ExportApp(request); +} + +StatusOr AgentServiceClient::ExportApp( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ExportAppRequest request; + request.set_name(name); + return connection_->ExportApp(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::ExportApp( + google::cloud::ces::v1::ExportAppRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ExportApp(request); +} + +StatusOr AgentServiceClient::ExportApp( + NoAwaitTag, google::cloud::ces::v1::ExportAppRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ExportApp(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::ExportApp(google::longrunning::Operation const& operation, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ExportApp(operation); +} + +future> +AgentServiceClient::ImportApp(std::string const& parent, + std::string const& display_name, + std::string const& app_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ImportAppRequest request; + request.set_parent(parent); + request.set_display_name(display_name); + request.set_app_id(app_id); + return connection_->ImportApp(request); +} + +StatusOr AgentServiceClient::ImportApp( + NoAwaitTag, std::string const& parent, std::string const& display_name, + std::string const& app_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ImportAppRequest request; + request.set_parent(parent); + request.set_display_name(display_name); + request.set_app_id(app_id); + return connection_->ImportApp(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::ImportApp( + google::cloud::ces::v1::ImportAppRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ImportApp(request); +} + +StatusOr AgentServiceClient::ImportApp( + NoAwaitTag, google::cloud::ces::v1::ImportAppRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ImportApp(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::ImportApp(google::longrunning::Operation const& operation, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ImportApp(operation); +} + +StreamRange AgentServiceClient::ListAgents( + std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListAgentsRequest request; + request.set_parent(parent); + return connection_->ListAgents(request); +} + +StreamRange AgentServiceClient::ListAgents( + google::cloud::ces::v1::ListAgentsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListAgents(std::move(request)); +} + +StatusOr AgentServiceClient::GetAgent( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetAgentRequest request; + request.set_name(name); + return connection_->GetAgent(request); +} + +StatusOr AgentServiceClient::GetAgent( + google::cloud::ces::v1::GetAgentRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetAgent(request); +} + +StatusOr AgentServiceClient::CreateAgent( + std::string const& parent, google::cloud::ces::v1::Agent const& agent, + std::string const& agent_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateAgentRequest request; + request.set_parent(parent); + *request.mutable_agent() = agent; + request.set_agent_id(agent_id); + return connection_->CreateAgent(request); +} + +StatusOr AgentServiceClient::CreateAgent( + std::string const& parent, google::cloud::ces::v1::Agent const& agent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateAgentRequest request; + request.set_parent(parent); + *request.mutable_agent() = agent; + return connection_->CreateAgent(request); +} + +StatusOr AgentServiceClient::CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateAgent(request); +} + +StatusOr AgentServiceClient::UpdateAgent( + google::cloud::ces::v1::Agent const& agent, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::UpdateAgentRequest request; + *request.mutable_agent() = agent; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateAgent(request); +} + +StatusOr AgentServiceClient::UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateAgent(request); +} + +Status AgentServiceClient::DeleteAgent(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteAgentRequest request; + request.set_name(name); + return connection_->DeleteAgent(request); +} + +Status AgentServiceClient::DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteAgent(request); +} + +StreamRange AgentServiceClient::ListExamples( + std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListExamplesRequest request; + request.set_parent(parent); + return connection_->ListExamples(request); +} + +StreamRange AgentServiceClient::ListExamples( + google::cloud::ces::v1::ListExamplesRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListExamples(std::move(request)); +} + +StatusOr AgentServiceClient::GetExample( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetExampleRequest request; + request.set_name(name); + return connection_->GetExample(request); +} + +StatusOr AgentServiceClient::GetExample( + google::cloud::ces::v1::GetExampleRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetExample(request); +} + +StatusOr AgentServiceClient::CreateExample( + std::string const& parent, google::cloud::ces::v1::Example const& example, + std::string const& example_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateExampleRequest request; + request.set_parent(parent); + *request.mutable_example() = example; + request.set_example_id(example_id); + return connection_->CreateExample(request); +} + +StatusOr AgentServiceClient::CreateExample( + std::string const& parent, google::cloud::ces::v1::Example const& example, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateExampleRequest request; + request.set_parent(parent); + *request.mutable_example() = example; + return connection_->CreateExample(request); +} + +StatusOr AgentServiceClient::CreateExample( + google::cloud::ces::v1::CreateExampleRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateExample(request); +} + +StatusOr AgentServiceClient::UpdateExample( + google::cloud::ces::v1::Example const& example, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::UpdateExampleRequest request; + *request.mutable_example() = example; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateExample(request); +} + +StatusOr AgentServiceClient::UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateExample(request); +} + +Status AgentServiceClient::DeleteExample(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteExampleRequest request; + request.set_name(name); + return connection_->DeleteExample(request); +} + +Status AgentServiceClient::DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteExample(request); +} + +StreamRange AgentServiceClient::ListTools( + std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListToolsRequest request; + request.set_parent(parent); + return connection_->ListTools(request); +} + +StreamRange AgentServiceClient::ListTools( + google::cloud::ces::v1::ListToolsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListTools(std::move(request)); +} + +StatusOr AgentServiceClient::GetTool( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetToolRequest request; + request.set_name(name); + return connection_->GetTool(request); +} + +StatusOr AgentServiceClient::GetTool( + google::cloud::ces::v1::GetToolRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetTool(request); +} + +StreamRange +AgentServiceClient::ListConversations(std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListConversationsRequest request; + request.set_parent(parent); + return connection_->ListConversations(request); +} + +StreamRange +AgentServiceClient::ListConversations( + google::cloud::ces::v1::ListConversationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListConversations(std::move(request)); +} + +StatusOr +AgentServiceClient::GetConversation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetConversationRequest request; + request.set_name(name); + return connection_->GetConversation(request); +} + +StatusOr +AgentServiceClient::GetConversation( + google::cloud::ces::v1::GetConversationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetConversation(request); +} + +Status AgentServiceClient::DeleteConversation(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteConversationRequest request; + request.set_name(name); + return connection_->DeleteConversation(request); +} + +Status AgentServiceClient::DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteConversation(request); +} + +future> +AgentServiceClient::BatchDeleteConversations(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::BatchDeleteConversationsRequest request; + request.set_parent(parent); + return connection_->BatchDeleteConversations(request); +} + +StatusOr +AgentServiceClient::BatchDeleteConversations(NoAwaitTag, + std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::BatchDeleteConversationsRequest request; + request.set_parent(parent); + return connection_->BatchDeleteConversations(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->BatchDeleteConversations(request); +} + +StatusOr +AgentServiceClient::BatchDeleteConversations( + NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->BatchDeleteConversations(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::BatchDeleteConversations( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->BatchDeleteConversations(operation); +} + +StatusOr AgentServiceClient::CreateTool( + std::string const& parent, google::cloud::ces::v1::Tool const& tool, + std::string const& tool_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateToolRequest request; + request.set_parent(parent); + *request.mutable_tool() = tool; + request.set_tool_id(tool_id); + return connection_->CreateTool(request); +} + +StatusOr AgentServiceClient::CreateTool( + std::string const& parent, google::cloud::ces::v1::Tool const& tool, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateToolRequest request; + request.set_parent(parent); + *request.mutable_tool() = tool; + return connection_->CreateTool(request); +} + +StatusOr AgentServiceClient::CreateTool( + google::cloud::ces::v1::CreateToolRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateTool(request); +} + +StatusOr AgentServiceClient::UpdateTool( + google::cloud::ces::v1::Tool const& tool, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::UpdateToolRequest request; + *request.mutable_tool() = tool; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateTool(request); +} + +StatusOr AgentServiceClient::UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateTool(request); +} + +Status AgentServiceClient::DeleteTool(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteToolRequest request; + request.set_name(name); + return connection_->DeleteTool(request); +} + +Status AgentServiceClient::DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteTool(request); +} + +StreamRange +AgentServiceClient::ListGuardrails(std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListGuardrailsRequest request; + request.set_parent(parent); + return connection_->ListGuardrails(request); +} + +StreamRange +AgentServiceClient::ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListGuardrails(std::move(request)); +} + +StatusOr AgentServiceClient::GetGuardrail( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetGuardrailRequest request; + request.set_name(name); + return connection_->GetGuardrail(request); +} + +StatusOr AgentServiceClient::GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetGuardrail(request); +} + +StatusOr AgentServiceClient::CreateGuardrail( + std::string const& parent, + google::cloud::ces::v1::Guardrail const& guardrail, + std::string const& guardrail_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateGuardrailRequest request; + request.set_parent(parent); + *request.mutable_guardrail() = guardrail; + request.set_guardrail_id(guardrail_id); + return connection_->CreateGuardrail(request); +} + +StatusOr AgentServiceClient::CreateGuardrail( + std::string const& parent, + google::cloud::ces::v1::Guardrail const& guardrail, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateGuardrailRequest request; + request.set_parent(parent); + *request.mutable_guardrail() = guardrail; + return connection_->CreateGuardrail(request); +} + +StatusOr AgentServiceClient::CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateGuardrail(request); +} + +StatusOr AgentServiceClient::UpdateGuardrail( + google::cloud::ces::v1::Guardrail const& guardrail, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::UpdateGuardrailRequest request; + *request.mutable_guardrail() = guardrail; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateGuardrail(request); +} + +StatusOr AgentServiceClient::UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateGuardrail(request); +} + +Status AgentServiceClient::DeleteGuardrail(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteGuardrailRequest request; + request.set_name(name); + return connection_->DeleteGuardrail(request); +} + +Status AgentServiceClient::DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteGuardrail(request); +} + +StreamRange +AgentServiceClient::ListDeployments(std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListDeploymentsRequest request; + request.set_parent(parent); + return connection_->ListDeployments(request); +} + +StreamRange +AgentServiceClient::ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListDeployments(std::move(request)); +} + +StatusOr AgentServiceClient::GetDeployment( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetDeploymentRequest request; + request.set_name(name); + return connection_->GetDeployment(request); +} + +StatusOr AgentServiceClient::GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetDeployment(request); +} + +StatusOr +AgentServiceClient::CreateDeployment( + std::string const& parent, + google::cloud::ces::v1::Deployment const& deployment, + std::string const& deployment_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateDeploymentRequest request; + request.set_parent(parent); + *request.mutable_deployment() = deployment; + request.set_deployment_id(deployment_id); + return connection_->CreateDeployment(request); +} + +StatusOr +AgentServiceClient::CreateDeployment( + std::string const& parent, + google::cloud::ces::v1::Deployment const& deployment, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateDeploymentRequest request; + request.set_parent(parent); + *request.mutable_deployment() = deployment; + return connection_->CreateDeployment(request); +} + +StatusOr +AgentServiceClient::CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateDeployment(request); +} + +StatusOr +AgentServiceClient::UpdateDeployment( + google::cloud::ces::v1::Deployment const& deployment, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::UpdateDeploymentRequest request; + *request.mutable_deployment() = deployment; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateDeployment(request); +} + +StatusOr +AgentServiceClient::UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateDeployment(request); +} + +Status AgentServiceClient::DeleteDeployment(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteDeploymentRequest request; + request.set_name(name); + return connection_->DeleteDeployment(request); +} + +Status AgentServiceClient::DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteDeployment(request); +} + +StreamRange AgentServiceClient::ListToolsets( + std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListToolsetsRequest request; + request.set_parent(parent); + return connection_->ListToolsets(request); +} + +StreamRange AgentServiceClient::ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListToolsets(std::move(request)); +} + +StatusOr AgentServiceClient::GetToolset( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetToolsetRequest request; + request.set_name(name); + return connection_->GetToolset(request); +} + +StatusOr AgentServiceClient::GetToolset( + google::cloud::ces::v1::GetToolsetRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetToolset(request); +} + +StatusOr AgentServiceClient::CreateToolset( + std::string const& parent, google::cloud::ces::v1::Toolset const& toolset, + std::string const& toolset_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateToolsetRequest request; + request.set_parent(parent); + *request.mutable_toolset() = toolset; + request.set_toolset_id(toolset_id); + return connection_->CreateToolset(request); +} + +StatusOr AgentServiceClient::CreateToolset( + std::string const& parent, google::cloud::ces::v1::Toolset const& toolset, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateToolsetRequest request; + request.set_parent(parent); + *request.mutable_toolset() = toolset; + return connection_->CreateToolset(request); +} + +StatusOr AgentServiceClient::CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateToolset(request); +} + +StatusOr AgentServiceClient::UpdateToolset( + google::cloud::ces::v1::Toolset const& toolset, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::UpdateToolsetRequest request; + *request.mutable_toolset() = toolset; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateToolset(request); +} + +StatusOr AgentServiceClient::UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateToolset(request); +} + +Status AgentServiceClient::DeleteToolset(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteToolsetRequest request; + request.set_name(name); + return connection_->DeleteToolset(request); +} + +Status AgentServiceClient::DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteToolset(request); +} + +StreamRange +AgentServiceClient::ListAppVersions(std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListAppVersionsRequest request; + request.set_parent(parent); + return connection_->ListAppVersions(request); +} + +StreamRange +AgentServiceClient::ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListAppVersions(std::move(request)); +} + +StatusOr AgentServiceClient::GetAppVersion( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetAppVersionRequest request; + request.set_name(name); + return connection_->GetAppVersion(request); +} + +StatusOr AgentServiceClient::GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetAppVersion(request); +} + +StatusOr +AgentServiceClient::CreateAppVersion( + std::string const& parent, + google::cloud::ces::v1::AppVersion const& app_version, + std::string const& app_version_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateAppVersionRequest request; + request.set_parent(parent); + *request.mutable_app_version() = app_version; + request.set_app_version_id(app_version_id); + return connection_->CreateAppVersion(request); +} + +StatusOr +AgentServiceClient::CreateAppVersion( + std::string const& parent, + google::cloud::ces::v1::AppVersion const& app_version, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::CreateAppVersionRequest request; + request.set_parent(parent); + *request.mutable_app_version() = app_version; + return connection_->CreateAppVersion(request); +} + +StatusOr +AgentServiceClient::CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateAppVersion(request); +} + +Status AgentServiceClient::DeleteAppVersion(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::DeleteAppVersionRequest request; + request.set_name(name); + return connection_->DeleteAppVersion(request); +} + +Status AgentServiceClient::DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteAppVersion(request); +} + +future> +AgentServiceClient::RestoreAppVersion(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::RestoreAppVersionRequest request; + request.set_name(name); + return connection_->RestoreAppVersion(request); +} + +StatusOr AgentServiceClient::RestoreAppVersion( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::RestoreAppVersionRequest request; + request.set_name(name); + return connection_->RestoreAppVersion(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RestoreAppVersion(request); +} + +StatusOr AgentServiceClient::RestoreAppVersion( + NoAwaitTag, google::cloud::ces::v1::RestoreAppVersionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RestoreAppVersion(NoAwaitTag{}, request); +} + +future> +AgentServiceClient::RestoreAppVersion( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RestoreAppVersion(operation); +} + +StreamRange +AgentServiceClient::ListChangelogs(std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::ListChangelogsRequest request; + request.set_parent(parent); + return connection_->ListChangelogs(request); +} + +StreamRange +AgentServiceClient::ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListChangelogs(std::move(request)); +} + +StatusOr AgentServiceClient::GetChangelog( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ces::v1::GetChangelogRequest request; + request.set_name(name); + return connection_->GetChangelog(request); +} + +StatusOr AgentServiceClient::GetChangelog( + google::cloud::ces::v1::GetChangelogRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetChangelog(request); +} + +StreamRange +AgentServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr AgentServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange AgentServiceClient::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 AgentServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr AgentServiceClient::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 AgentServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status AgentServiceClient::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 AgentServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status AgentServiceClient::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 AgentServiceClient::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 ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/agent_client.h b/google/cloud/ces/v1/agent_client.h new file mode 100644 index 0000000000000..a69a768ef7e5a --- /dev/null +++ b/google/cloud/ces/v1/agent_client.h @@ -0,0 +1,3912 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CLIENT_H + +#include "google/cloud/ces/v1/agent_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// The service that manages agent-related resources in Gemini Enterprise for +/// Customer Engagement (CES). +/// +/// @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 AgentServiceClient { + public: + explicit AgentServiceClient( + std::shared_ptr connection, Options opts = {}); + ~AgentServiceClient(); + + ///@{ + /// @name Copy and move support + AgentServiceClient(AgentServiceClient const&) = default; + AgentServiceClient& operator=(AgentServiceClient const&) = default; + AgentServiceClient(AgentServiceClient&&) = default; + AgentServiceClient& operator=(AgentServiceClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(AgentServiceClient const& a, + AgentServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(AgentServiceClient const& a, + AgentServiceClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Lists apps in the given project and location. + /// + /// @param parent Required. The resource name of the location to list apps from. + /// @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.ces.v1.App], 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.ListAppsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L503} + /// + // clang-format on + StreamRange ListApps(std::string const& parent, + Options opts = {}); + + // clang-format off + /// + /// Lists apps in the 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.ces.v1.ListAppsRequest]. + /// 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.ces.v1.App], 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.ListAppsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L503} + /// + // clang-format on + StreamRange ListApps( + google::cloud::ces::v1::ListAppsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified app. + /// + /// @param name Required. The resource name of the app to retrieve. + /// @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.ces.v1.App]) + /// 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.GetAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L548} + /// + // clang-format on + StatusOr GetApp(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified app. + /// + /// @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.ces.v1.GetAppRequest]. + /// 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.ces.v1.App]) + /// 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.GetAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L548} + /// + // clang-format on + StatusOr GetApp( + google::cloud::ces::v1::GetAppRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Creates a new app in the given project and location. + /// + /// @param parent Required. The resource name of the location to create an app in. + /// @param app Required. The app to create. + /// @param app_id Optional. The ID to use for the app, which will become the final component + /// of the app's resource name. If not provided, a unique ID will be + /// automatically assigned for the app. + /// @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.ces.v1.App] 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.CreateAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L558} + /// + // clang-format on + future> CreateApp( + std::string const& parent, google::cloud::ces::v1::App const& app, + std::string const& app_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateApp + /// + /// 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 CreateApp( + NoAwaitTag, std::string const& parent, + google::cloud::ces::v1::App const& app, std::string const& app_id, + Options opts = {}); + + // clang-format off + /// + /// Creates a new app in the given project and location. + /// + /// @param parent Required. The resource name of the location to create an app in. + /// @param app Required. The app to create. + /// @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.ces.v1.App] 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.CreateAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L558} + /// + // clang-format on + future> CreateApp( + std::string const& parent, google::cloud::ces::v1::App const& app, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateApp + /// + /// 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 CreateApp( + NoAwaitTag, std::string const& parent, + google::cloud::ces::v1::App const& app, Options opts = {}); + + // clang-format off + /// + /// Creates a new app in the 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.ces.v1.CreateAppRequest]. + /// 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.ces.v1.App] 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.CreateAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L558} + /// + // clang-format on + future> CreateApp( + google::cloud::ces::v1::CreateAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateApp + /// + /// 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 CreateApp( + NoAwaitTag, google::cloud::ces::v1::CreateAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateApp + /// + /// 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> CreateApp( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Updates the specified app. + /// + /// @param app Required. The app to update. + /// @param update_mask Optional. Field mask is used to control which fields get updated. If the + /// mask is not present, all fields will be updated. + /// @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.ces.v1.App]) + /// 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.UpdateAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L576} + /// + // clang-format on + StatusOr UpdateApp( + google::cloud::ces::v1::App const& app, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the specified app. + /// + /// @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.ces.v1.UpdateAppRequest]. + /// 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.ces.v1.App]) + /// 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.ces.v1.App]: @googleapis_reference_link{google/cloud/ces/v1/app.proto#L50} + /// [google.cloud.ces.v1.UpdateAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L576} + /// + // clang-format on + StatusOr UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified app. + /// + /// @param name Required. The resource name of the app to delete. + /// @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.ces.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.ces.v1.DeleteAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L588} + /// [google.cloud.ces.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L851} + /// + // clang-format on + future> DeleteApp( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteApp + /// + /// 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 DeleteApp(NoAwaitTag, + std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified app. + /// + /// @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.ces.v1.DeleteAppRequest]. + /// 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.ces.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.ces.v1.DeleteAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L588} + /// [google.cloud.ces.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L851} + /// + // clang-format on + future> DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteApp + /// + /// 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 DeleteApp( + NoAwaitTag, google::cloud::ces::v1::DeleteAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteApp + /// + /// 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> DeleteApp( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Exports the specified app. + /// + /// @param name Required. The resource name of the app to export. + /// @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.ces.v1.ExportAppResponse] 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.ces.v1.ExportAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L604} + /// [google.cloud.ces.v1.ExportAppResponse]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L635} + /// + // clang-format on + future> ExportApp( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief ExportApp + /// + /// 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 ExportApp(NoAwaitTag, + std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Exports the specified app. + /// + /// @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.ces.v1.ExportAppRequest]. + /// 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.ces.v1.ExportAppResponse] 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.ces.v1.ExportAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L604} + /// [google.cloud.ces.v1.ExportAppResponse]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L635} + /// + // clang-format on + future> ExportApp( + google::cloud::ces::v1::ExportAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief ExportApp + /// + /// 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 ExportApp( + NoAwaitTag, google::cloud::ces::v1::ExportAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief ExportApp + /// + /// 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> ExportApp( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Imports the specified app. + /// + /// @param parent Required. The parent resource name with the location of the app to import. + /// @param display_name Optional. The display name of the app to import. + /// * If the app is created on import, and the display name is specified, + /// the imported app will use this display name. If a conflict is detected + /// with an existing app, a timestamp will be appended to the display name + /// to make it unique. + /// * If the app is a reimport, this field should not be set. Providing a + /// display name during reimport will result in an INVALID_ARGUMENT error. + /// @param app_id Optional. The ID to use for the imported app. + /// * If not specified, a unique ID will be automatically assigned for + /// the app. + /// * Otherwise, the imported app will use this ID as the final component of + /// its resource name. If an app with the same ID already exists at the + /// specified location in the project, the content of the existing app will be + /// replaced. + /// @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.ces.v1.ImportAppResponse] 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.ces.v1.ImportAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L649} + /// [google.cloud.ces.v1.ImportAppResponse]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L732} + /// + // clang-format on + future> ImportApp( + std::string const& parent, std::string const& display_name, + std::string const& app_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief ImportApp + /// + /// 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 ImportApp( + NoAwaitTag, std::string const& parent, std::string const& display_name, + std::string const& app_id, Options opts = {}); + + // clang-format off + /// + /// Imports the specified app. + /// + /// @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.ces.v1.ImportAppRequest]. + /// 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.ces.v1.ImportAppResponse] 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.ces.v1.ImportAppRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L649} + /// [google.cloud.ces.v1.ImportAppResponse]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L732} + /// + // clang-format on + future> ImportApp( + google::cloud::ces::v1::ImportAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief ImportApp + /// + /// 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 ImportApp( + NoAwaitTag, google::cloud::ces::v1::ImportAppRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief ImportApp + /// + /// 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> ImportApp( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Lists agents in the given app. + /// + /// @param parent Required. The resource name of the app to list agents from. + /// @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.ces.v1.Agent], 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.ListAgentsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L745} + /// + // clang-format on + StreamRange ListAgents( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists agents in the given app. + /// + /// @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.ces.v1.ListAgentsRequest]. + /// 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.ces.v1.Agent], 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.ListAgentsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L745} + /// + // clang-format on + StreamRange ListAgents( + google::cloud::ces::v1::ListAgentsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified agent. + /// + /// @param name Required. The resource name of the agent to retrieve. + /// @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.ces.v1.Agent]) + /// 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.GetAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L787} + /// + // clang-format on + StatusOr GetAgent(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified agent. + /// + /// @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.ces.v1.GetAgentRequest]. + /// 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.ces.v1.Agent]) + /// 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.GetAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L787} + /// + // clang-format on + StatusOr GetAgent( + google::cloud::ces::v1::GetAgentRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new agent in the given app. + /// + /// @param parent Required. The resource name of the app to create an agent in. + /// @param agent Required. The agent to create. + /// @param agent_id Optional. The ID to use for the agent, which will become the final + /// component of the agent's resource name. If not provided, a unique ID will + /// be automatically assigned for the agent. + /// @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.ces.v1.Agent]) + /// 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.CreateAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L797} + /// + // clang-format on + StatusOr CreateAgent( + std::string const& parent, google::cloud::ces::v1::Agent const& agent, + std::string const& agent_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new agent in the given app. + /// + /// @param parent Required. The resource name of the app to create an agent in. + /// @param agent Required. The agent to create. + /// @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.ces.v1.Agent]) + /// 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.CreateAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L797} + /// + // clang-format on + StatusOr CreateAgent( + std::string const& parent, google::cloud::ces::v1::Agent const& agent, + Options opts = {}); + + // clang-format off + /// + /// Creates a new agent in the given app. + /// + /// @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.ces.v1.CreateAgentRequest]. + /// 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.ces.v1.Agent]) + /// 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.CreateAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L797} + /// + // clang-format on + StatusOr CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates the specified agent. + /// + /// @param agent Required. The agent to update. + /// @param update_mask Optional. Field mask is used to control which fields get updated. If the + /// mask is not present, all fields will be updated. + /// @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.ces.v1.Agent]) + /// 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.UpdateAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L815} + /// + // clang-format on + StatusOr UpdateAgent( + google::cloud::ces::v1::Agent const& agent, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the specified agent. + /// + /// @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.ces.v1.UpdateAgentRequest]. + /// 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.ces.v1.Agent]) + /// 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.ces.v1.Agent]: @googleapis_reference_link{google/cloud/ces/v1/agent.proto#L36} + /// [google.cloud.ces.v1.UpdateAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L815} + /// + // clang-format on + StatusOr UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified agent. + /// + /// @param name Required. The resource name of the agent to delete. + /// @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.ces.v1.DeleteAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L827} + /// + // clang-format on + Status DeleteAgent(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the specified agent. + /// + /// @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.ces.v1.DeleteAgentRequest]. + /// 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.ces.v1.DeleteAgentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L827} + /// + // clang-format on + Status DeleteAgent(google::cloud::ces::v1::DeleteAgentRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists examples in the given app. + /// + /// @param parent Required. The resource name of the app to list examples from. + /// @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.ces.v1.Example], 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.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// [google.cloud.ces.v1.ListExamplesRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L873} + /// + // clang-format on + StreamRange ListExamples( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists examples in the given app. + /// + /// @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.ces.v1.ListExamplesRequest]. + /// 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.ces.v1.Example], 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.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// [google.cloud.ces.v1.ListExamplesRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L873} + /// + // clang-format on + StreamRange ListExamples( + google::cloud::ces::v1::ListExamplesRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified example. + /// + /// @param name Required. The resource name of the example to retrieve. + /// @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.ces.v1.Example]) + /// 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.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// [google.cloud.ces.v1.GetExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L917} + /// + // clang-format on + StatusOr GetExample(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified example. + /// + /// @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.ces.v1.GetExampleRequest]. + /// 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.ces.v1.Example]) + /// 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.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// [google.cloud.ces.v1.GetExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L917} + /// + // clang-format on + StatusOr GetExample( + google::cloud::ces::v1::GetExampleRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new example in the given app. + /// + /// @param parent Required. The resource name of the app to create an example in. + /// @param example Required. The example to create. + /// @param example_id Optional. The ID to use for the example, which will become the final + /// component of the example's resource name. If not provided, a unique ID will + /// be automatically assigned for the example. + /// @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.ces.v1.Example]) + /// 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.ces.v1.CreateExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L927} + /// [google.cloud.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// + // clang-format on + StatusOr CreateExample( + std::string const& parent, google::cloud::ces::v1::Example const& example, + std::string const& example_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new example in the given app. + /// + /// @param parent Required. The resource name of the app to create an example in. + /// @param example Required. The example to create. + /// @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.ces.v1.Example]) + /// 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.ces.v1.CreateExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L927} + /// [google.cloud.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// + // clang-format on + StatusOr CreateExample( + std::string const& parent, google::cloud::ces::v1::Example const& example, + Options opts = {}); + + // clang-format off + /// + /// Creates a new example in the given app. + /// + /// @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.ces.v1.CreateExampleRequest]. + /// 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.ces.v1.Example]) + /// 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.ces.v1.CreateExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L927} + /// [google.cloud.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// + // clang-format on + StatusOr CreateExample( + google::cloud::ces::v1::CreateExampleRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates the specified example. + /// + /// @param example Required. The example to update. + /// @param update_mask Optional. Field mask is used to control which fields get updated. If the + /// mask is not present, all fields will be updated. + /// @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.ces.v1.Example]) + /// 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.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// [google.cloud.ces.v1.UpdateExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L947} + /// + // clang-format on + StatusOr UpdateExample( + google::cloud::ces::v1::Example const& example, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the specified example. + /// + /// @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.ces.v1.UpdateExampleRequest]. + /// 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.ces.v1.Example]) + /// 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.ces.v1.Example]: @googleapis_reference_link{google/cloud/ces/v1/example.proto#L32} + /// [google.cloud.ces.v1.UpdateExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L947} + /// + // clang-format on + StatusOr UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified example. + /// + /// @param name Required. The resource name of the example to delete. + /// @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.ces.v1.DeleteExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L959} + /// + // clang-format on + Status DeleteExample(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the specified example. + /// + /// @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.ces.v1.DeleteExampleRequest]. + /// 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.ces.v1.DeleteExampleRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L959} + /// + // clang-format on + Status DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists tools in the given app. + /// + /// @param parent Required. The resource name of the app to list tools from. + /// @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.ces.v1.Tool], 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.ces.v1.ListToolsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L975} + /// [google.cloud.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// + // clang-format on + StreamRange ListTools(std::string const& parent, + Options opts = {}); + + // clang-format off + /// + /// Lists tools in the given app. + /// + /// @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.ces.v1.ListToolsRequest]. + /// 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.ces.v1.Tool], 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.ces.v1.ListToolsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L975} + /// [google.cloud.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// + // clang-format on + StreamRange ListTools( + google::cloud::ces::v1::ListToolsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified tool. + /// + /// @param name Required. The resource name of the tool to retrieve. + /// @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.ces.v1.Tool]) + /// 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.ces.v1.GetToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1017} + /// [google.cloud.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// + // clang-format on + StatusOr GetTool(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified tool. + /// + /// @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.ces.v1.GetToolRequest]. + /// 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.ces.v1.Tool]) + /// 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.ces.v1.GetToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1017} + /// [google.cloud.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// + // clang-format on + StatusOr GetTool( + google::cloud::ces::v1::GetToolRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Lists conversations in the given app. + /// + /// @param parent Required. The resource name of the app to list conversations from. + /// @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.ces.v1.Conversation], 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.ces.v1.Conversation]: @googleapis_reference_link{google/cloud/ces/v1/conversation.proto#L31} + /// [google.cloud.ces.v1.ListConversationsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1082} + /// + // clang-format on + StreamRange ListConversations( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists conversations in the given app. + /// + /// @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.ces.v1.ListConversationsRequest]. + /// 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.ces.v1.Conversation], 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.ces.v1.Conversation]: @googleapis_reference_link{google/cloud/ces/v1/conversation.proto#L31} + /// [google.cloud.ces.v1.ListConversationsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1082} + /// + // clang-format on + StreamRange ListConversations( + google::cloud::ces::v1::ListConversationsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified conversation. + /// + /// @param name Required. The resource name of the conversation to retrieve. + /// @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.ces.v1.Conversation]) + /// 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.ces.v1.Conversation]: @googleapis_reference_link{google/cloud/ces/v1/conversation.proto#L31} + /// [google.cloud.ces.v1.GetConversationRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1131} + /// + // clang-format on + StatusOr GetConversation( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified conversation. + /// + /// @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.ces.v1.GetConversationRequest]. + /// 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.ces.v1.Conversation]) + /// 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.ces.v1.Conversation]: @googleapis_reference_link{google/cloud/ces/v1/conversation.proto#L31} + /// [google.cloud.ces.v1.GetConversationRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1131} + /// + // clang-format on + StatusOr GetConversation( + google::cloud::ces::v1::GetConversationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified conversation. + /// + /// @param name Required. The resource name of the conversation to delete. + /// @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.ces.v1.DeleteConversationRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1148} + /// + // clang-format on + Status DeleteConversation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the specified conversation. + /// + /// @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.ces.v1.DeleteConversationRequest]. + /// 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.ces.v1.DeleteConversationRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1148} + /// + // clang-format on + Status DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Batch deletes the specified conversations. + /// + /// @param parent Required. The resource name of the app to delete conversations from. + /// Format: + /// `projects/{project}/locations/{location}/apps/{app}` + /// @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.ces.v1.BatchDeleteConversationsResponse] 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.ces.v1.BatchDeleteConversationsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1165} + /// [google.cloud.ces.v1.BatchDeleteConversationsResponse]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1187} + /// + // clang-format on + future> + BatchDeleteConversations(std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// @copybrief BatchDeleteConversations + /// + /// 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 BatchDeleteConversations( + NoAwaitTag, std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Batch deletes the specified conversations. + /// + /// @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.ces.v1.BatchDeleteConversationsRequest]. + /// 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.ces.v1.BatchDeleteConversationsResponse] 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.ces.v1.BatchDeleteConversationsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1165} + /// [google.cloud.ces.v1.BatchDeleteConversationsResponse]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1187} + /// + // clang-format on + future> + BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief BatchDeleteConversations + /// + /// 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 BatchDeleteConversations( + NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief BatchDeleteConversations + /// + /// 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> + BatchDeleteConversations(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Creates a new tool in the given app. + /// + /// @param parent Required. The resource name of the app to create a tool in. + /// @param tool Required. The tool to create. + /// @param tool_id Optional. The ID to use for the tool, which will become the final component + /// of the tool's resource name. If not provided, a unique ID will be + /// automatically assigned for the tool. + /// @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.ces.v1.Tool]) + /// 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.ces.v1.CreateToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1027} + /// [google.cloud.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// + // clang-format on + StatusOr CreateTool( + std::string const& parent, google::cloud::ces::v1::Tool const& tool, + std::string const& tool_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new tool in the given app. + /// + /// @param parent Required. The resource name of the app to create a tool in. + /// @param tool Required. The tool to create. + /// @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.ces.v1.Tool]) + /// 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.ces.v1.CreateToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1027} + /// [google.cloud.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// + // clang-format on + StatusOr CreateTool( + std::string const& parent, google::cloud::ces::v1::Tool const& tool, + Options opts = {}); + + // clang-format off + /// + /// Creates a new tool in the given app. + /// + /// @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.ces.v1.CreateToolRequest]. + /// 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.ces.v1.Tool]) + /// 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.ces.v1.CreateToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1027} + /// [google.cloud.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// + // clang-format on + StatusOr CreateTool( + google::cloud::ces::v1::CreateToolRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates the specified tool. + /// + /// @param tool Required. The tool to update. + /// @param update_mask Optional. Field mask is used to control which fields get updated. If the + /// mask is not present, all fields will be updated. + /// @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.ces.v1.Tool]) + /// 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.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// [google.cloud.ces.v1.UpdateToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1045} + /// + // clang-format on + StatusOr UpdateTool( + google::cloud::ces::v1::Tool const& tool, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the specified tool. + /// + /// @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.ces.v1.UpdateToolRequest]. + /// 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.ces.v1.Tool]) + /// 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.ces.v1.Tool]: @googleapis_reference_link{google/cloud/ces/v1/tool.proto#L42} + /// [google.cloud.ces.v1.UpdateToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1045} + /// + // clang-format on + StatusOr UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified tool. + /// + /// @param name Required. The resource name of the tool to delete. + /// @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.ces.v1.DeleteToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1057} + /// + // clang-format on + Status DeleteTool(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the specified tool. + /// + /// @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.ces.v1.DeleteToolRequest]. + /// 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.ces.v1.DeleteToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1057} + /// + // clang-format on + Status DeleteTool(google::cloud::ces::v1::DeleteToolRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists guardrails in the given app. + /// + /// @param parent Required. The resource name of the app to list guardrails from. + /// @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.ces.v1.Guardrail], 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.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// [google.cloud.ces.v1.ListGuardrailsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1201} + /// + // clang-format on + StreamRange ListGuardrails( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists guardrails in the given app. + /// + /// @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.ces.v1.ListGuardrailsRequest]. + /// 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.ces.v1.Guardrail], 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.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// [google.cloud.ces.v1.ListGuardrailsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1201} + /// + // clang-format on + StreamRange ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified guardrail. + /// + /// @param name Required. The resource name of the guardrail to retrieve. + /// @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.ces.v1.Guardrail]) + /// 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.ces.v1.GetGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1245} + /// [google.cloud.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// + // clang-format on + StatusOr GetGuardrail( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified guardrail. + /// + /// @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.ces.v1.GetGuardrailRequest]. + /// 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.ces.v1.Guardrail]) + /// 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.ces.v1.GetGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1245} + /// [google.cloud.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// + // clang-format on + StatusOr GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new guardrail in the given app. + /// + /// @param parent Required. The resource name of the app to create a guardrail in. + /// @param guardrail Required. The guardrail to create. + /// @param guardrail_id Optional. The ID to use for the guardrail, which will become the final + /// component of the guardrail's resource name. If not provided, a unique ID + /// will be automatically assigned for the guardrail. + /// @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.ces.v1.Guardrail]) + /// 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.ces.v1.CreateGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1255} + /// [google.cloud.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// + // clang-format on + StatusOr CreateGuardrail( + std::string const& parent, + google::cloud::ces::v1::Guardrail const& guardrail, + std::string const& guardrail_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new guardrail in the given app. + /// + /// @param parent Required. The resource name of the app to create a guardrail in. + /// @param guardrail Required. The guardrail to create. + /// @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.ces.v1.Guardrail]) + /// 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.ces.v1.CreateGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1255} + /// [google.cloud.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// + // clang-format on + StatusOr CreateGuardrail( + std::string const& parent, + google::cloud::ces::v1::Guardrail const& guardrail, Options opts = {}); + + // clang-format off + /// + /// Creates a new guardrail in the given app. + /// + /// @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.ces.v1.CreateGuardrailRequest]. + /// 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.ces.v1.Guardrail]) + /// 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.ces.v1.CreateGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1255} + /// [google.cloud.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// + // clang-format on + StatusOr CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates the specified guardrail. + /// + /// @param guardrail Required. The guardrail to update. + /// @param update_mask Optional. Field mask is used to control which fields get updated. If the + /// mask is not present, all fields will be updated. + /// @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.ces.v1.Guardrail]) + /// 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.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// [google.cloud.ces.v1.UpdateGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1275} + /// + // clang-format on + StatusOr UpdateGuardrail( + google::cloud::ces::v1::Guardrail const& guardrail, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the specified guardrail. + /// + /// @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.ces.v1.UpdateGuardrailRequest]. + /// 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.ces.v1.Guardrail]) + /// 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.ces.v1.Guardrail]: @googleapis_reference_link{google/cloud/ces/v1/guardrail.proto#L31} + /// [google.cloud.ces.v1.UpdateGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1275} + /// + // clang-format on + StatusOr UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified guardrail. + /// + /// @param name Required. The resource name of the guardrail to delete. + /// @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.ces.v1.DeleteGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1287} + /// + // clang-format on + Status DeleteGuardrail(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the specified guardrail. + /// + /// @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.ces.v1.DeleteGuardrailRequest]. + /// 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.ces.v1.DeleteGuardrailRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1287} + /// + // clang-format on + Status DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists deployments in the given app. + /// + /// @param parent Required. The parent app. + /// Format: + /// `projects/{project}/locations/{location}/apps/{app}` + /// @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.ces.v1.Deployment], 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.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// [google.cloud.ces.v1.ListDeploymentsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1312} + /// + // clang-format on + StreamRange ListDeployments( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists deployments in the given app. + /// + /// @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.ces.v1.ListDeploymentsRequest]. + /// 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.ces.v1.Deployment], 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.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// [google.cloud.ces.v1.ListDeploymentsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1312} + /// + // clang-format on + StreamRange ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified deployment. + /// + /// @param name Required. The name of the deployment. + /// Format: + /// `projects/{project}/locations/{location}/apps/{app}/deployments/{deployment}` + /// @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.ces.v1.Deployment]) + /// 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.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// [google.cloud.ces.v1.GetDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1354} + /// + // clang-format on + StatusOr GetDeployment( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified deployment. + /// + /// @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.ces.v1.GetDeploymentRequest]. + /// 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.ces.v1.Deployment]) + /// 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.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// [google.cloud.ces.v1.GetDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1354} + /// + // clang-format on + StatusOr GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new deployment in the given app. + /// + /// @param parent Required. The parent app. + /// Format: + /// `projects/{project}/locations/{location}/apps/{app}` + /// @param deployment Required. The deployment to create. + /// @param deployment_id Optional. The ID to use for the deployment, which will become the final + /// component of the deployment's resource name. If not provided, a unique ID + /// will be automatically assigned for the deployment. + /// @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.ces.v1.Deployment]) + /// 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.ces.v1.CreateDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1366} + /// [google.cloud.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// + // clang-format on + StatusOr CreateDeployment( + std::string const& parent, + google::cloud::ces::v1::Deployment const& deployment, + std::string const& deployment_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new deployment in the given app. + /// + /// @param parent Required. The parent app. + /// Format: + /// `projects/{project}/locations/{location}/apps/{app}` + /// @param deployment Required. The deployment to create. + /// @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.ces.v1.Deployment]) + /// 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.ces.v1.CreateDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1366} + /// [google.cloud.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// + // clang-format on + StatusOr CreateDeployment( + std::string const& parent, + google::cloud::ces::v1::Deployment const& deployment, Options opts = {}); + + // clang-format off + /// + /// Creates a new deployment in the given app. + /// + /// @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.ces.v1.CreateDeploymentRequest]. + /// 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.ces.v1.Deployment]) + /// 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.ces.v1.CreateDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1366} + /// [google.cloud.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// + // clang-format on + StatusOr CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates the specified deployment. + /// + /// @param deployment Required. The deployment to update. + /// @param update_mask Optional. The list of fields to update. + /// @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.ces.v1.Deployment]) + /// 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.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// [google.cloud.ces.v1.UpdateDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1388} + /// + // clang-format on + StatusOr UpdateDeployment( + google::cloud::ces::v1::Deployment const& deployment, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the specified deployment. + /// + /// @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.ces.v1.UpdateDeploymentRequest]. + /// 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.ces.v1.Deployment]) + /// 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.ces.v1.Deployment]: @googleapis_reference_link{google/cloud/ces/v1/deployment.proto#L31} + /// [google.cloud.ces.v1.UpdateDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1388} + /// + // clang-format on + StatusOr UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified deployment. + /// + /// @param name Required. The name of the deployment to delete. + /// Format: + /// `projects/{project}/locations/{location}/apps/{app}/deployments/{deployment}` + /// @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.ces.v1.DeleteDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1399} + /// + // clang-format on + Status DeleteDeployment(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the specified deployment. + /// + /// @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.ces.v1.DeleteDeploymentRequest]. + /// 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.ces.v1.DeleteDeploymentRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1399} + /// + // clang-format on + Status DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists toolsets in the given app. + /// + /// @param parent Required. The resource name of the app to list toolsets from. + /// @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.ces.v1.Toolset], 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.ces.v1.ListToolsetsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1416} + /// [google.cloud.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// + // clang-format on + StreamRange ListToolsets( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists toolsets in the given app. + /// + /// @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.ces.v1.ListToolsetsRequest]. + /// 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.ces.v1.Toolset], 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.ces.v1.ListToolsetsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1416} + /// [google.cloud.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// + // clang-format on + StreamRange ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified toolset. + /// + /// @param name Required. The resource name of the toolset to retrieve. + /// @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.ces.v1.Toolset]) + /// 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.ces.v1.GetToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1460} + /// [google.cloud.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// + // clang-format on + StatusOr GetToolset(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified toolset. + /// + /// @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.ces.v1.GetToolsetRequest]. + /// 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.ces.v1.Toolset]) + /// 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.ces.v1.GetToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1460} + /// [google.cloud.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// + // clang-format on + StatusOr GetToolset( + google::cloud::ces::v1::GetToolsetRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new toolset in the given app. + /// + /// @param parent Required. The resource name of the app to create a toolset in. + /// @param toolset Required. The toolset to create. + /// @param toolset_id Optional. The ID to use for the toolset, which will become the final + /// component of the toolset's resource name. If not provided, a unique ID will + /// be automatically assigned for the toolset. + /// @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.ces.v1.Toolset]) + /// 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.ces.v1.CreateToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1470} + /// [google.cloud.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// + // clang-format on + StatusOr CreateToolset( + std::string const& parent, google::cloud::ces::v1::Toolset const& toolset, + std::string const& toolset_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new toolset in the given app. + /// + /// @param parent Required. The resource name of the app to create a toolset in. + /// @param toolset Required. The toolset to create. + /// @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.ces.v1.Toolset]) + /// 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.ces.v1.CreateToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1470} + /// [google.cloud.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// + // clang-format on + StatusOr CreateToolset( + std::string const& parent, google::cloud::ces::v1::Toolset const& toolset, + Options opts = {}); + + // clang-format off + /// + /// Creates a new toolset in the given app. + /// + /// @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.ces.v1.CreateToolsetRequest]. + /// 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.ces.v1.Toolset]) + /// 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.ces.v1.CreateToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1470} + /// [google.cloud.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// + // clang-format on + StatusOr CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates the specified toolset. + /// + /// @param toolset Required. The toolset to update. + /// @param update_mask Optional. Field mask is used to control which fields get updated. If the + /// mask is not present, all fields will be updated. + /// @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.ces.v1.Toolset]) + /// 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.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// [google.cloud.ces.v1.UpdateToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1490} + /// + // clang-format on + StatusOr UpdateToolset( + google::cloud::ces::v1::Toolset const& toolset, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the specified toolset. + /// + /// @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.ces.v1.UpdateToolsetRequest]. + /// 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.ces.v1.Toolset]) + /// 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.ces.v1.Toolset]: @googleapis_reference_link{google/cloud/ces/v1/toolset.proto#L35} + /// [google.cloud.ces.v1.UpdateToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1490} + /// + // clang-format on + StatusOr UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified toolset. + /// + /// @param name Required. The resource name of the toolset to delete. + /// @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.ces.v1.DeleteToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1502} + /// + // clang-format on + Status DeleteToolset(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the specified toolset. + /// + /// @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.ces.v1.DeleteToolsetRequest]. + /// 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.ces.v1.DeleteToolsetRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1502} + /// + // clang-format on + Status DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists all app versions in the given app. + /// + /// @param parent Required. The resource name of the app to list app versions from. + /// @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.ces.v1.AppVersion], 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.ces.v1.AppVersion]: @googleapis_reference_link{google/cloud/ces/v1/app_version.proto#L58} + /// [google.cloud.ces.v1.ListAppVersionsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1527} + /// + // clang-format on + StreamRange ListAppVersions( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists all app versions in the given app. + /// + /// @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.ces.v1.ListAppVersionsRequest]. + /// 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.ces.v1.AppVersion], 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.ces.v1.AppVersion]: @googleapis_reference_link{google/cloud/ces/v1/app_version.proto#L58} + /// [google.cloud.ces.v1.ListAppVersionsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1527} + /// + // clang-format on + StreamRange ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified app version. + /// + /// @param name Required. The resource name of the app version to retrieve. + /// @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.ces.v1.AppVersion]) + /// 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.ces.v1.AppVersion]: @googleapis_reference_link{google/cloud/ces/v1/app_version.proto#L58} + /// [google.cloud.ces.v1.GetAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1571} + /// + // clang-format on + StatusOr GetAppVersion( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets details of the specified app version. + /// + /// @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.ces.v1.GetAppVersionRequest]. + /// 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.ces.v1.AppVersion]) + /// 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.ces.v1.AppVersion]: @googleapis_reference_link{google/cloud/ces/v1/app_version.proto#L58} + /// [google.cloud.ces.v1.GetAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1571} + /// + // clang-format on + StatusOr GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new app version in the given app. + /// + /// @param parent Required. The resource name of the app to create an app version in. + /// @param app_version Required. The app version to create. + /// @param app_version_id Optional. The ID to use for the app version, which will become the final + /// component of the app version's resource name. If not provided, a unique ID + /// will be automatically assigned for the app version. + /// @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.ces.v1.AppVersion]) + /// 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.ces.v1.AppVersion]: @googleapis_reference_link{google/cloud/ces/v1/app_version.proto#L58} + /// [google.cloud.ces.v1.CreateAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1597} + /// + // clang-format on + StatusOr CreateAppVersion( + std::string const& parent, + google::cloud::ces::v1::AppVersion const& app_version, + std::string const& app_version_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new app version in the given app. + /// + /// @param parent Required. The resource name of the app to create an app version in. + /// @param app_version Required. The app version to create. + /// @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.ces.v1.AppVersion]) + /// 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.ces.v1.AppVersion]: @googleapis_reference_link{google/cloud/ces/v1/app_version.proto#L58} + /// [google.cloud.ces.v1.CreateAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1597} + /// + // clang-format on + StatusOr CreateAppVersion( + std::string const& parent, + google::cloud::ces::v1::AppVersion const& app_version, Options opts = {}); + + // clang-format off + /// + /// Creates a new app version in the given app. + /// + /// @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.ces.v1.CreateAppVersionRequest]. + /// 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.ces.v1.AppVersion]) + /// 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.ces.v1.AppVersion]: @googleapis_reference_link{google/cloud/ces/v1/app_version.proto#L58} + /// [google.cloud.ces.v1.CreateAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1597} + /// + // clang-format on + StatusOr CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the specified app version. + /// + /// @param name Required. The resource name of the app version to delete. + /// @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.ces.v1.DeleteAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1581} + /// + // clang-format on + Status DeleteAppVersion(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the specified app version. + /// + /// @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.ces.v1.DeleteAppVersionRequest]. + /// 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.ces.v1.DeleteAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1581} + /// + // clang-format on + Status DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Restores the specified app version. + /// This will create a new app version from the current draft app and overwrite + /// the current draft with the specified app version. + /// + /// @param name Required. The resource name of the app version to restore. + /// @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.ces.v1.RestoreAppVersionResponse] 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.ces.v1.RestoreAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1617} + /// [google.cloud.ces.v1.RestoreAppVersionResponse]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1627} + /// + // clang-format on + future> + RestoreAppVersion(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief RestoreAppVersion + /// + /// 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 RestoreAppVersion( + NoAwaitTag, std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Restores the specified app version. + /// This will create a new app version from the current draft app and overwrite + /// the current draft with the specified app version. + /// + /// @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.ces.v1.RestoreAppVersionRequest]. + /// 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.ces.v1.RestoreAppVersionResponse] 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.ces.v1.RestoreAppVersionRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1617} + /// [google.cloud.ces.v1.RestoreAppVersionResponse]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1627} + /// + // clang-format on + future> + RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief RestoreAppVersion + /// + /// 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 RestoreAppVersion( + NoAwaitTag, + google::cloud::ces::v1::RestoreAppVersionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief RestoreAppVersion + /// + /// 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> + RestoreAppVersion(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Lists the changelogs of the specified app. + /// + /// @param parent Required. The resource name of the app to list changelogs from. + /// @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.ces.v1.Changelog], 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.ces.v1.Changelog]: @googleapis_reference_link{google/cloud/ces/v1/changelog.proto#L31} + /// [google.cloud.ces.v1.ListChangelogsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1631} + /// + // clang-format on + StreamRange ListChangelogs( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists the changelogs of the specified app. + /// + /// @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.ces.v1.ListChangelogsRequest]. + /// 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.ces.v1.Changelog], 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.ces.v1.Changelog]: @googleapis_reference_link{google/cloud/ces/v1/changelog.proto#L31} + /// [google.cloud.ces.v1.ListChangelogsRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1631} + /// + // clang-format on + StreamRange ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the specified changelog. + /// + /// @param name Required. The resource name of the changelog to retrieve. + /// @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.ces.v1.Changelog]) + /// 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.ces.v1.Changelog]: @googleapis_reference_link{google/cloud/ces/v1/changelog.proto#L31} + /// [google.cloud.ces.v1.GetChangelogRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1689} + /// + // clang-format on + StatusOr GetChangelog( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets the specified changelog. + /// + /// @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.ces.v1.GetChangelogRequest]. + /// 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.ces.v1.Changelog]) + /// 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.ces.v1.Changelog]: @googleapis_reference_link{google/cloud/ces/v1/changelog.proto#L31} + /// [google.cloud.ces.v1.GetChangelogRequest]: @googleapis_reference_link{google/cloud/ces/v1/agent_service.proto#L1689} + /// + // clang-format on + StatusOr GetChangelog( + google::cloud::ces::v1::GetChangelogRequest 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 ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CLIENT_H diff --git a/google/cloud/ces/v1/agent_connection.cc b/google/cloud/ces/v1/agent_connection.cc new file mode 100644 index 0000000000000..f25fda2932abd --- /dev/null +++ b/google/cloud/ces/v1/agent_connection.cc @@ -0,0 +1,473 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/agent_connection.h" +#include "google/cloud/ces/v1/agent_options.h" +#include "google/cloud/ces/v1/internal/agent_connection_impl.h" +#include "google/cloud/ces/v1/internal/agent_option_defaults.h" +#include "google/cloud/ces/v1/internal/agent_stub_factory.h" +#include "google/cloud/ces/v1/internal/agent_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AgentServiceConnection::~AgentServiceConnection() = default; + +StreamRange AgentServiceConnection::ListApps( + google::cloud::ces::v1:: + ListAppsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentServiceConnection::GetApp( + google::cloud::ces::v1::GetAppRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> AgentServiceConnection::CreateApp( + google::cloud::ces::v1::CreateAppRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr AgentServiceConnection::CreateApp( + NoAwaitTag, google::cloud::ces::v1::CreateAppRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> AgentServiceConnection::CreateApp( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr AgentServiceConnection::UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +AgentServiceConnection::DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr AgentServiceConnection::DeleteApp( + NoAwaitTag, google::cloud::ces::v1::DeleteAppRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +AgentServiceConnection::DeleteApp(google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +AgentServiceConnection::ExportApp( + google::cloud::ces::v1::ExportAppRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr AgentServiceConnection::ExportApp( + NoAwaitTag, google::cloud::ces::v1::ExportAppRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +AgentServiceConnection::ExportApp(google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +AgentServiceConnection::ImportApp( + google::cloud::ces::v1::ImportAppRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr AgentServiceConnection::ImportApp( + NoAwaitTag, google::cloud::ces::v1::ImportAppRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +AgentServiceConnection::ImportApp(google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange AgentServiceConnection::ListAgents( + google::cloud::ces::v1:: + ListAgentsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentServiceConnection::GetAgent( + google::cloud::ces::v1::GetAgentRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AgentServiceConnection::CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AgentServiceConnection::UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AgentServiceConnection::ListExamples( + google::cloud::ces::v1:: + ListExamplesRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentServiceConnection::GetExample( + google::cloud::ces::v1::GetExampleRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AgentServiceConnection::CreateExample( + google::cloud::ces::v1::CreateExampleRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AgentServiceConnection::UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange AgentServiceConnection::ListTools( + google::cloud::ces::v1:: + ListToolsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentServiceConnection::GetTool( + google::cloud::ces::v1::GetToolRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AgentServiceConnection::ListConversations( + google::cloud::ces::v1:: + ListConversationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AgentServiceConnection::GetConversation( + google::cloud::ces::v1::GetConversationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +AgentServiceConnection::BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +AgentServiceConnection::BatchDeleteConversations( + NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +AgentServiceConnection::BatchDeleteConversations( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr AgentServiceConnection::CreateTool( + google::cloud::ces::v1::CreateToolRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AgentServiceConnection::UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AgentServiceConnection::ListGuardrails( + google::cloud::ces::v1:: + ListGuardrailsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AgentServiceConnection::GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AgentServiceConnection::CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AgentServiceConnection::UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AgentServiceConnection::ListDeployments( + google::cloud::ces::v1:: + ListDeploymentsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AgentServiceConnection::GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AgentServiceConnection::CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AgentServiceConnection::UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AgentServiceConnection::ListToolsets( + google::cloud::ces::v1:: + ListToolsetsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentServiceConnection::GetToolset( + google::cloud::ces::v1::GetToolsetRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AgentServiceConnection::CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AgentServiceConnection::UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AgentServiceConnection::ListAppVersions( + google::cloud::ces::v1:: + ListAppVersionsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AgentServiceConnection::GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AgentServiceConnection::CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +AgentServiceConnection::RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +AgentServiceConnection::RestoreAppVersion( + NoAwaitTag, google::cloud::ces::v1::RestoreAppVersionRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +AgentServiceConnection::RestoreAppVersion( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +AgentServiceConnection::ListChangelogs( + google::cloud::ces::v1:: + ListChangelogsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AgentServiceConnection::GetChangelog( + google::cloud::ces::v1::GetChangelogRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AgentServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AgentServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AgentServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr MakeAgentServiceConnection( + Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = ces_v1_internal::AgentServiceDefaultOptions(std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = + ces_v1_internal::CreateDefaultAgentServiceStub(std::move(auth), options); + return ces_v1_internal::MakeAgentServiceTracingConnection( + std::make_shared( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/agent_connection.h b/google/cloud/ces/v1/agent_connection.h new file mode 100644 index 0000000000000..c21fa2640bf7b --- /dev/null +++ b/google/cloud/ces/v1/agent_connection.h @@ -0,0 +1,423 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CONNECTION_H + +#include "google/cloud/ces/v1/agent_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/agent_service.pb.h" +#include "google/cloud/ces/v1/internal/agent_retry_traits.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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `AgentServiceConnection`. +class AgentServiceRetryPolicy : 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 `AgentServiceConnection` 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 AgentServiceLimitedErrorCountRetryPolicy + : public AgentServiceRetryPolicy { + 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 AgentServiceLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + AgentServiceLimitedErrorCountRetryPolicy( + AgentServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : AgentServiceLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + AgentServiceLimitedErrorCountRetryPolicy( + AgentServiceLimitedErrorCountRetryPolicy const& rhs) noexcept + : AgentServiceLimitedErrorCountRetryPolicy(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 = AgentServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + ces_v1_internal::AgentServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `AgentServiceConnection` 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 AgentServiceLimitedTimeRetryPolicy : public AgentServiceRetryPolicy { + 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 AgentServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + AgentServiceLimitedTimeRetryPolicy( + AgentServiceLimitedTimeRetryPolicy&& rhs) noexcept + : AgentServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + AgentServiceLimitedTimeRetryPolicy( + AgentServiceLimitedTimeRetryPolicy const& rhs) noexcept + : AgentServiceLimitedTimeRetryPolicy(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 = AgentServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + ces_v1_internal::AgentServiceRetryTraits> + impl_; +}; + +/** + * The `AgentServiceConnection` object for `AgentServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `AgentServiceClient`. This allows users to inject custom behavior + * (e.g., with a Google Mock object) when writing tests that use objects of type + * `AgentServiceClient`. + * + * To create a concrete instance, see `MakeAgentServiceConnection()`. + * + * For mocking, see `ces_v1_mocks::MockAgentServiceConnection`. + */ +class AgentServiceConnection { + public: + virtual ~AgentServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StreamRange ListApps( + google::cloud::ces::v1::ListAppsRequest request); + + virtual StatusOr GetApp( + google::cloud::ces::v1::GetAppRequest const& request); + + virtual future> CreateApp( + google::cloud::ces::v1::CreateAppRequest const& request); + + virtual StatusOr CreateApp( + NoAwaitTag, google::cloud::ces::v1::CreateAppRequest const& request); + + virtual future> CreateApp( + google::longrunning::Operation const& operation); + + virtual StatusOr UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const& request); + + virtual future> DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const& request); + + virtual StatusOr DeleteApp( + NoAwaitTag, google::cloud::ces::v1::DeleteAppRequest const& request); + + virtual future> DeleteApp( + google::longrunning::Operation const& operation); + + virtual future> ExportApp( + google::cloud::ces::v1::ExportAppRequest const& request); + + virtual StatusOr ExportApp( + NoAwaitTag, google::cloud::ces::v1::ExportAppRequest const& request); + + virtual future> ExportApp( + google::longrunning::Operation const& operation); + + virtual future> ImportApp( + google::cloud::ces::v1::ImportAppRequest const& request); + + virtual StatusOr ImportApp( + NoAwaitTag, google::cloud::ces::v1::ImportAppRequest const& request); + + virtual future> ImportApp( + google::longrunning::Operation const& operation); + + virtual StreamRange ListAgents( + google::cloud::ces::v1::ListAgentsRequest request); + + virtual StatusOr GetAgent( + google::cloud::ces::v1::GetAgentRequest const& request); + + virtual StatusOr CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const& request); + + virtual StatusOr UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const& request); + + virtual Status DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const& request); + + virtual StreamRange ListExamples( + google::cloud::ces::v1::ListExamplesRequest request); + + virtual StatusOr GetExample( + google::cloud::ces::v1::GetExampleRequest const& request); + + virtual StatusOr CreateExample( + google::cloud::ces::v1::CreateExampleRequest const& request); + + virtual StatusOr UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const& request); + + virtual Status DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const& request); + + virtual StreamRange ListTools( + google::cloud::ces::v1::ListToolsRequest request); + + virtual StatusOr GetTool( + google::cloud::ces::v1::GetToolRequest const& request); + + virtual StreamRange ListConversations( + google::cloud::ces::v1::ListConversationsRequest request); + + virtual StatusOr GetConversation( + google::cloud::ces::v1::GetConversationRequest const& request); + + virtual Status DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const& request); + + virtual future< + StatusOr> + BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request); + + virtual StatusOr BatchDeleteConversations( + NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request); + + virtual future< + StatusOr> + BatchDeleteConversations(google::longrunning::Operation const& operation); + + virtual StatusOr CreateTool( + google::cloud::ces::v1::CreateToolRequest const& request); + + virtual StatusOr UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const& request); + + virtual Status DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const& request); + + virtual StreamRange ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest request); + + virtual StatusOr GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const& request); + + virtual StatusOr CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const& request); + + virtual StatusOr UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const& request); + + virtual Status DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const& request); + + virtual StreamRange ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest request); + + virtual StatusOr GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const& request); + + virtual StatusOr CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const& request); + + virtual StatusOr UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const& request); + + virtual Status DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const& request); + + virtual StreamRange ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest request); + + virtual StatusOr GetToolset( + google::cloud::ces::v1::GetToolsetRequest const& request); + + virtual StatusOr CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const& request); + + virtual StatusOr UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const& request); + + virtual Status DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const& request); + + virtual StreamRange ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest request); + + virtual StatusOr GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const& request); + + virtual StatusOr CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const& request); + + virtual Status DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const& request); + + virtual future> + RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const& request); + + virtual StatusOr RestoreAppVersion( + NoAwaitTag, + google::cloud::ces::v1::RestoreAppVersionRequest const& request); + + virtual future> + RestoreAppVersion(google::longrunning::Operation const& operation); + + virtual StreamRange ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest request); + + virtual StatusOr GetChangelog( + google::cloud::ces::v1::GetChangelogRequest 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 `AgentServiceConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of AgentServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `AgentServiceConnection`. Expected options are any of the types in + * the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::ces_v1::AgentServicePolicyOptionList` + * + * @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 `AgentServiceConnection` created by + * this function. + */ +std::shared_ptr MakeAgentServiceConnection( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CONNECTION_H diff --git a/google/cloud/ces/v1/agent_connection_idempotency_policy.cc b/google/cloud/ces/v1/agent_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..19fc2844fdc84 --- /dev/null +++ b/google/cloud/ces/v1/agent_connection_idempotency_policy.cc @@ -0,0 +1,315 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/agent_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +AgentServiceConnectionIdempotencyPolicy:: + ~AgentServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +AgentServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListApps( + google::cloud::ces::v1::ListAppsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetApp( + google::cloud::ces::v1::GetAppRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CreateApp( + google::cloud::ces::v1::CreateAppRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ExportApp( + google::cloud::ces::v1::ExportAppRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ImportApp( + google::cloud::ces::v1::ImportAppRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListAgents( + google::cloud::ces::v1::ListAgentsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetAgent( + google::cloud::ces::v1::GetAgentRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListExamples( + google::cloud::ces::v1::ListExamplesRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetExample( + google::cloud::ces::v1::GetExampleRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CreateExample( + google::cloud::ces::v1::CreateExampleRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListTools( + google::cloud::ces::v1::ListToolsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetTool( + google::cloud::ces::v1::GetToolRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListConversations( + google::cloud::ces::v1::ListConversationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetConversation( + google::cloud::ces::v1::GetConversationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CreateTool( + google::cloud::ces::v1::CreateToolRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetToolset( + google::cloud::ces::v1::GetToolsetRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetChangelog( + google::cloud::ces::v1::GetChangelogRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency AgentServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultAgentServiceConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/agent_connection_idempotency_policy.h b/google/cloud/ces/v1/agent_connection_idempotency_policy.h new file mode 100644 index 0000000000000..d8012d45f3499 --- /dev/null +++ b/google/cloud/ces/v1/agent_connection_idempotency_policy.h @@ -0,0 +1,213 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/ces/v1/agent_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AgentServiceConnectionIdempotencyPolicy { + public: + virtual ~AgentServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() + const; + + virtual google::cloud::Idempotency ListApps( + google::cloud::ces::v1::ListAppsRequest request); + + virtual google::cloud::Idempotency GetApp( + google::cloud::ces::v1::GetAppRequest const& request); + + virtual google::cloud::Idempotency CreateApp( + google::cloud::ces::v1::CreateAppRequest const& request); + + virtual google::cloud::Idempotency UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const& request); + + virtual google::cloud::Idempotency DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const& request); + + virtual google::cloud::Idempotency ExportApp( + google::cloud::ces::v1::ExportAppRequest const& request); + + virtual google::cloud::Idempotency ImportApp( + google::cloud::ces::v1::ImportAppRequest const& request); + + virtual google::cloud::Idempotency ListAgents( + google::cloud::ces::v1::ListAgentsRequest request); + + virtual google::cloud::Idempotency GetAgent( + google::cloud::ces::v1::GetAgentRequest const& request); + + virtual google::cloud::Idempotency CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const& request); + + virtual google::cloud::Idempotency UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const& request); + + virtual google::cloud::Idempotency DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const& request); + + virtual google::cloud::Idempotency ListExamples( + google::cloud::ces::v1::ListExamplesRequest request); + + virtual google::cloud::Idempotency GetExample( + google::cloud::ces::v1::GetExampleRequest const& request); + + virtual google::cloud::Idempotency CreateExample( + google::cloud::ces::v1::CreateExampleRequest const& request); + + virtual google::cloud::Idempotency UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const& request); + + virtual google::cloud::Idempotency DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const& request); + + virtual google::cloud::Idempotency ListTools( + google::cloud::ces::v1::ListToolsRequest request); + + virtual google::cloud::Idempotency GetTool( + google::cloud::ces::v1::GetToolRequest const& request); + + virtual google::cloud::Idempotency ListConversations( + google::cloud::ces::v1::ListConversationsRequest request); + + virtual google::cloud::Idempotency GetConversation( + google::cloud::ces::v1::GetConversationRequest const& request); + + virtual google::cloud::Idempotency DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const& request); + + virtual google::cloud::Idempotency BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request); + + virtual google::cloud::Idempotency CreateTool( + google::cloud::ces::v1::CreateToolRequest const& request); + + virtual google::cloud::Idempotency UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const& request); + + virtual google::cloud::Idempotency DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const& request); + + virtual google::cloud::Idempotency ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest request); + + virtual google::cloud::Idempotency GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const& request); + + virtual google::cloud::Idempotency CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const& request); + + virtual google::cloud::Idempotency UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const& request); + + virtual google::cloud::Idempotency DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const& request); + + virtual google::cloud::Idempotency ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest request); + + virtual google::cloud::Idempotency GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const& request); + + virtual google::cloud::Idempotency CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const& request); + + virtual google::cloud::Idempotency UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const& request); + + virtual google::cloud::Idempotency DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const& request); + + virtual google::cloud::Idempotency ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest request); + + virtual google::cloud::Idempotency GetToolset( + google::cloud::ces::v1::GetToolsetRequest const& request); + + virtual google::cloud::Idempotency CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const& request); + + virtual google::cloud::Idempotency UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const& request); + + virtual google::cloud::Idempotency DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const& request); + + virtual google::cloud::Idempotency ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest request); + + virtual google::cloud::Idempotency GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const& request); + + virtual google::cloud::Idempotency CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const& request); + + virtual google::cloud::Idempotency DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const& request); + + virtual google::cloud::Idempotency RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const& request); + + virtual google::cloud::Idempotency ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest request); + + virtual google::cloud::Idempotency GetChangelog( + google::cloud::ces::v1::GetChangelogRequest 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 +MakeDefaultAgentServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/ces/v1/agent_options.h b/google/cloud/ces/v1/agent_options.h new file mode 100644 index 0000000000000..bba4b38c1073b --- /dev/null +++ b/google/cloud/ces/v1/agent_options.h @@ -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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_OPTIONS_H + +#include "google/cloud/ces/v1/agent_connection.h" +#include "google/cloud/ces/v1/agent_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-ces-options + */ +struct AgentServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-ces-options + */ +struct AgentServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-ces-options + */ +struct AgentServiceConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the long-running operations + * polling policy. + * + * @ingroup google-cloud-ces-options + */ +struct AgentServicePollingPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to AgentService. + * + * @ingroup google-cloud-ces-options + */ +using AgentServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_AGENT_OPTIONS_H diff --git a/google/cloud/ces/v1/internal/agent_auth_decorator.cc b/google/cloud/ces/v1/internal/agent_auth_decorator.cc new file mode 100644 index 0000000000000..b93ef66c78491 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_auth_decorator.cc @@ -0,0 +1,642 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_auth_decorator.h" +#include "google/cloud/ces/v1/agent_service.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AgentServiceAuth::AgentServiceAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr AgentServiceAuth::ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListApps(context, options, request); +} + +StatusOr AgentServiceAuth::GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetApp(context, options, request); +} + +future> +AgentServiceAuth::AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest 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->AsyncCreateApp(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr AgentServiceAuth::CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateApp(context, options, request); +} + +StatusOr AgentServiceAuth::UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateApp(context, options, request); +} + +future> +AgentServiceAuth::AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest 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->AsyncDeleteApp(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr AgentServiceAuth::DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteApp(context, options, request); +} + +future> +AgentServiceAuth::AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest 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->AsyncExportApp(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr AgentServiceAuth::ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ExportApp(context, options, request); +} + +future> +AgentServiceAuth::AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest 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->AsyncImportApp(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr AgentServiceAuth::ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ImportApp(context, options, request); +} + +StatusOr +AgentServiceAuth::ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListAgents(context, options, request); +} + +StatusOr AgentServiceAuth::GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetAgent(context, options, request); +} + +StatusOr AgentServiceAuth::CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateAgent(context, options, request); +} + +StatusOr AgentServiceAuth::UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateAgent(context, options, request); +} + +Status AgentServiceAuth::DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteAgent(context, options, request); +} + +StatusOr +AgentServiceAuth::ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListExamples(context, options, request); +} + +StatusOr AgentServiceAuth::GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetExample(context, options, request); +} + +StatusOr AgentServiceAuth::CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateExample(context, options, request); +} + +StatusOr AgentServiceAuth::UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateExample(context, options, request); +} + +Status AgentServiceAuth::DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteExample(context, options, request); +} + +StatusOr AgentServiceAuth::ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListTools(context, options, request); +} + +StatusOr AgentServiceAuth::GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetTool(context, options, request); +} + +StatusOr +AgentServiceAuth::ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListConversations(context, options, request); +} + +StatusOr +AgentServiceAuth::GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetConversation(context, options, request); +} + +Status AgentServiceAuth::DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteConversation(context, options, request); +} + +future> +AgentServiceAuth::AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest 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->AsyncBatchDeleteConversations( + cq, *std::move(context), std::move(options), request); + }); +} + +StatusOr +AgentServiceAuth::BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->BatchDeleteConversations(context, options, request); +} + +StatusOr AgentServiceAuth::CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateTool(context, options, request); +} + +StatusOr AgentServiceAuth::UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateTool(context, options, request); +} + +Status AgentServiceAuth::DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteTool(context, options, request); +} + +StatusOr +AgentServiceAuth::ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListGuardrails(context, options, request); +} + +StatusOr AgentServiceAuth::GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetGuardrail(context, options, request); +} + +StatusOr AgentServiceAuth::CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateGuardrail(context, options, request); +} + +StatusOr AgentServiceAuth::UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateGuardrail(context, options, request); +} + +Status AgentServiceAuth::DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteGuardrail(context, options, request); +} + +StatusOr +AgentServiceAuth::ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListDeployments(context, options, request); +} + +StatusOr AgentServiceAuth::GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetDeployment(context, options, request); +} + +StatusOr AgentServiceAuth::CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateDeployment(context, options, request); +} + +StatusOr AgentServiceAuth::UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateDeployment(context, options, request); +} + +Status AgentServiceAuth::DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteDeployment(context, options, request); +} + +StatusOr +AgentServiceAuth::ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListToolsets(context, options, request); +} + +StatusOr AgentServiceAuth::GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetToolset(context, options, request); +} + +StatusOr AgentServiceAuth::CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateToolset(context, options, request); +} + +StatusOr AgentServiceAuth::UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateToolset(context, options, request); +} + +Status AgentServiceAuth::DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteToolset(context, options, request); +} + +StatusOr +AgentServiceAuth::ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListAppVersions(context, options, request); +} + +StatusOr AgentServiceAuth::GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetAppVersion(context, options, request); +} + +StatusOr AgentServiceAuth::CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateAppVersion(context, options, request); +} + +Status AgentServiceAuth::DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteAppVersion(context, options, request); +} + +future> +AgentServiceAuth::AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest 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->AsyncRestoreAppVersion(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr AgentServiceAuth::RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->RestoreAppVersion(context, options, request); +} + +StatusOr +AgentServiceAuth::ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListChangelogs(context, options, request); +} + +StatusOr AgentServiceAuth::GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetChangelog(context, options, request); +} + +StatusOr +AgentServiceAuth::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 AgentServiceAuth::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 +AgentServiceAuth::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 AgentServiceAuth::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 AgentServiceAuth::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 AgentServiceAuth::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> +AgentServiceAuth::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 AgentServiceAuth::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/agent_auth_decorator.h b/google/cloud/ces/v1/internal/agent_auth_decorator.h new file mode 100644 index 0000000000000..b2b7ba3fc74a2 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_auth_decorator.h @@ -0,0 +1,325 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_AUTH_DECORATOR_H + +#include "google/cloud/ces/v1/internal/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AgentServiceAuth : public AgentServiceStub { + public: + ~AgentServiceAuth() override = default; + AgentServiceAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) override; + + StatusOr GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) override; + + future> AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) override; + + future> AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + StatusOr DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + future> AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + StatusOr ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + future> AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) override; + + StatusOr GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) override; + + StatusOr CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) override; + + StatusOr UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) override; + + Status DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) override; + + StatusOr ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) override; + + StatusOr GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) override; + + StatusOr CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) override; + + StatusOr UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) override; + + Status DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) override; + + StatusOr ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) override; + + StatusOr GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) override; + + StatusOr ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) override; + + StatusOr GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) override; + + Status DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) + override; + + future> + AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) override; + + StatusOr UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) override; + + Status DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) override; + + StatusOr ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) override; + + StatusOr GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) override; + + StatusOr CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) override; + + StatusOr UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) override; + + Status DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) override; + + StatusOr ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) override; + + StatusOr GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) override; + + StatusOr CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) override; + + StatusOr UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) override; + + Status DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) override; + + StatusOr ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) override; + + StatusOr GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) override; + + StatusOr CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) override; + + StatusOr UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) override; + + Status DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) override; + + StatusOr ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) override; + + StatusOr GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) override; + + StatusOr CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) override; + + Status DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) override; + + future> AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) override; + + StatusOr GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_AUTH_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/agent_connection_impl.cc b/google/cloud/ces/v1/internal/agent_connection_impl.cc new file mode 100644 index 0000000000000..d7b6b6546a397 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_connection_impl.cc @@ -0,0 +1,1482 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_connection_impl.h" +#include "google/cloud/ces/v1/internal/agent_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 ces_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 + +AgentServiceConnectionImpl::AgentServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions(std::move(options), + AgentServiceConnection::options())) {} + +StreamRange AgentServiceConnectionImpl::ListApps( + google::cloud::ces::v1::ListAppsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListApps(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::ces::v1::ListAppsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) { + return stub->ListApps(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListAppsResponse r) { + std::vector result(r.apps().size()); + auto& messages = *r.mutable_apps(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AgentServiceConnectionImpl::GetApp( + google::cloud::ces::v1::GetAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetApp(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) { + return stub_->GetApp(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::CreateApp( + google::cloud::ces::v1::CreateAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = idempotency_policy(*current)->CreateApp(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::ces::v1::App>( + background_->cq(), current, std::move(request_copy), + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) { + return stub->AsyncCreateApp(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::ces::v1::App>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr AgentServiceConnectionImpl::CreateApp( + NoAwaitTag, google::cloud::ces::v1::CreateAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateApp(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppRequest const& request) { + return stub_->CreateApp(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::CreateApp( + 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 CreateApp", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::ces::v1::App>( + 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::ces::v1::App>, + polling_policy(*current), __func__); +} + +StatusOr AgentServiceConnectionImpl::UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateApp(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) { + return stub_->UpdateApp(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = idempotency_policy(*current)->DeleteApp(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::ces::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::ces::v1::DeleteAppRequest const& request) { + return stub->AsyncDeleteApp(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::ces::v1::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr AgentServiceConnectionImpl::DeleteApp( + NoAwaitTag, google::cloud::ces::v1::DeleteAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteApp(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + return stub_->DeleteApp(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::DeleteApp( + 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 DeleteApp", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::ces::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::ces::v1::OperationMetadata>, + polling_policy(*current), __func__); +} + +future> +AgentServiceConnectionImpl::ExportApp( + google::cloud::ces::v1::ExportAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = idempotency_policy(*current)->ExportApp(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::ces::v1::ExportAppResponse>( + background_->cq(), current, std::move(request_copy), + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) { + return stub->AsyncExportApp(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::ces::v1::ExportAppResponse>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr AgentServiceConnectionImpl::ExportApp( + NoAwaitTag, google::cloud::ces::v1::ExportAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->ExportApp(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExportAppRequest const& request) { + return stub_->ExportApp(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::ExportApp( + 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 ExportApp", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::ces::v1::ExportAppResponse>( + 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::ces::v1::ExportAppResponse>, + polling_policy(*current), __func__); +} + +future> +AgentServiceConnectionImpl::ImportApp( + google::cloud::ces::v1::ImportAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = idempotency_policy(*current)->ImportApp(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::ces::v1::ImportAppResponse>( + background_->cq(), current, std::move(request_copy), + [stub = stub_](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) { + return stub->AsyncImportApp(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::ces::v1::ImportAppResponse>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr AgentServiceConnectionImpl::ImportApp( + NoAwaitTag, google::cloud::ces::v1::ImportAppRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->ImportApp(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ImportAppRequest const& request) { + return stub_->ImportApp(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::ImportApp( + 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 ImportApp", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::ces::v1::ImportAppResponse>( + 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::ces::v1::ImportAppResponse>, + polling_policy(*current), __func__); +} + +StreamRange +AgentServiceConnectionImpl::ListAgents( + google::cloud::ces::v1::ListAgentsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListAgents(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::ces::v1::ListAgentsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) { + return stub->ListAgents(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListAgentsResponse r) { + std::vector result(r.agents().size()); + auto& messages = *r.mutable_agents(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AgentServiceConnectionImpl::GetAgent( + google::cloud::ces::v1::GetAgentRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetAgent(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) { + return stub_->GetAgent(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AgentServiceConnectionImpl::CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateAgent(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) { + return stub_->CreateAgent(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AgentServiceConnectionImpl::UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateAgent(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) { + return stub_->UpdateAgent(context, options, request); + }, + *current, request, __func__); +} + +Status AgentServiceConnectionImpl::DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteAgent(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) { + return stub_->DeleteAgent(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +AgentServiceConnectionImpl::ListExamples( + google::cloud::ces::v1::ListExamplesRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListExamples(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::ces::v1::ListExamplesRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) { + return stub->ListExamples(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListExamplesResponse r) { + std::vector result( + r.examples().size()); + auto& messages = *r.mutable_examples(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AgentServiceConnectionImpl::GetExample( + google::cloud::ces::v1::GetExampleRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetExample(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) { + return stub_->GetExample(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::CreateExample( + google::cloud::ces::v1::CreateExampleRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateExample(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) { + return stub_->CreateExample(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateExample(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) { + return stub_->UpdateExample(context, options, request); + }, + *current, request, __func__); +} + +Status AgentServiceConnectionImpl::DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteExample(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) { + return stub_->DeleteExample(context, options, request); + }, + *current, request, __func__); +} + +StreamRange AgentServiceConnectionImpl::ListTools( + google::cloud::ces::v1::ListToolsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListTools(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::ces::v1::ListToolsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) { + return stub->ListTools(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListToolsResponse r) { + std::vector result(r.tools().size()); + auto& messages = *r.mutable_tools(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AgentServiceConnectionImpl::GetTool( + google::cloud::ces::v1::GetToolRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetTool(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) { + return stub_->GetTool(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +AgentServiceConnectionImpl::ListConversations( + google::cloud::ces::v1::ListConversationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListConversations(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::ces::v1::ListConversationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& + request) { + return stub->ListConversations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListConversationsResponse r) { + std::vector result( + r.conversations().size()); + auto& messages = *r.mutable_conversations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AgentServiceConnectionImpl::GetConversation( + google::cloud::ces::v1::GetConversationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetConversation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) { + return stub_->GetConversation(context, options, request); + }, + *current, request, __func__); +} + +Status AgentServiceConnectionImpl::DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteConversation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) { + return stub_->DeleteConversation(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->BatchDeleteConversations(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::ces::v1::BatchDeleteConversationsResponse>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& + request) { + return stub->AsyncBatchDeleteConversations(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::ces::v1::BatchDeleteConversationsResponse>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +AgentServiceConnectionImpl::BatchDeleteConversations( + NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->BatchDeleteConversations(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& + request) { + return stub_->BatchDeleteConversations(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::BatchDeleteConversations( + 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 BatchDeleteConversations", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::ces::v1::BatchDeleteConversationsResponse>( + 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::ces::v1::BatchDeleteConversationsResponse>, + polling_policy(*current), __func__); +} + +StatusOr AgentServiceConnectionImpl::CreateTool( + google::cloud::ces::v1::CreateToolRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateTool(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) { + return stub_->CreateTool(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AgentServiceConnectionImpl::UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateTool(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) { + return stub_->UpdateTool(context, options, request); + }, + *current, request, __func__); +} + +Status AgentServiceConnectionImpl::DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteTool(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) { + return stub_->DeleteTool(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +AgentServiceConnectionImpl::ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListGuardrails(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::ces::v1::ListGuardrailsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) { + return stub->ListGuardrails(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListGuardrailsResponse r) { + std::vector result( + r.guardrails().size()); + auto& messages = *r.mutable_guardrails(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AgentServiceConnectionImpl::GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetGuardrail(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) { + return stub_->GetGuardrail(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateGuardrail(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + return stub_->CreateGuardrail(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateGuardrail(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + return stub_->UpdateGuardrail(context, options, request); + }, + *current, request, __func__); +} + +Status AgentServiceConnectionImpl::DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteGuardrail(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + return stub_->DeleteGuardrail(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +AgentServiceConnectionImpl::ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListDeployments(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::ces::v1::ListDeploymentsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) { + return stub->ListDeployments(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListDeploymentsResponse r) { + std::vector result( + r.deployments().size()); + auto& messages = *r.mutable_deployments(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AgentServiceConnectionImpl::GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetDeployment(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) { + return stub_->GetDeployment(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateDeployment(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + return stub_->CreateDeployment(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateDeployment(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + return stub_->UpdateDeployment(context, options, request); + }, + *current, request, __func__); +} + +Status AgentServiceConnectionImpl::DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteDeployment(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + return stub_->DeleteDeployment(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +AgentServiceConnectionImpl::ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListToolsets(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::ces::v1::ListToolsetsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) { + return stub->ListToolsets(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListToolsetsResponse r) { + std::vector result( + r.toolsets().size()); + auto& messages = *r.mutable_toolsets(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AgentServiceConnectionImpl::GetToolset( + google::cloud::ces::v1::GetToolsetRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetToolset(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) { + return stub_->GetToolset(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateToolset(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) { + return stub_->CreateToolset(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateToolset(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + return stub_->UpdateToolset(context, options, request); + }, + *current, request, __func__); +} + +Status AgentServiceConnectionImpl::DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteToolset(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + return stub_->DeleteToolset(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +AgentServiceConnectionImpl::ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListAppVersions(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::ces::v1::ListAppVersionsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) { + return stub->ListAppVersions(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListAppVersionsResponse r) { + std::vector result( + r.app_versions().size()); + auto& messages = *r.mutable_app_versions(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AgentServiceConnectionImpl::GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetAppVersion(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) { + return stub_->GetAppVersion(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AgentServiceConnectionImpl::CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateAppVersion(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + return stub_->CreateAppVersion(context, options, request); + }, + *current, request, __func__); +} + +Status AgentServiceConnectionImpl::DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteAppVersion(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + return stub_->DeleteAppVersion(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->RestoreAppVersion(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::ces::v1::RestoreAppVersionResponse>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + return stub->AsyncRestoreAppVersion(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::ces::v1::RestoreAppVersionResponse>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +AgentServiceConnectionImpl::RestoreAppVersion( + NoAwaitTag, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->RestoreAppVersion(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + return stub_->RestoreAppVersion(context, options, request); + }, + *current, request, __func__); +} + +future> +AgentServiceConnectionImpl::RestoreAppVersion( + 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 RestoreAppVersion", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::ces::v1::RestoreAppVersionResponse>( + 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::ces::v1::RestoreAppVersionResponse>, + polling_policy(*current), __func__); +} + +StreamRange +AgentServiceConnectionImpl::ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListChangelogs(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::ces::v1::ListChangelogsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) { + return stub->ListChangelogs(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ces::v1::ListChangelogsResponse r) { + std::vector result( + r.changelogs().size()); + auto& messages = *r.mutable_changelogs(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AgentServiceConnectionImpl::GetChangelog( + google::cloud::ces::v1::GetChangelogRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetChangelog(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest const& request) { + return stub_->GetChangelog(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +AgentServiceConnectionImpl::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 +AgentServiceConnectionImpl::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 +AgentServiceConnectionImpl::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 +AgentServiceConnectionImpl::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 AgentServiceConnectionImpl::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 AgentServiceConnectionImpl::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 ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/agent_connection_impl.h b/google/cloud/ces/v1/internal/agent_connection_impl.h new file mode 100644 index 0000000000000..08a73eabf8bc5 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_connection_impl.h @@ -0,0 +1,274 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_CONNECTION_IMPL_H + +#include "google/cloud/ces/v1/agent_connection.h" +#include "google/cloud/ces/v1/agent_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/agent_options.h" +#include "google/cloud/ces/v1/internal/agent_retry_traits.h" +#include "google/cloud/ces/v1/internal/agent_stub.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AgentServiceConnectionImpl : public ces_v1::AgentServiceConnection { + public: + ~AgentServiceConnectionImpl() override = default; + + AgentServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options); + + Options options() override { return options_; } + + StreamRange ListApps( + google::cloud::ces::v1::ListAppsRequest request) override; + + StatusOr GetApp( + google::cloud::ces::v1::GetAppRequest const& request) override; + + future> CreateApp( + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr CreateApp( + NoAwaitTag, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + future> CreateApp( + google::longrunning::Operation const& operation) override; + + StatusOr UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const& request) override; + + future> DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + StatusOr DeleteApp( + NoAwaitTag, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + future> DeleteApp( + google::longrunning::Operation const& operation) override; + + future> ExportApp( + google::cloud::ces::v1::ExportAppRequest const& request) override; + + StatusOr ExportApp( + NoAwaitTag, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + future> ExportApp( + google::longrunning::Operation const& operation) override; + + future> ImportApp( + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ImportApp( + NoAwaitTag, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + future> ImportApp( + google::longrunning::Operation const& operation) override; + + StreamRange ListAgents( + google::cloud::ces::v1::ListAgentsRequest request) override; + + StatusOr GetAgent( + google::cloud::ces::v1::GetAgentRequest const& request) override; + + StatusOr CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const& request) override; + + StatusOr UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const& request) override; + + Status DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const& request) override; + + StreamRange ListExamples( + google::cloud::ces::v1::ListExamplesRequest request) override; + + StatusOr GetExample( + google::cloud::ces::v1::GetExampleRequest const& request) override; + + StatusOr CreateExample( + google::cloud::ces::v1::CreateExampleRequest const& request) override; + + StatusOr UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const& request) override; + + Status DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const& request) override; + + StreamRange ListTools( + google::cloud::ces::v1::ListToolsRequest request) override; + + StatusOr GetTool( + google::cloud::ces::v1::GetToolRequest const& request) override; + + StreamRange ListConversations( + google::cloud::ces::v1::ListConversationsRequest request) override; + + StatusOr GetConversation( + google::cloud::ces::v1::GetConversationRequest const& request) override; + + Status DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const& request) + override; + + future> + BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr BatchDeleteConversations( + NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + future> + BatchDeleteConversations( + google::longrunning::Operation const& operation) override; + + StatusOr CreateTool( + google::cloud::ces::v1::CreateToolRequest const& request) override; + + StatusOr UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const& request) override; + + Status DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const& request) override; + + StreamRange ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest request) override; + + StatusOr GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const& request) override; + + StatusOr CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const& request) override; + + StatusOr UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const& request) override; + + Status DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const& request) override; + + StreamRange ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest request) override; + + StatusOr GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const& request) override; + + StatusOr CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const& request) override; + + StatusOr UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const& request) override; + + Status DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const& request) override; + + StreamRange ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest request) override; + + StatusOr GetToolset( + google::cloud::ces::v1::GetToolsetRequest const& request) override; + + StatusOr CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const& request) override; + + StatusOr UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const& request) override; + + Status DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const& request) override; + + StreamRange ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest request) override; + + StatusOr GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const& request) override; + + StatusOr CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const& request) override; + + Status DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const& request) override; + + future> + RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr RestoreAppVersion( + NoAwaitTag, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + future> + RestoreAppVersion(google::longrunning::Operation const& operation) override; + + StreamRange ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest request) override; + + StatusOr GetChangelog( + google::cloud::ces::v1::GetChangelogRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_CONNECTION_IMPL_H diff --git a/google/cloud/ces/v1/internal/agent_logging_decorator.cc b/google/cloud/ces/v1/internal/agent_logging_decorator.cc new file mode 100644 index 0000000000000..ca1afdf420ec2 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_logging_decorator.cc @@ -0,0 +1,804 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_logging_decorator.h" +#include "google/cloud/ces/v1/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AgentServiceLogging::AgentServiceLogging( + std::shared_ptr child, TracingOptions tracing_options, + std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +StatusOr +AgentServiceLogging::ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) { + return child_->ListApps(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) { + return child_->GetApp(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +AgentServiceLogging::AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) { + return child_->AsyncCreateApp(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr AgentServiceLogging::CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppRequest const& request) { + return child_->CreateApp(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) { + return child_->UpdateApp(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +AgentServiceLogging::AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + return child_->AsyncDeleteApp(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr AgentServiceLogging::DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + return child_->DeleteApp(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +AgentServiceLogging::AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) { + return child_->AsyncExportApp(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr AgentServiceLogging::ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExportAppRequest const& request) { + return child_->ExportApp(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +AgentServiceLogging::AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) { + return child_->AsyncImportApp(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr AgentServiceLogging::ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ImportAppRequest const& request) { + return child_->ImportApp(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) { + return child_->ListAgents(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) { + return child_->GetAgent(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) { + return child_->CreateAgent(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) { + return child_->UpdateAgent(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentServiceLogging::DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) { + return child_->DeleteAgent(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) { + return child_->ListExamples(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) { + return child_->GetExample(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) { + return child_->CreateExample(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) { + return child_->UpdateExample(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentServiceLogging::DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) { + return child_->DeleteExample(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) { + return child_->ListTools(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) { + return child_->GetTool(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) { + return child_->ListConversations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) { + return child_->GetConversation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentServiceLogging::DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) { + return child_->DeleteConversation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +AgentServiceLogging::AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& + request) { + return child_->AsyncBatchDeleteConversations( + cq, std::move(context), std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +AgentServiceLogging::BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& + request) { + return child_->BatchDeleteConversations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) { + return child_->CreateTool(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) { + return child_->UpdateTool(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentServiceLogging::DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) { + return child_->DeleteTool(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) { + return child_->ListGuardrails(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) { + return child_->GetGuardrail(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + return child_->CreateGuardrail(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + return child_->UpdateGuardrail(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentServiceLogging::DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + return child_->DeleteGuardrail(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) { + return child_->ListDeployments(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) { + return child_->GetDeployment(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + return child_->CreateDeployment(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + return child_->UpdateDeployment(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentServiceLogging::DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + return child_->DeleteDeployment(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) { + return child_->ListToolsets(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) { + return child_->GetToolset(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) { + return child_->CreateToolset(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + return child_->UpdateToolset(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentServiceLogging::DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + return child_->DeleteToolset(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) { + return child_->ListAppVersions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) { + return child_->GetAppVersion(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + return child_->CreateAppVersion(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +Status AgentServiceLogging::DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + return child_->DeleteAppVersion(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +AgentServiceLogging::AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + return child_->AsyncRestoreAppVersion(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr AgentServiceLogging::RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + return child_->RestoreAppVersion(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) { + return child_->ListChangelogs(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentServiceLogging::GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest const& request) { + return child_->GetChangelog(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AgentServiceLogging::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 AgentServiceLogging::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 +AgentServiceLogging::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 AgentServiceLogging::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 AgentServiceLogging::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 AgentServiceLogging::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> +AgentServiceLogging::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 AgentServiceLogging::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/agent_logging_decorator.h b/google/cloud/ces/v1/internal/agent_logging_decorator.h new file mode 100644 index 0000000000000..2e9863287534d --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_logging_decorator.h @@ -0,0 +1,325 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_LOGGING_DECORATOR_H + +#include "google/cloud/ces/v1/internal/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AgentServiceLogging : public AgentServiceStub { + public: + ~AgentServiceLogging() override = default; + AgentServiceLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const& components); + + StatusOr ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) override; + + StatusOr GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) override; + + future> AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) override; + + future> AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + StatusOr DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + future> AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + StatusOr ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + future> AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) override; + + StatusOr GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) override; + + StatusOr CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) override; + + StatusOr UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) override; + + Status DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) override; + + StatusOr ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) override; + + StatusOr GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) override; + + StatusOr CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) override; + + StatusOr UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) override; + + Status DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) override; + + StatusOr ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) override; + + StatusOr GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) override; + + StatusOr ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) override; + + StatusOr GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) override; + + Status DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) + override; + + future> + AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) override; + + StatusOr UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) override; + + Status DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) override; + + StatusOr ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) override; + + StatusOr GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) override; + + StatusOr CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) override; + + StatusOr UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) override; + + Status DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) override; + + StatusOr ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) override; + + StatusOr GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) override; + + StatusOr CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) override; + + StatusOr UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) override; + + Status DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) override; + + StatusOr ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) override; + + StatusOr GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) override; + + StatusOr CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) override; + + StatusOr UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) override; + + Status DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) override; + + StatusOr ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) override; + + StatusOr GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) override; + + StatusOr CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) override; + + Status DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) override; + + future> AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) override; + + StatusOr GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest 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_; +}; // AgentServiceLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_LOGGING_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/agent_metadata_decorator.cc b/google/cloud/ces/v1/internal/agent_metadata_decorator.cc new file mode 100644 index 0000000000000..f84bc7f3eddc7 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_metadata_decorator.cc @@ -0,0 +1,625 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_metadata_decorator.h" +#include "google/cloud/ces/v1/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AgentServiceMetadata::AgentServiceMetadata( + 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 +AgentServiceMetadata::ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListApps(context, options, request); +} + +StatusOr AgentServiceMetadata::GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetApp(context, options, request); +} + +future> +AgentServiceMetadata::AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AsyncCreateApp(cq, std::move(context), std::move(options), + request); +} + +StatusOr AgentServiceMetadata::CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateApp(context, options, request); +} + +StatusOr AgentServiceMetadata::UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("app.name=", internal::UrlEncode(request.app().name()))); + return child_->UpdateApp(context, options, request); +} + +future> +AgentServiceMetadata::AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncDeleteApp(cq, std::move(context), std::move(options), + request); +} + +StatusOr AgentServiceMetadata::DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteApp(context, options, request); +} + +future> +AgentServiceMetadata::AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncExportApp(cq, std::move(context), std::move(options), + request); +} + +StatusOr AgentServiceMetadata::ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ExportApp(context, options, request); +} + +future> +AgentServiceMetadata::AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AsyncImportApp(cq, std::move(context), std::move(options), + request); +} + +StatusOr AgentServiceMetadata::ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ImportApp(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListAgents(context, options, request); +} + +StatusOr AgentServiceMetadata::GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetAgent(context, options, request); +} + +StatusOr AgentServiceMetadata::CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateAgent(context, options, request); +} + +StatusOr AgentServiceMetadata::UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("agent.name=", internal::UrlEncode(request.agent().name()))); + return child_->UpdateAgent(context, options, request); +} + +Status AgentServiceMetadata::DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteAgent(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListExamples(context, options, request); +} + +StatusOr AgentServiceMetadata::GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetExample(context, options, request); +} + +StatusOr AgentServiceMetadata::CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateExample(context, options, request); +} + +StatusOr AgentServiceMetadata::UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) { + SetMetadata(context, options, + absl::StrCat("example.name=", + internal::UrlEncode(request.example().name()))); + return child_->UpdateExample(context, options, request); +} + +Status AgentServiceMetadata::DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteExample(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListTools(context, options, request); +} + +StatusOr AgentServiceMetadata::GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetTool(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListConversations(context, options, request); +} + +StatusOr +AgentServiceMetadata::GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetConversation(context, options, request); +} + +Status AgentServiceMetadata::DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteConversation(context, options, request); +} + +future> +AgentServiceMetadata::AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AsyncBatchDeleteConversations(cq, std::move(context), + std::move(options), request); +} + +StatusOr +AgentServiceMetadata::BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->BatchDeleteConversations(context, options, request); +} + +StatusOr AgentServiceMetadata::CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateTool(context, options, request); +} + +StatusOr AgentServiceMetadata::UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("tool.name=", internal::UrlEncode(request.tool().name()))); + return child_->UpdateTool(context, options, request); +} + +Status AgentServiceMetadata::DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteTool(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListGuardrails(context, options, request); +} + +StatusOr AgentServiceMetadata::GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetGuardrail(context, options, request); +} + +StatusOr +AgentServiceMetadata::CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateGuardrail(context, options, request); +} + +StatusOr +AgentServiceMetadata::UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + SetMetadata(context, options, + absl::StrCat("guardrail.name=", + internal::UrlEncode(request.guardrail().name()))); + return child_->UpdateGuardrail(context, options, request); +} + +Status AgentServiceMetadata::DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteGuardrail(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListDeployments(context, options, request); +} + +StatusOr +AgentServiceMetadata::GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetDeployment(context, options, request); +} + +StatusOr +AgentServiceMetadata::CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateDeployment(context, options, request); +} + +StatusOr +AgentServiceMetadata::UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + SetMetadata(context, options, + absl::StrCat("deployment.name=", + internal::UrlEncode(request.deployment().name()))); + return child_->UpdateDeployment(context, options, request); +} + +Status AgentServiceMetadata::DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteDeployment(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListToolsets(context, options, request); +} + +StatusOr AgentServiceMetadata::GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetToolset(context, options, request); +} + +StatusOr AgentServiceMetadata::CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateToolset(context, options, request); +} + +StatusOr AgentServiceMetadata::UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + SetMetadata(context, options, + absl::StrCat("toolset.name=", + internal::UrlEncode(request.toolset().name()))); + return child_->UpdateToolset(context, options, request); +} + +Status AgentServiceMetadata::DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteToolset(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListAppVersions(context, options, request); +} + +StatusOr +AgentServiceMetadata::GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetAppVersion(context, options, request); +} + +StatusOr +AgentServiceMetadata::CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateAppVersion(context, options, request); +} + +Status AgentServiceMetadata::DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteAppVersion(context, options, request); +} + +future> +AgentServiceMetadata::AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncRestoreAppVersion(cq, std::move(context), + std::move(options), request); +} + +StatusOr +AgentServiceMetadata::RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->RestoreAppVersion(context, options, request); +} + +StatusOr +AgentServiceMetadata::ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListChangelogs(context, options, request); +} + +StatusOr AgentServiceMetadata::GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetChangelog(context, options, request); +} + +StatusOr +AgentServiceMetadata::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 AgentServiceMetadata::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 +AgentServiceMetadata::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 AgentServiceMetadata::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 AgentServiceMetadata::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 AgentServiceMetadata::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> +AgentServiceMetadata::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 AgentServiceMetadata::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 AgentServiceMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void AgentServiceMetadata::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/agent_metadata_decorator.h b/google/cloud/ces/v1/internal/agent_metadata_decorator.h new file mode 100644 index 0000000000000..4a81aa926429b --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_metadata_decorator.h @@ -0,0 +1,330 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_METADATA_DECORATOR_H + +#include "google/cloud/ces/v1/internal/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AgentServiceMetadata : public AgentServiceStub { + public: + ~AgentServiceMetadata() override = default; + AgentServiceMetadata(std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + StatusOr ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) override; + + StatusOr GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) override; + + future> AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) override; + + future> AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + StatusOr DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + future> AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + StatusOr ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + future> AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) override; + + StatusOr GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) override; + + StatusOr CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) override; + + StatusOr UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) override; + + Status DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) override; + + StatusOr ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) override; + + StatusOr GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) override; + + StatusOr CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) override; + + StatusOr UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) override; + + Status DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) override; + + StatusOr ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) override; + + StatusOr GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) override; + + StatusOr ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) override; + + StatusOr GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) override; + + Status DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) + override; + + future> + AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) override; + + StatusOr UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) override; + + Status DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) override; + + StatusOr ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) override; + + StatusOr GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) override; + + StatusOr CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) override; + + StatusOr UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) override; + + Status DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) override; + + StatusOr ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) override; + + StatusOr GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) override; + + StatusOr CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) override; + + StatusOr UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) override; + + Status DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) override; + + StatusOr ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) override; + + StatusOr GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) override; + + StatusOr CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) override; + + StatusOr UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) override; + + Status DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) override; + + StatusOr ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) override; + + StatusOr GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) override; + + StatusOr CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) override; + + Status DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) override; + + future> AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) override; + + StatusOr GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_METADATA_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/agent_option_defaults.cc b/google/cloud/ces/v1/internal/agent_option_defaults.cc new file mode 100644 index 0000000000000..aac8b15f28571 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_option_defaults.cc @@ -0,0 +1,74 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_option_defaults.h" +#include "google/cloud/ces/v1/agent_connection.h" +#include "google/cloud/ces/v1/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options AgentServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_AGENT_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_AGENT_SERVICE_AUTHORITY", "ces.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + ces_v1::AgentServiceLimitedTimeRetryPolicy(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( + options.get()->clone(), + ExponentialBackoffPolicy(std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling) + .clone()) + .clone()); + } + if (!options.has()) { + options.set( + ces_v1::MakeDefaultAgentServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/agent_option_defaults.h b/google/cloud/ces/v1/internal/agent_option_defaults.h new file mode 100644 index 0000000000000..cd2949cb2a312 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options AgentServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_OPTION_DEFAULTS_H diff --git a/google/cloud/ces/v1/internal/agent_retry_traits.h b/google/cloud/ces/v1/internal/agent_retry_traits.h new file mode 100644 index 0000000000000..27023a2c840f9 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct AgentServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_RETRY_TRAITS_H diff --git a/google/cloud/ces/v1/internal/agent_sources.cc b/google/cloud/ces/v1/internal/agent_sources.cc new file mode 100644 index 0000000000000..d1630bf1dbb49 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_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/ces/v1/agent_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/ces/v1/agent_client.cc" +#include "google/cloud/ces/v1/agent_connection.cc" +#include "google/cloud/ces/v1/agent_connection_idempotency_policy.cc" +#include "google/cloud/ces/v1/internal/agent_auth_decorator.cc" +#include "google/cloud/ces/v1/internal/agent_connection_impl.cc" +#include "google/cloud/ces/v1/internal/agent_logging_decorator.cc" +#include "google/cloud/ces/v1/internal/agent_metadata_decorator.cc" +#include "google/cloud/ces/v1/internal/agent_option_defaults.cc" +#include "google/cloud/ces/v1/internal/agent_stub.cc" +#include "google/cloud/ces/v1/internal/agent_stub_factory.cc" +#include "google/cloud/ces/v1/internal/agent_tracing_connection.cc" +#include "google/cloud/ces/v1/internal/agent_tracing_stub.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/ces/v1/internal/agent_stub.cc b/google/cloud/ces/v1/internal/agent_stub.cc new file mode 100644 index 0000000000000..99cdce61f8adf --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_stub.cc @@ -0,0 +1,810 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_stub.h" +#include "google/cloud/ces/v1/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AgentServiceStub::~AgentServiceStub() = default; + +StatusOr +DefaultAgentServiceStub::ListApps( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListAppsRequest const& request) { + google::cloud::ces::v1::ListAppsResponse response; + auto status = grpc_stub_->ListApps(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::GetApp( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetAppRequest const& request) { + google::cloud::ces::v1::App response; + auto status = grpc_stub_->GetApp(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultAgentServiceStub::AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::ces::v1::CreateAppRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::cloud::ces::v1::CreateAppRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncCreateApp(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr DefaultAgentServiceStub::CreateApp( + grpc::ClientContext& context, Options, + google::cloud::ces::v1::CreateAppRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->CreateApp(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::UpdateApp( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::UpdateAppRequest const& request) { + google::cloud::ces::v1::App response; + auto status = grpc_stub_->UpdateApp(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultAgentServiceStub::AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::ces::v1::DeleteAppRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::cloud::ces::v1::DeleteAppRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncDeleteApp(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr DefaultAgentServiceStub::DeleteApp( + grpc::ClientContext& context, Options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->DeleteApp(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultAgentServiceStub::AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::ces::v1::ExportAppRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::cloud::ces::v1::ExportAppRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncExportApp(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr DefaultAgentServiceStub::ExportApp( + grpc::ClientContext& context, Options, + google::cloud::ces::v1::ExportAppRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->ExportApp(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultAgentServiceStub::AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::ces::v1::ImportAppRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::cloud::ces::v1::ImportAppRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncImportApp(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr DefaultAgentServiceStub::ImportApp( + grpc::ClientContext& context, Options, + google::cloud::ces::v1::ImportAppRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->ImportApp(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::ListAgents( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListAgentsRequest const& request) { + google::cloud::ces::v1::ListAgentsResponse response; + auto status = grpc_stub_->ListAgents(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::GetAgent( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetAgentRequest const& request) { + google::cloud::ces::v1::Agent response; + auto status = grpc_stub_->GetAgent(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::CreateAgent( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::CreateAgentRequest const& request) { + google::cloud::ces::v1::Agent response; + auto status = grpc_stub_->CreateAgent(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::UpdateAgent( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::UpdateAgentRequest const& request) { + google::cloud::ces::v1::Agent response; + auto status = grpc_stub_->UpdateAgent(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentServiceStub::DeleteAgent( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::DeleteAgentRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteAgent(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultAgentServiceStub::ListExamples( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListExamplesRequest const& request) { + google::cloud::ces::v1::ListExamplesResponse response; + auto status = grpc_stub_->ListExamples(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::GetExample( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetExampleRequest const& request) { + google::cloud::ces::v1::Example response; + auto status = grpc_stub_->GetExample(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::CreateExample( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::CreateExampleRequest const& request) { + google::cloud::ces::v1::Example response; + auto status = grpc_stub_->CreateExample(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::UpdateExample( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::UpdateExampleRequest const& request) { + google::cloud::ces::v1::Example response; + auto status = grpc_stub_->UpdateExample(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentServiceStub::DeleteExample( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::DeleteExampleRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteExample(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultAgentServiceStub::ListTools( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListToolsRequest const& request) { + google::cloud::ces::v1::ListToolsResponse response; + auto status = grpc_stub_->ListTools(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::GetTool( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetToolRequest const& request) { + google::cloud::ces::v1::Tool response; + auto status = grpc_stub_->GetTool(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::ListConversations( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListConversationsRequest const& request) { + google::cloud::ces::v1::ListConversationsResponse response; + auto status = grpc_stub_->ListConversations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::GetConversation( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetConversationRequest const& request) { + google::cloud::ces::v1::Conversation response; + auto status = grpc_stub_->GetConversation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentServiceStub::DeleteConversation( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::DeleteConversationRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteConversation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +future> +DefaultAgentServiceStub::AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::ces::v1::BatchDeleteConversationsRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncBatchDeleteConversations(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultAgentServiceStub::BatchDeleteConversations( + grpc::ClientContext& context, Options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + google::longrunning::Operation response; + auto status = + grpc_stub_->BatchDeleteConversations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::CreateTool( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::CreateToolRequest const& request) { + google::cloud::ces::v1::Tool response; + auto status = grpc_stub_->CreateTool(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::UpdateTool( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::UpdateToolRequest const& request) { + google::cloud::ces::v1::Tool response; + auto status = grpc_stub_->UpdateTool(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentServiceStub::DeleteTool( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::DeleteToolRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteTool(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultAgentServiceStub::ListGuardrails( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListGuardrailsRequest const& request) { + google::cloud::ces::v1::ListGuardrailsResponse response; + auto status = grpc_stub_->ListGuardrails(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::GetGuardrail( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetGuardrailRequest const& request) { + google::cloud::ces::v1::Guardrail response; + auto status = grpc_stub_->GetGuardrail(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::CreateGuardrail( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + google::cloud::ces::v1::Guardrail response; + auto status = grpc_stub_->CreateGuardrail(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::UpdateGuardrail( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + google::cloud::ces::v1::Guardrail response; + auto status = grpc_stub_->UpdateGuardrail(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentServiceStub::DeleteGuardrail( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteGuardrail(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultAgentServiceStub::ListDeployments( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListDeploymentsRequest const& request) { + google::cloud::ces::v1::ListDeploymentsResponse response; + auto status = grpc_stub_->ListDeployments(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::GetDeployment( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetDeploymentRequest const& request) { + google::cloud::ces::v1::Deployment response; + auto status = grpc_stub_->GetDeployment(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::CreateDeployment( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + google::cloud::ces::v1::Deployment response; + auto status = grpc_stub_->CreateDeployment(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::UpdateDeployment( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + google::cloud::ces::v1::Deployment response; + auto status = grpc_stub_->UpdateDeployment(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentServiceStub::DeleteDeployment( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteDeployment(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultAgentServiceStub::ListToolsets( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListToolsetsRequest const& request) { + google::cloud::ces::v1::ListToolsetsResponse response; + auto status = grpc_stub_->ListToolsets(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentServiceStub::GetToolset( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetToolsetRequest const& request) { + google::cloud::ces::v1::Toolset response; + auto status = grpc_stub_->GetToolset(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::CreateToolset( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::CreateToolsetRequest const& request) { + google::cloud::ces::v1::Toolset response; + auto status = grpc_stub_->CreateToolset(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::UpdateToolset( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + google::cloud::ces::v1::Toolset response; + auto status = grpc_stub_->UpdateToolset(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentServiceStub::DeleteToolset( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteToolset(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultAgentServiceStub::ListAppVersions( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListAppVersionsRequest const& request) { + google::cloud::ces::v1::ListAppVersionsResponse response; + auto status = grpc_stub_->ListAppVersions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::GetAppVersion( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetAppVersionRequest const& request) { + google::cloud::ces::v1::AppVersion response; + auto status = grpc_stub_->GetAppVersion(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::CreateAppVersion( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + google::cloud::ces::v1::AppVersion response; + auto status = grpc_stub_->CreateAppVersion(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAgentServiceStub::DeleteAppVersion( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteAppVersion(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +future> +DefaultAgentServiceStub::AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::ces::v1::RestoreAppVersionRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::ces::v1::RestoreAppVersionRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncRestoreAppVersion(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultAgentServiceStub::RestoreAppVersion( + grpc::ClientContext& context, Options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->RestoreAppVersion(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::ListChangelogs( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ListChangelogsRequest const& request) { + google::cloud::ces::v1::ListChangelogsResponse response; + auto status = grpc_stub_->ListChangelogs(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::GetChangelog( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GetChangelogRequest const& request) { + google::cloud::ces::v1::Changelog response; + auto status = grpc_stub_->GetChangelog(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAgentServiceStub::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 +DefaultAgentServiceStub::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 +DefaultAgentServiceStub::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 DefaultAgentServiceStub::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 DefaultAgentServiceStub::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 DefaultAgentServiceStub::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> +DefaultAgentServiceStub::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 DefaultAgentServiceStub::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/agent_stub.h b/google/cloud/ces/v1/internal/agent_stub.h new file mode 100644 index 0000000000000..8c5207a40f662 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_stub.h @@ -0,0 +1,617 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_STUB_H + +#include "google/cloud/ces/v1/agent_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AgentServiceStub { + public: + virtual ~AgentServiceStub() = 0; + + virtual StatusOr ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) = 0; + + virtual StatusOr GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) = 0; + + virtual future> AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) = 0; + + virtual StatusOr CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) = 0; + + virtual StatusOr UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) = 0; + + virtual future> AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) = 0; + + virtual StatusOr DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) = 0; + + virtual future> AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) = 0; + + virtual StatusOr ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) = 0; + + virtual future> AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) = 0; + + virtual StatusOr ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) = 0; + + virtual StatusOr ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) = 0; + + virtual StatusOr GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) = 0; + + virtual StatusOr CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) = 0; + + virtual StatusOr UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) = 0; + + virtual Status DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) = 0; + + virtual StatusOr ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) = 0; + + virtual StatusOr GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) = 0; + + virtual StatusOr CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) = 0; + + virtual StatusOr UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) = 0; + + virtual Status DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) = 0; + + virtual StatusOr ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) = 0; + + virtual StatusOr GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) = 0; + + virtual StatusOr + ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) = 0; + + virtual StatusOr GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) = 0; + + virtual Status DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) = 0; + + virtual future> + AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& + request) = 0; + + virtual StatusOr BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& + request) = 0; + + virtual StatusOr CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) = 0; + + virtual StatusOr UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) = 0; + + virtual Status DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) = 0; + + virtual StatusOr + ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) = 0; + + virtual StatusOr GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) = 0; + + virtual StatusOr CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) = 0; + + virtual StatusOr UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) = 0; + + virtual Status DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) = 0; + + virtual StatusOr + ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) = 0; + + virtual StatusOr GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) = 0; + + virtual StatusOr CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) = 0; + + virtual StatusOr UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) = 0; + + virtual Status DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) = 0; + + virtual StatusOr ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) = 0; + + virtual StatusOr GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) = 0; + + virtual StatusOr CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) = 0; + + virtual StatusOr UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) = 0; + + virtual Status DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) = 0; + + virtual StatusOr + ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) = 0; + + virtual StatusOr GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) = 0; + + virtual StatusOr CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) = 0; + + virtual Status DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) = 0; + + virtual future> + AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) = 0; + + virtual StatusOr RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) = 0; + + virtual StatusOr + ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) = 0; + + virtual StatusOr GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest 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 DefaultAgentServiceStub : public AgentServiceStub { + public: + DefaultAgentServiceStub( + std::unique_ptr + 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 ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) override; + + StatusOr GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) override; + + future> AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) override; + + future> AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + StatusOr DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + future> AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + StatusOr ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + future> AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) override; + + StatusOr GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) override; + + StatusOr CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) override; + + StatusOr UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) override; + + Status DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) override; + + StatusOr ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) override; + + StatusOr GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) override; + + StatusOr CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) override; + + StatusOr UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) override; + + Status DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) override; + + StatusOr ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) override; + + StatusOr GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) override; + + StatusOr ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) override; + + StatusOr GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) override; + + Status DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) + override; + + future> + AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) override; + + StatusOr UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) override; + + Status DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) override; + + StatusOr ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) override; + + StatusOr GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) override; + + StatusOr CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) override; + + StatusOr UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) override; + + Status DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) override; + + StatusOr ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) override; + + StatusOr GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) override; + + StatusOr CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) override; + + StatusOr UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) override; + + Status DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) override; + + StatusOr ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) override; + + StatusOr GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) override; + + StatusOr CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) override; + + StatusOr UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) override; + + Status DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) override; + + StatusOr ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) override; + + StatusOr GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) override; + + StatusOr CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) override; + + Status DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) override; + + future> AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) override; + + StatusOr GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest 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 + grpc_stub_; + std::unique_ptr + locations_stub_; + std::unique_ptr + operations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_STUB_H diff --git a/google/cloud/ces/v1/internal/agent_stub_factory.cc b/google/cloud/ces/v1/internal/agent_stub_factory.cc new file mode 100644 index 0000000000000..220a701bb2631 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_stub_factory.cc @@ -0,0 +1,81 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_stub_factory.h" +#include "google/cloud/ces/v1/agent_service.grpc.pb.h" +#include "google/cloud/ces/v1/internal/agent_auth_decorator.h" +#include "google/cloud/ces/v1/internal/agent_logging_decorator.h" +#include "google/cloud/ces/v1/internal/agent_metadata_decorator.h" +#include "google/cloud/ces/v1/internal/agent_stub.h" +#include "google/cloud/ces/v1/internal/agent_tracing_stub.h" +#include "google/cloud/location/locations.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultAgentServiceStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::ces::v1::AgentService::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 = MakeAgentServiceTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/agent_stub_factory.h b/google/cloud/ces/v1/internal/agent_stub_factory.h new file mode 100644 index 0000000000000..49a58078a406f --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_STUB_FACTORY_H + +#include "google/cloud/ces/v1/internal/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultAgentServiceStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_STUB_FACTORY_H diff --git a/google/cloud/ces/v1/internal/agent_tracing_connection.cc b/google/cloud/ces/v1/internal/agent_tracing_connection.cc new file mode 100644 index 0000000000000..89a78efa5e366 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_tracing_connection.cc @@ -0,0 +1,629 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AgentServiceTracingConnection::AgentServiceTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StreamRange +AgentServiceTracingConnection::ListApps( + google::cloud::ces::v1::ListAppsRequest request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ListApps"); + internal::OTelScope scope(span); + auto sr = child_->ListApps(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr AgentServiceTracingConnection::GetApp( + google::cloud::ces::v1::GetAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::GetApp"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetApp(request)); +} + +future> +AgentServiceTracingConnection::CreateApp( + google::cloud::ces::v1::CreateAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::CreateApp"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateApp(request)); +} + +StatusOr +AgentServiceTracingConnection::CreateApp( + NoAwaitTag, google::cloud::ces::v1::CreateAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::CreateApp"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->CreateApp(NoAwaitTag{}, request)); +} + +future> +AgentServiceTracingConnection::CreateApp( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::CreateApp"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateApp(operation)); +} + +StatusOr AgentServiceTracingConnection::UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::UpdateApp"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateApp(request)); +} + +future> +AgentServiceTracingConnection::DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteApp"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteApp(request)); +} + +StatusOr +AgentServiceTracingConnection::DeleteApp( + NoAwaitTag, google::cloud::ces::v1::DeleteAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteApp"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->DeleteApp(NoAwaitTag{}, request)); +} + +future> +AgentServiceTracingConnection::DeleteApp( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteApp"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteApp(operation)); +} + +future> +AgentServiceTracingConnection::ExportApp( + google::cloud::ces::v1::ExportAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ExportApp"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->ExportApp(request)); +} + +StatusOr +AgentServiceTracingConnection::ExportApp( + NoAwaitTag, google::cloud::ces::v1::ExportAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ExportApp"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->ExportApp(NoAwaitTag{}, request)); +} + +future> +AgentServiceTracingConnection::ExportApp( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ExportApp"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->ExportApp(operation)); +} + +future> +AgentServiceTracingConnection::ImportApp( + google::cloud::ces::v1::ImportAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ImportApp"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->ImportApp(request)); +} + +StatusOr +AgentServiceTracingConnection::ImportApp( + NoAwaitTag, google::cloud::ces::v1::ImportAppRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ImportApp"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->ImportApp(NoAwaitTag{}, request)); +} + +future> +AgentServiceTracingConnection::ImportApp( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ImportApp"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->ImportApp(operation)); +} + +StreamRange +AgentServiceTracingConnection::ListAgents( + google::cloud::ces::v1::ListAgentsRequest request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ListAgents"); + internal::OTelScope scope(span); + auto sr = child_->ListAgents(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr AgentServiceTracingConnection::GetAgent( + google::cloud::ces::v1::GetAgentRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::GetAgent"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetAgent(request)); +} + +StatusOr +AgentServiceTracingConnection::CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::CreateAgent"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateAgent(request)); +} + +StatusOr +AgentServiceTracingConnection::UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::UpdateAgent"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateAgent(request)); +} + +Status AgentServiceTracingConnection::DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteAgent"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteAgent(request)); +} + +StreamRange +AgentServiceTracingConnection::ListExamples( + google::cloud::ces::v1::ListExamplesRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListExamples"); + internal::OTelScope scope(span); + auto sr = child_->ListExamples(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetExample( + google::cloud::ces::v1::GetExampleRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::GetExample"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetExample(request)); +} + +StatusOr +AgentServiceTracingConnection::CreateExample( + google::cloud::ces::v1::CreateExampleRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::CreateExample"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateExample(request)); +} + +StatusOr +AgentServiceTracingConnection::UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::UpdateExample"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateExample(request)); +} + +Status AgentServiceTracingConnection::DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteExample"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteExample(request)); +} + +StreamRange +AgentServiceTracingConnection::ListTools( + google::cloud::ces::v1::ListToolsRequest request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::ListTools"); + internal::OTelScope scope(span); + auto sr = child_->ListTools(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr AgentServiceTracingConnection::GetTool( + google::cloud::ces::v1::GetToolRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::GetTool"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetTool(request)); +} + +StreamRange +AgentServiceTracingConnection::ListConversations( + google::cloud::ces::v1::ListConversationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListConversations"); + internal::OTelScope scope(span); + auto sr = child_->ListConversations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetConversation( + google::cloud::ces::v1::GetConversationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::GetConversation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetConversation(request)); +} + +Status AgentServiceTracingConnection::DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteConversation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteConversation(request)); +} + +future> +AgentServiceTracingConnection::BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + auto span = internal::MakeSpan( + "ces_v1::AgentServiceConnection::BatchDeleteConversations"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->BatchDeleteConversations(request)); +} + +StatusOr +AgentServiceTracingConnection::BatchDeleteConversations( + NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + auto span = internal::MakeSpan( + "ces_v1::AgentServiceConnection::BatchDeleteConversations"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan( + *span, child_->BatchDeleteConversations(NoAwaitTag{}, request)); +} + +future> +AgentServiceTracingConnection::BatchDeleteConversations( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "ces_v1::AgentServiceConnection::BatchDeleteConversations"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->BatchDeleteConversations(operation)); +} + +StatusOr +AgentServiceTracingConnection::CreateTool( + google::cloud::ces::v1::CreateToolRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::CreateTool"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateTool(request)); +} + +StatusOr +AgentServiceTracingConnection::UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::UpdateTool"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateTool(request)); +} + +Status AgentServiceTracingConnection::DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteTool"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteTool(request)); +} + +StreamRange +AgentServiceTracingConnection::ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListGuardrails"); + internal::OTelScope scope(span); + auto sr = child_->ListGuardrails(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::GetGuardrail"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetGuardrail(request)); +} + +StatusOr +AgentServiceTracingConnection::CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::CreateGuardrail"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateGuardrail(request)); +} + +StatusOr +AgentServiceTracingConnection::UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::UpdateGuardrail"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateGuardrail(request)); +} + +Status AgentServiceTracingConnection::DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteGuardrail"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteGuardrail(request)); +} + +StreamRange +AgentServiceTracingConnection::ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListDeployments"); + internal::OTelScope scope(span); + auto sr = child_->ListDeployments(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::GetDeployment"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetDeployment(request)); +} + +StatusOr +AgentServiceTracingConnection::CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::CreateDeployment"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateDeployment(request)); +} + +StatusOr +AgentServiceTracingConnection::UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::UpdateDeployment"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateDeployment(request)); +} + +Status AgentServiceTracingConnection::DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteDeployment"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteDeployment(request)); +} + +StreamRange +AgentServiceTracingConnection::ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListToolsets"); + internal::OTelScope scope(span); + auto sr = child_->ListToolsets(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetToolset( + google::cloud::ces::v1::GetToolsetRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::GetToolset"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetToolset(request)); +} + +StatusOr +AgentServiceTracingConnection::CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::CreateToolset"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateToolset(request)); +} + +StatusOr +AgentServiceTracingConnection::UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::UpdateToolset"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateToolset(request)); +} + +Status AgentServiceTracingConnection::DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteToolset"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteToolset(request)); +} + +StreamRange +AgentServiceTracingConnection::ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListAppVersions"); + internal::OTelScope scope(span); + auto sr = child_->ListAppVersions(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::GetAppVersion"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetAppVersion(request)); +} + +StatusOr +AgentServiceTracingConnection::CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::CreateAppVersion"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateAppVersion(request)); +} + +Status AgentServiceTracingConnection::DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteAppVersion"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteAppVersion(request)); +} + +future> +AgentServiceTracingConnection::RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::RestoreAppVersion"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->RestoreAppVersion(request)); +} + +StatusOr +AgentServiceTracingConnection::RestoreAppVersion( + NoAwaitTag, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::RestoreAppVersion"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->RestoreAppVersion(NoAwaitTag{}, request)); +} + +future> +AgentServiceTracingConnection::RestoreAppVersion( + google::longrunning::Operation const& operation) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::RestoreAppVersion"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->RestoreAppVersion(operation)); +} + +StreamRange +AgentServiceTracingConnection::ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListChangelogs"); + internal::OTelScope scope(span); + auto sr = child_->ListChangelogs(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetChangelog( + google::cloud::ces::v1::GetChangelogRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::GetChangelog"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetChangelog(request)); +} + +StreamRange +AgentServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("ces_v1::AgentServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +AgentServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status AgentServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status AgentServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::AgentServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr +MakeAgentServiceTracingConnection( + 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 ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/agent_tracing_connection.h b/google/cloud/ces/v1/internal/agent_tracing_connection.h new file mode 100644 index 0000000000000..fc5718d537281 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_tracing_connection.h @@ -0,0 +1,269 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_TRACING_CONNECTION_H + +#include "google/cloud/ces/v1/agent_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AgentServiceTracingConnection : public ces_v1::AgentServiceConnection { + public: + ~AgentServiceTracingConnection() override = default; + + explicit AgentServiceTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StreamRange ListApps( + google::cloud::ces::v1::ListAppsRequest request) override; + + StatusOr GetApp( + google::cloud::ces::v1::GetAppRequest const& request) override; + + future> CreateApp( + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr CreateApp( + NoAwaitTag, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + future> CreateApp( + google::longrunning::Operation const& operation) override; + + StatusOr UpdateApp( + google::cloud::ces::v1::UpdateAppRequest const& request) override; + + future> DeleteApp( + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + StatusOr DeleteApp( + NoAwaitTag, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + future> DeleteApp( + google::longrunning::Operation const& operation) override; + + future> ExportApp( + google::cloud::ces::v1::ExportAppRequest const& request) override; + + StatusOr ExportApp( + NoAwaitTag, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + future> ExportApp( + google::longrunning::Operation const& operation) override; + + future> ImportApp( + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ImportApp( + NoAwaitTag, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + future> ImportApp( + google::longrunning::Operation const& operation) override; + + StreamRange ListAgents( + google::cloud::ces::v1::ListAgentsRequest request) override; + + StatusOr GetAgent( + google::cloud::ces::v1::GetAgentRequest const& request) override; + + StatusOr CreateAgent( + google::cloud::ces::v1::CreateAgentRequest const& request) override; + + StatusOr UpdateAgent( + google::cloud::ces::v1::UpdateAgentRequest const& request) override; + + Status DeleteAgent( + google::cloud::ces::v1::DeleteAgentRequest const& request) override; + + StreamRange ListExamples( + google::cloud::ces::v1::ListExamplesRequest request) override; + + StatusOr GetExample( + google::cloud::ces::v1::GetExampleRequest const& request) override; + + StatusOr CreateExample( + google::cloud::ces::v1::CreateExampleRequest const& request) override; + + StatusOr UpdateExample( + google::cloud::ces::v1::UpdateExampleRequest const& request) override; + + Status DeleteExample( + google::cloud::ces::v1::DeleteExampleRequest const& request) override; + + StreamRange ListTools( + google::cloud::ces::v1::ListToolsRequest request) override; + + StatusOr GetTool( + google::cloud::ces::v1::GetToolRequest const& request) override; + + StreamRange ListConversations( + google::cloud::ces::v1::ListConversationsRequest request) override; + + StatusOr GetConversation( + google::cloud::ces::v1::GetConversationRequest const& request) override; + + Status DeleteConversation( + google::cloud::ces::v1::DeleteConversationRequest const& request) + override; + + future> + BatchDeleteConversations( + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr BatchDeleteConversations( + NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + future> + BatchDeleteConversations( + google::longrunning::Operation const& operation) override; + + StatusOr CreateTool( + google::cloud::ces::v1::CreateToolRequest const& request) override; + + StatusOr UpdateTool( + google::cloud::ces::v1::UpdateToolRequest const& request) override; + + Status DeleteTool( + google::cloud::ces::v1::DeleteToolRequest const& request) override; + + StreamRange ListGuardrails( + google::cloud::ces::v1::ListGuardrailsRequest request) override; + + StatusOr GetGuardrail( + google::cloud::ces::v1::GetGuardrailRequest const& request) override; + + StatusOr CreateGuardrail( + google::cloud::ces::v1::CreateGuardrailRequest const& request) override; + + StatusOr UpdateGuardrail( + google::cloud::ces::v1::UpdateGuardrailRequest const& request) override; + + Status DeleteGuardrail( + google::cloud::ces::v1::DeleteGuardrailRequest const& request) override; + + StreamRange ListDeployments( + google::cloud::ces::v1::ListDeploymentsRequest request) override; + + StatusOr GetDeployment( + google::cloud::ces::v1::GetDeploymentRequest const& request) override; + + StatusOr CreateDeployment( + google::cloud::ces::v1::CreateDeploymentRequest const& request) override; + + StatusOr UpdateDeployment( + google::cloud::ces::v1::UpdateDeploymentRequest const& request) override; + + Status DeleteDeployment( + google::cloud::ces::v1::DeleteDeploymentRequest const& request) override; + + StreamRange ListToolsets( + google::cloud::ces::v1::ListToolsetsRequest request) override; + + StatusOr GetToolset( + google::cloud::ces::v1::GetToolsetRequest const& request) override; + + StatusOr CreateToolset( + google::cloud::ces::v1::CreateToolsetRequest const& request) override; + + StatusOr UpdateToolset( + google::cloud::ces::v1::UpdateToolsetRequest const& request) override; + + Status DeleteToolset( + google::cloud::ces::v1::DeleteToolsetRequest const& request) override; + + StreamRange ListAppVersions( + google::cloud::ces::v1::ListAppVersionsRequest request) override; + + StatusOr GetAppVersion( + google::cloud::ces::v1::GetAppVersionRequest const& request) override; + + StatusOr CreateAppVersion( + google::cloud::ces::v1::CreateAppVersionRequest const& request) override; + + Status DeleteAppVersion( + google::cloud::ces::v1::DeleteAppVersionRequest const& request) override; + + future> + RestoreAppVersion( + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr RestoreAppVersion( + NoAwaitTag, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + future> + RestoreAppVersion(google::longrunning::Operation const& operation) override; + + StreamRange ListChangelogs( + google::cloud::ces::v1::ListChangelogsRequest request) override; + + StatusOr GetChangelog( + google::cloud::ces::v1::GetChangelogRequest 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 +MakeAgentServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_TRACING_CONNECTION_H diff --git a/google/cloud/ces/v1/internal/agent_tracing_stub.cc b/google/cloud/ces/v1/internal/agent_tracing_stub.cc new file mode 100644 index 0000000000000..81d390fc75329 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_tracing_stub.cc @@ -0,0 +1,784 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/internal/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AgentServiceTracingStub::AgentServiceTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +StatusOr +AgentServiceTracingStub::ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "ListApps"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListApps(context, options, request)); +} + +StatusOr AgentServiceTracingStub::GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "GetApp"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetApp(context, options, request)); +} + +future> +AgentServiceTracingStub::AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "CreateApp"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncCreateApp(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr AgentServiceTracingStub::CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "CreateApp"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateApp(context, options, request)); +} + +StatusOr AgentServiceTracingStub::UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "UpdateApp"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateApp(context, options, request)); +} + +future> +AgentServiceTracingStub::AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "DeleteApp"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncDeleteApp(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr AgentServiceTracingStub::DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "DeleteApp"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteApp(context, options, request)); +} + +future> +AgentServiceTracingStub::AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "ExportApp"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncExportApp(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr AgentServiceTracingStub::ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "ExportApp"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ExportApp(context, options, request)); +} + +future> +AgentServiceTracingStub::AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "ImportApp"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncImportApp(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr AgentServiceTracingStub::ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "ImportApp"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ImportApp(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "ListAgents"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListAgents(context, options, request)); +} + +StatusOr AgentServiceTracingStub::GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "GetAgent"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetAgent(context, options, request)); +} + +StatusOr AgentServiceTracingStub::CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "CreateAgent"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateAgent(context, options, request)); +} + +StatusOr AgentServiceTracingStub::UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "UpdateAgent"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateAgent(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "DeleteAgent"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteAgent(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListExamples"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListExamples(context, options, request)); +} + +StatusOr AgentServiceTracingStub::GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "GetExample"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetExample(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "CreateExample"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateExample(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "UpdateExample"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateExample(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "DeleteExample"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteExample(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "ListTools"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListTools(context, options, request)); +} + +StatusOr AgentServiceTracingStub::GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "GetTool"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetTool(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListConversations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->ListConversations(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "GetConversation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetConversation(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "DeleteConversation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->DeleteConversation(context, options, request)); +} + +future> +AgentServiceTracingStub::AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "BatchDeleteConversations"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncBatchDeleteConversations(cq, context, + std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +AgentServiceTracingStub::BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "BatchDeleteConversations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->BatchDeleteConversations(context, options, request)); +} + +StatusOr AgentServiceTracingStub::CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "CreateTool"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateTool(context, options, request)); +} + +StatusOr AgentServiceTracingStub::UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "UpdateTool"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateTool(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "DeleteTool"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteTool(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListGuardrails"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListGuardrails(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "GetGuardrail"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetGuardrail(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "CreateGuardrail"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateGuardrail(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "UpdateGuardrail"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateGuardrail(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "DeleteGuardrail"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteGuardrail(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListDeployments"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListDeployments(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "GetDeployment"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetDeployment(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "CreateDeployment"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateDeployment(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "UpdateDeployment"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateDeployment(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "DeleteDeployment"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteDeployment(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListToolsets"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListToolsets(context, options, request)); +} + +StatusOr AgentServiceTracingStub::GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "GetToolset"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetToolset(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "CreateToolset"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateToolset(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "UpdateToolset"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateToolset(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "DeleteToolset"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteToolset(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListAppVersions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListAppVersions(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "GetAppVersion"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetAppVersion(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "CreateAppVersion"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateAppVersion(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "DeleteAppVersion"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteAppVersion(context, options, request)); +} + +future> +AgentServiceTracingStub::AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "RestoreAppVersion"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncRestoreAppVersion(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +AgentServiceTracingStub::RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "RestoreAppVersion"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->RestoreAppVersion(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListChangelogs"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListChangelogs(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "GetChangelog"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetChangelog(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +AgentServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr AgentServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status AgentServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status AgentServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.AgentService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +future> +AgentServiceTracingStub::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 AgentServiceTracingStub::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 MakeAgentServiceTracingStub( + std::shared_ptr stub) { + return std::make_shared(std::move(stub)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/agent_tracing_stub.h b/google/cloud/ces/v1/internal/agent_tracing_stub.h new file mode 100644 index 0000000000000..a3d5e8f6726b4 --- /dev/null +++ b/google/cloud/ces/v1/internal/agent_tracing_stub.h @@ -0,0 +1,332 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_TRACING_STUB_H + +#include "google/cloud/ces/v1/internal/agent_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AgentServiceTracingStub : public AgentServiceStub { + public: + ~AgentServiceTracingStub() override = default; + + explicit AgentServiceTracingStub(std::shared_ptr child); + + StatusOr ListApps( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppsRequest const& request) override; + + StatusOr GetApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppRequest const& request) override; + + future> AsyncCreateApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr CreateApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::CreateAppRequest const& request) override; + + StatusOr UpdateApp( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAppRequest const& request) override; + + future> AsyncDeleteApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + StatusOr DeleteApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::DeleteAppRequest const& request) override; + + future> AsyncExportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + StatusOr ExportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ExportAppRequest const& request) override; + + future> AsyncImportApp( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ImportApp( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::ImportAppRequest const& request) override; + + StatusOr ListAgents( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAgentsRequest const& request) override; + + StatusOr GetAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAgentRequest const& request) override; + + StatusOr CreateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAgentRequest const& request) override; + + StatusOr UpdateAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateAgentRequest const& request) override; + + Status DeleteAgent( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAgentRequest const& request) override; + + StatusOr ListExamples( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListExamplesRequest const& request) override; + + StatusOr GetExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetExampleRequest const& request) override; + + StatusOr CreateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateExampleRequest const& request) override; + + StatusOr UpdateExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateExampleRequest const& request) override; + + Status DeleteExample( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteExampleRequest const& request) override; + + StatusOr ListTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsRequest const& request) override; + + StatusOr GetTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolRequest const& request) override; + + StatusOr ListConversations( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListConversationsRequest const& request) override; + + StatusOr GetConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetConversationRequest const& request) override; + + Status DeleteConversation( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteConversationRequest const& request) + override; + + future> + AsyncBatchDeleteConversations( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr BatchDeleteConversations( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request) + override; + + StatusOr CreateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolRequest const& request) override; + + StatusOr UpdateTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolRequest const& request) override; + + Status DeleteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolRequest const& request) override; + + StatusOr ListGuardrails( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListGuardrailsRequest const& request) override; + + StatusOr GetGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetGuardrailRequest const& request) override; + + StatusOr CreateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateGuardrailRequest const& request) override; + + StatusOr UpdateGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateGuardrailRequest const& request) override; + + Status DeleteGuardrail( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteGuardrailRequest const& request) override; + + StatusOr ListDeployments( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListDeploymentsRequest const& request) override; + + StatusOr GetDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetDeploymentRequest const& request) override; + + StatusOr CreateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateDeploymentRequest const& request) override; + + StatusOr UpdateDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateDeploymentRequest const& request) override; + + Status DeleteDeployment( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteDeploymentRequest const& request) override; + + StatusOr ListToolsets( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListToolsetsRequest const& request) override; + + StatusOr GetToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetToolsetRequest const& request) override; + + StatusOr CreateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateToolsetRequest const& request) override; + + StatusOr UpdateToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::UpdateToolsetRequest const& request) override; + + Status DeleteToolset( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteToolsetRequest const& request) override; + + StatusOr ListAppVersions( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListAppVersionsRequest const& request) override; + + StatusOr GetAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetAppVersionRequest const& request) override; + + StatusOr CreateAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::CreateAppVersionRequest const& request) override; + + Status DeleteAppVersion( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::DeleteAppVersionRequest const& request) override; + + future> AsyncRestoreAppVersion( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr RestoreAppVersion( + grpc::ClientContext& context, Options options, + google::cloud::ces::v1::RestoreAppVersionRequest const& request) override; + + StatusOr ListChangelogs( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ListChangelogsRequest const& request) override; + + StatusOr GetChangelog( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GetChangelogRequest 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 MakeAgentServiceTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_AGENT_TRACING_STUB_H diff --git a/google/cloud/ces/v1/internal/session_auth_decorator.cc b/google/cloud/ces/v1/internal/session_auth_decorator.cc new file mode 100644 index 0000000000000..46631439a4ceb --- /dev/null +++ b/google/cloud/ces/v1/internal/session_auth_decorator.cc @@ -0,0 +1,121 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_auth_decorator.h" +#include "google/cloud/ces/v1/session_service.grpc.pb.h" +#include "google/cloud/internal/async_read_write_stream_auth.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SessionServiceAuth::SessionServiceAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr +SessionServiceAuth::RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->RunSession(context, options, request); +} + +std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> +SessionServiceAuth::AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) { + using StreamAuth = google::cloud::internal::AsyncStreamingReadWriteRpcAuth< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>; + + auto call = [child = child_, cq, options = std::move(options)]( + std::shared_ptr ctx) { + return child->AsyncBidiRunSession(cq, std::move(ctx), options); + }; + return std::make_unique( + std::move(context), auth_, StreamAuth::StreamFactory(std::move(call))); +} + +StatusOr +SessionServiceAuth::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 SessionServiceAuth::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 +SessionServiceAuth::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 SessionServiceAuth::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 SessionServiceAuth::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 SessionServiceAuth::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/session_auth_decorator.h b/google/cloud/ces/v1/internal/session_auth_decorator.h new file mode 100644 index 0000000000000..337608fe719b0 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_auth_decorator.h @@ -0,0 +1,92 @@ +// 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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_AUTH_DECORATOR_H + +#include "google/cloud/ces/v1/internal/session_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SessionServiceAuth : public SessionServiceStub { + public: + ~SessionServiceAuth() override = default; + SessionServiceAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) override; + + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_AUTH_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/session_connection_impl.cc b/google/cloud/ces/v1/internal/session_connection_impl.cc new file mode 100644 index 0000000000000..9c6a13cce9b33 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_connection_impl.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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_connection_impl.h" +#include "google/cloud/ces/v1/internal/session_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 ces_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(); +} + +} // namespace + +SessionServiceConnectionImpl::SessionServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions(std::move(options), + SessionServiceConnection::options())) {} + +StatusOr +SessionServiceConnectionImpl::RunSession( + google::cloud::ces::v1::RunSessionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->RunSession(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) { + return stub_->RunSession(context, options, request); + }, + *current, request, __func__); +} + +std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> +SessionServiceConnectionImpl::AsyncBidiRunSession() { + return stub_->AsyncBidiRunSession(background_->cq(), + std::make_shared(), + internal::SaveCurrentOptions()); +} + +StreamRange +SessionServiceConnectionImpl::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 +SessionServiceConnectionImpl::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 +SessionServiceConnectionImpl::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 +SessionServiceConnectionImpl::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 SessionServiceConnectionImpl::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 SessionServiceConnectionImpl::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 ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/session_connection_impl.h b/google/cloud/ces/v1/internal/session_connection_impl.h new file mode 100644 index 0000000000000..2deed4342dfdc --- /dev/null +++ b/google/cloud/ces/v1/internal/session_connection_impl.h @@ -0,0 +1,89 @@ +// 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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_CONNECTION_IMPL_H + +#include "google/cloud/ces/v1/internal/session_retry_traits.h" +#include "google/cloud/ces/v1/internal/session_stub.h" +#include "google/cloud/ces/v1/session_connection.h" +#include "google/cloud/ces/v1/session_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/session_options.h" +#include "google/cloud/async_streaming_read_write_rpc.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SessionServiceConnectionImpl : public ces_v1::SessionServiceConnection { + public: + ~SessionServiceConnectionImpl() override = default; + + SessionServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options); + + Options options() override { return options_; } + + StatusOr RunSession( + google::cloud::ces::v1::RunSessionRequest const& request) override; + + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession() 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_CONNECTION_IMPL_H diff --git a/google/cloud/ces/v1/internal/session_logging_decorator.cc b/google/cloud/ces/v1/internal/session_logging_decorator.cc new file mode 100644 index 0000000000000..9426611deee3f --- /dev/null +++ b/google/cloud/ces/v1/internal/session_logging_decorator.cc @@ -0,0 +1,152 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_logging_decorator.h" +#include "google/cloud/ces/v1/session_service.grpc.pb.h" +#include "google/cloud/internal/async_read_write_stream_logging.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SessionServiceLogging::SessionServiceLogging( + std::shared_ptr child, TracingOptions tracing_options, + std::set const& components) + : child_(std::move(child)), + tracing_options_(std::move(tracing_options)), + stream_logging_(components.find("rpc-streams") != components.end()) {} + +StatusOr +SessionServiceLogging::RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) { + return child_->RunSession(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> +SessionServiceLogging::AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) { + using LoggingStream = + ::google::cloud::internal::AsyncStreamingReadWriteRpcLogging< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>; + + auto request_id = google::cloud::internal::RequestIdForLogging(); + GCP_LOG(DEBUG) << __func__ << "(" << request_id << ")"; + auto stream = + child_->AsyncBidiRunSession(cq, std::move(context), std::move(options)); + if (stream_logging_) { + stream = std::make_unique( + std::move(stream), tracing_options_, std::move(request_id)); + } + return stream; +} + +StatusOr +SessionServiceLogging::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 SessionServiceLogging::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 +SessionServiceLogging::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 SessionServiceLogging::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 SessionServiceLogging::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 SessionServiceLogging::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/session_logging_decorator.h b/google/cloud/ces/v1/internal/session_logging_decorator.h new file mode 100644 index 0000000000000..00d9a2805155e --- /dev/null +++ b/google/cloud/ces/v1/internal/session_logging_decorator.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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_LOGGING_DECORATOR_H + +#include "google/cloud/ces/v1/internal/session_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SessionServiceLogging : public SessionServiceStub { + public: + ~SessionServiceLogging() override = default; + SessionServiceLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const& components); + + StatusOr RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) override; + + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) 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_; + bool stream_logging_; +}; // SessionServiceLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_LOGGING_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/session_metadata_decorator.cc b/google/cloud/ces/v1/internal/session_metadata_decorator.cc new file mode 100644 index 0000000000000..075b547a4e321 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_metadata_decorator.cc @@ -0,0 +1,141 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_metadata_decorator.h" +#include "google/cloud/ces/v1/session_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SessionServiceMetadata::SessionServiceMetadata( + 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 +SessionServiceMetadata::RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("config.session=", + internal::UrlEncode(request.config().session()))); + return child_->RunSession(context, options, request); +} + +std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> +SessionServiceMetadata::AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) { + SetMetadata(*context, *options); + return child_->AsyncBidiRunSession(cq, std::move(context), + std::move(options)); +} + +StatusOr +SessionServiceMetadata::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 SessionServiceMetadata::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 +SessionServiceMetadata::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 SessionServiceMetadata::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 SessionServiceMetadata::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 SessionServiceMetadata::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 SessionServiceMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void SessionServiceMetadata::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/session_metadata_decorator.h b/google/cloud/ces/v1/internal/session_metadata_decorator.h new file mode 100644 index 0000000000000..2f9d4e2a195aa --- /dev/null +++ b/google/cloud/ces/v1/internal/session_metadata_decorator.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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_METADATA_DECORATOR_H + +#include "google/cloud/ces/v1/internal/session_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SessionServiceMetadata : public SessionServiceStub { + public: + ~SessionServiceMetadata() override = default; + SessionServiceMetadata(std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + StatusOr RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) override; + + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_METADATA_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/session_option_defaults.cc b/google/cloud/ces/v1/internal/session_option_defaults.cc new file mode 100644 index 0000000000000..6224175e14269 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_option_defaults.cc @@ -0,0 +1,64 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_option_defaults.h" +#include "google/cloud/ces/v1/session_connection.h" +#include "google/cloud/ces/v1/session_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options SessionServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_SESSION_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_SESSION_SERVICE_AUTHORITY", "ces.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + ces_v1::SessionServiceLimitedTimeRetryPolicy(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( + ces_v1::MakeDefaultSessionServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/session_option_defaults.h b/google/cloud/ces/v1/internal/session_option_defaults.h new file mode 100644 index 0000000000000..f8046e7a9b617 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options SessionServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_OPTION_DEFAULTS_H diff --git a/google/cloud/ces/v1/internal/session_retry_traits.h b/google/cloud/ces/v1/internal/session_retry_traits.h new file mode 100644 index 0000000000000..ecc6910b1b066 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct SessionServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_RETRY_TRAITS_H diff --git a/google/cloud/ces/v1/internal/session_sources.cc b/google/cloud/ces/v1/internal/session_sources.cc new file mode 100644 index 0000000000000..94f48b649e13c --- /dev/null +++ b/google/cloud/ces/v1/internal/session_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/ces/v1/session_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/ces/v1/internal/session_auth_decorator.cc" +#include "google/cloud/ces/v1/internal/session_connection_impl.cc" +#include "google/cloud/ces/v1/internal/session_logging_decorator.cc" +#include "google/cloud/ces/v1/internal/session_metadata_decorator.cc" +#include "google/cloud/ces/v1/internal/session_option_defaults.cc" +#include "google/cloud/ces/v1/internal/session_stub.cc" +#include "google/cloud/ces/v1/internal/session_stub_factory.cc" +#include "google/cloud/ces/v1/internal/session_tracing_connection.cc" +#include "google/cloud/ces/v1/internal/session_tracing_stub.cc" +#include "google/cloud/ces/v1/session_client.cc" +#include "google/cloud/ces/v1/session_connection.cc" +#include "google/cloud/ces/v1/session_connection_idempotency_policy.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/ces/v1/internal/session_stub.cc b/google/cloud/ces/v1/internal/session_stub.cc new file mode 100644 index 0000000000000..8b5c932153053 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_stub.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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_stub.h" +#include "google/cloud/ces/v1/session_service.grpc.pb.h" +#include "google/cloud/grpc_error_delegate.h" +#include "google/cloud/internal/async_read_write_stream_impl.h" +#include "google/cloud/status_or.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SessionServiceStub::~SessionServiceStub() = default; + +StatusOr +DefaultSessionServiceStub::RunSession( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::RunSessionRequest const& request) { + google::cloud::ces::v1::RunSessionResponse response; + auto status = grpc_stub_->RunSession(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> +DefaultSessionServiceStub::AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) { + return google::cloud::internal::MakeStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>( + cq, std::move(context), std::move(options), + [this](grpc::ClientContext* context, grpc::CompletionQueue* cq) { + return grpc_stub_->PrepareAsyncBidiRunSession(context, cq); + }); +} + +StatusOr +DefaultSessionServiceStub::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 +DefaultSessionServiceStub::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 +DefaultSessionServiceStub::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 +DefaultSessionServiceStub::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 DefaultSessionServiceStub::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 DefaultSessionServiceStub::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/session_stub.h b/google/cloud/ces/v1/internal/session_stub.h new file mode 100644 index 0000000000000..0426940c449b8 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_stub.h @@ -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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_STUB_H + +#include "google/cloud/ces/v1/session_service.grpc.pb.h" +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/async_streaming_read_write_rpc.h" +#include "google/cloud/completion_queue.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SessionServiceStub { + public: + virtual ~SessionServiceStub() = 0; + + virtual StatusOr RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) = 0; + + virtual std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession(google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) = 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 DefaultSessionServiceStub : public SessionServiceStub { + public: + explicit DefaultSessionServiceStub( + 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 RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) override; + + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) 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 + grpc_stub_; + std::unique_ptr + operations_stub_; + std::unique_ptr + locations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_STUB_H diff --git a/google/cloud/ces/v1/internal/session_stub_factory.cc b/google/cloud/ces/v1/internal/session_stub_factory.cc new file mode 100644 index 0000000000000..fde08279586f5 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_stub_factory.h" +#include "google/cloud/ces/v1/internal/session_auth_decorator.h" +#include "google/cloud/ces/v1/internal/session_logging_decorator.h" +#include "google/cloud/ces/v1/internal/session_metadata_decorator.h" +#include "google/cloud/ces/v1/internal/session_stub.h" +#include "google/cloud/ces/v1/internal/session_tracing_stub.h" +#include "google/cloud/ces/v1/session_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultSessionServiceStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::ces::v1::SessionService::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 = MakeSessionServiceTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/session_stub_factory.h b/google/cloud/ces/v1/internal/session_stub_factory.h new file mode 100644 index 0000000000000..466fab2b11975 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_STUB_FACTORY_H + +#include "google/cloud/ces/v1/internal/session_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultSessionServiceStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_STUB_FACTORY_H diff --git a/google/cloud/ces/v1/internal/session_tracing_connection.cc b/google/cloud/ces/v1/internal/session_tracing_connection.cc new file mode 100644 index 0000000000000..8b443f898f81a --- /dev/null +++ b/google/cloud/ces/v1/internal/session_tracing_connection.cc @@ -0,0 +1,118 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SessionServiceTracingConnection::SessionServiceTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StatusOr +SessionServiceTracingConnection::RunSession( + google::cloud::ces::v1::RunSessionRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::SessionServiceConnection::RunSession"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->RunSession(request)); +} + +std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> +SessionServiceTracingConnection::AsyncBidiRunSession() { + return child_->AsyncBidiRunSession(); +} + +StreamRange +SessionServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::SessionServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::SessionServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +SessionServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::SessionServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::SessionServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status SessionServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::SessionServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status SessionServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::SessionServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr +MakeSessionServiceTracingConnection( + 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 ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/session_tracing_connection.h b/google/cloud/ces/v1/internal/session_tracing_connection.h new file mode 100644 index 0000000000000..28fb70edcee60 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_tracing_connection.h @@ -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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_TRACING_CONNECTION_H + +#include "google/cloud/ces/v1/session_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SessionServiceTracingConnection + : public ces_v1::SessionServiceConnection { + public: + ~SessionServiceTracingConnection() override = default; + + explicit SessionServiceTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StatusOr RunSession( + google::cloud::ces::v1::RunSessionRequest const& request) override; + + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession() 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 +MakeSessionServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_TRACING_CONNECTION_H diff --git a/google/cloud/ces/v1/internal/session_tracing_stub.cc b/google/cloud/ces/v1/internal/session_tracing_stub.cc new file mode 100644 index 0000000000000..2fbfdcac16d71 --- /dev/null +++ b/google/cloud/ces/v1/internal/session_tracing_stub.cc @@ -0,0 +1,146 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/internal/session_tracing_stub.h" +#include "google/cloud/internal/async_read_write_stream_tracing.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SessionServiceTracingStub::SessionServiceTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +StatusOr +SessionServiceTracingStub::RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.SessionService", + "RunSession"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->RunSession(context, options, request)); +} + +std::unique_ptr> +SessionServiceTracingStub::AsyncBidiRunSession( + CompletionQueue const& cq, std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.SessionService", + "BidiRunSession"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto stream = child_->AsyncBidiRunSession(cq, context, std::move(options)); + return std::make_unique>( + std::move(context), std::move(stream), std::move(span)); +} + +StatusOr +SessionServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.SessionService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +SessionServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.SessionService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +SessionServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.SessionService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +SessionServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.SessionService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status SessionServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.SessionService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status SessionServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.SessionService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +std::shared_ptr MakeSessionServiceTracingStub( + std::shared_ptr stub) { + return std::make_shared(std::move(stub)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/session_tracing_stub.h b/google/cloud/ces/v1/internal/session_tracing_stub.h new file mode 100644 index 0000000000000..9a24bb30abf6b --- /dev/null +++ b/google/cloud/ces/v1/internal/session_tracing_stub.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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_TRACING_STUB_H + +#include "google/cloud/ces/v1/internal/session_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SessionServiceTracingStub : public SessionServiceStub { + public: + ~SessionServiceTracingStub() override = default; + + explicit SessionServiceTracingStub(std::shared_ptr child); + + StatusOr RunSession( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RunSessionRequest const& request) override; + + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession( + google::cloud::CompletionQueue const& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options) 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 MakeSessionServiceTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_SESSION_TRACING_STUB_H diff --git a/google/cloud/ces/v1/internal/tool_auth_decorator.cc b/google/cloud/ces/v1/internal/tool_auth_decorator.cc new file mode 100644 index 0000000000000..55679702987a1 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_auth_decorator.cc @@ -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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_auth_decorator.h" +#include "google/cloud/ces/v1/tool_service.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +ToolServiceAuth::ToolServiceAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr +ToolServiceAuth::ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ExecuteTool(context, options, request); +} + +StatusOr +ToolServiceAuth::RetrieveToolSchema( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->RetrieveToolSchema(context, options, request); +} + +StatusOr +ToolServiceAuth::RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->RetrieveTools(context, options, request); +} + +StatusOr +ToolServiceAuth::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 ToolServiceAuth::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 +ToolServiceAuth::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 ToolServiceAuth::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 ToolServiceAuth::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 ToolServiceAuth::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/tool_auth_decorator.h b/google/cloud/ces/v1/internal/tool_auth_decorator.h new file mode 100644 index 0000000000000..102291dd56c57 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_auth_decorator.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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_AUTH_DECORATOR_H + +#include "google/cloud/ces/v1/internal/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class ToolServiceAuth : public ToolServiceStub { + public: + ~ToolServiceAuth() override = default; + ToolServiceAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) override; + + StatusOr + RetrieveToolSchema(grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& + request) override; + + StatusOr RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_AUTH_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/tool_connection_impl.cc b/google/cloud/ces/v1/internal/tool_connection_impl.cc new file mode 100644 index 0000000000000..8fe19363c09b2 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_connection_impl.cc @@ -0,0 +1,226 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_connection_impl.h" +#include "google/cloud/ces/v1/internal/tool_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 ces_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(); +} + +} // namespace + +ToolServiceConnectionImpl::ToolServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions(std::move(options), + ToolServiceConnection::options())) {} + +StatusOr +ToolServiceConnectionImpl::ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->ExecuteTool(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) { + return stub_->ExecuteTool(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ToolServiceConnectionImpl::RetrieveToolSchema( + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->RetrieveToolSchema(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + return stub_->RetrieveToolSchema(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ToolServiceConnectionImpl::RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->RetrieveTools(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + return stub_->RetrieveTools(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +ToolServiceConnectionImpl::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 +ToolServiceConnectionImpl::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 +ToolServiceConnectionImpl::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 +ToolServiceConnectionImpl::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 ToolServiceConnectionImpl::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 ToolServiceConnectionImpl::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 ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/tool_connection_impl.h b/google/cloud/ces/v1/internal/tool_connection_impl.h new file mode 100644 index 0000000000000..8194b4083d487 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_connection_impl.h @@ -0,0 +1,89 @@ +// 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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_CONNECTION_IMPL_H + +#include "google/cloud/ces/v1/internal/tool_retry_traits.h" +#include "google/cloud/ces/v1/internal/tool_stub.h" +#include "google/cloud/ces/v1/tool_connection.h" +#include "google/cloud/ces/v1/tool_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/tool_options.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class ToolServiceConnectionImpl : public ces_v1::ToolServiceConnection { + public: + ~ToolServiceConnectionImpl() override = default; + + ToolServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options); + + Options options() override { return options_; } + + StatusOr ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const& request) override; + + StatusOr + RetrieveToolSchema(google::cloud::ces::v1::RetrieveToolSchemaRequest const& + request) override; + + StatusOr RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_CONNECTION_IMPL_H diff --git a/google/cloud/ces/v1/internal/tool_logging_decorator.cc b/google/cloud/ces/v1/internal/tool_logging_decorator.cc new file mode 100644 index 0000000000000..26036493fae1b --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_logging_decorator.cc @@ -0,0 +1,150 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_logging_decorator.h" +#include "google/cloud/ces/v1/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +ToolServiceLogging::ToolServiceLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +StatusOr +ToolServiceLogging::ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) { + return child_->ExecuteTool(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ToolServiceLogging::RetrieveToolSchema( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + return child_->RetrieveToolSchema(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ToolServiceLogging::RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + return child_->RetrieveTools(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ToolServiceLogging::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 ToolServiceLogging::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 +ToolServiceLogging::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 ToolServiceLogging::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 ToolServiceLogging::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 ToolServiceLogging::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/tool_logging_decorator.h b/google/cloud/ces/v1/internal/tool_logging_decorator.h new file mode 100644 index 0000000000000..72cd67ed6e594 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_logging_decorator.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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_LOGGING_DECORATOR_H + +#include "google/cloud/ces/v1/internal/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class ToolServiceLogging : public ToolServiceStub { + public: + ~ToolServiceLogging() override = default; + ToolServiceLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const& components); + + StatusOr ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) override; + + StatusOr + RetrieveToolSchema(grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& + request) override; + + StatusOr RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest 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_; +}; // ToolServiceLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_LOGGING_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/tool_metadata_decorator.cc b/google/cloud/ces/v1/internal/tool_metadata_decorator.cc new file mode 100644 index 0000000000000..d0fd20c08a4c3 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_metadata_decorator.cc @@ -0,0 +1,146 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_metadata_decorator.h" +#include "google/cloud/ces/v1/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +ToolServiceMetadata::ToolServiceMetadata( + 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 +ToolServiceMetadata::ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ExecuteTool(context, options, request); +} + +StatusOr +ToolServiceMetadata::RetrieveToolSchema( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->RetrieveToolSchema(context, options, request); +} + +StatusOr +ToolServiceMetadata::RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("toolset=", internal::UrlEncode(request.toolset()))); + return child_->RetrieveTools(context, options, request); +} + +StatusOr +ToolServiceMetadata::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 ToolServiceMetadata::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 +ToolServiceMetadata::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 ToolServiceMetadata::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 ToolServiceMetadata::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 ToolServiceMetadata::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 ToolServiceMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void ToolServiceMetadata::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/tool_metadata_decorator.h b/google/cloud/ces/v1/internal/tool_metadata_decorator.h new file mode 100644 index 0000000000000..3674224c51dc3 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_metadata_decorator.h @@ -0,0 +1,98 @@ +// 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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_METADATA_DECORATOR_H + +#include "google/cloud/ces/v1/internal/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class ToolServiceMetadata : public ToolServiceStub { + public: + ~ToolServiceMetadata() override = default; + ToolServiceMetadata(std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + StatusOr ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) override; + + StatusOr + RetrieveToolSchema(grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& + request) override; + + StatusOr RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_METADATA_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/tool_option_defaults.cc b/google/cloud/ces/v1/internal/tool_option_defaults.cc new file mode 100644 index 0000000000000..b924efccf4c8f --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_option_defaults.cc @@ -0,0 +1,64 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_option_defaults.h" +#include "google/cloud/ces/v1/tool_connection.h" +#include "google/cloud/ces/v1/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options ToolServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_TOOL_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_TOOL_SERVICE_AUTHORITY", "ces.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + ces_v1::ToolServiceLimitedTimeRetryPolicy(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( + ces_v1::MakeDefaultToolServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/tool_option_defaults.h b/google/cloud/ces/v1/internal/tool_option_defaults.h new file mode 100644 index 0000000000000..36090e5547cfb --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options ToolServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_OPTION_DEFAULTS_H diff --git a/google/cloud/ces/v1/internal/tool_retry_traits.h b/google/cloud/ces/v1/internal/tool_retry_traits.h new file mode 100644 index 0000000000000..c744035d4d266 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct ToolServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_RETRY_TRAITS_H diff --git a/google/cloud/ces/v1/internal/tool_sources.cc b/google/cloud/ces/v1/internal/tool_sources.cc new file mode 100644 index 0000000000000..6f06559be9d8b --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_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/ces/v1/tool_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/ces/v1/internal/tool_auth_decorator.cc" +#include "google/cloud/ces/v1/internal/tool_connection_impl.cc" +#include "google/cloud/ces/v1/internal/tool_logging_decorator.cc" +#include "google/cloud/ces/v1/internal/tool_metadata_decorator.cc" +#include "google/cloud/ces/v1/internal/tool_option_defaults.cc" +#include "google/cloud/ces/v1/internal/tool_stub.cc" +#include "google/cloud/ces/v1/internal/tool_stub_factory.cc" +#include "google/cloud/ces/v1/internal/tool_tracing_connection.cc" +#include "google/cloud/ces/v1/internal/tool_tracing_stub.cc" +#include "google/cloud/ces/v1/tool_client.cc" +#include "google/cloud/ces/v1/tool_connection.cc" +#include "google/cloud/ces/v1/tool_connection_idempotency_policy.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/ces/v1/internal/tool_stub.cc b/google/cloud/ces/v1/internal/tool_stub.cc new file mode 100644 index 0000000000000..36f9b2e06a983 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_stub.cc @@ -0,0 +1,145 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_stub.h" +#include "google/cloud/ces/v1/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +ToolServiceStub::~ToolServiceStub() = default; + +StatusOr +DefaultToolServiceStub::ExecuteTool( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::ExecuteToolRequest const& request) { + google::cloud::ces::v1::ExecuteToolResponse response; + auto status = grpc_stub_->ExecuteTool(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultToolServiceStub::RetrieveToolSchema( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + google::cloud::ces::v1::RetrieveToolSchemaResponse response; + auto status = grpc_stub_->RetrieveToolSchema(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultToolServiceStub::RetrieveTools( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + google::cloud::ces::v1::RetrieveToolsResponse response; + auto status = grpc_stub_->RetrieveTools(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultToolServiceStub::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 DefaultToolServiceStub::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 +DefaultToolServiceStub::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 DefaultToolServiceStub::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 DefaultToolServiceStub::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 DefaultToolServiceStub::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/tool_stub.h b/google/cloud/ces/v1/internal/tool_stub.h new file mode 100644 index 0000000000000..5685f0c4c0b68 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_stub.h @@ -0,0 +1,148 @@ +// 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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_STUB_H + +#include "google/cloud/ces/v1/tool_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class ToolServiceStub { + public: + virtual ~ToolServiceStub() = 0; + + virtual StatusOr ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) = 0; + + virtual StatusOr + RetrieveToolSchema( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) = 0; + + virtual StatusOr RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest 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 DefaultToolServiceStub : public ToolServiceStub { + public: + explicit DefaultToolServiceStub( + 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 ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) override; + + StatusOr + RetrieveToolSchema(grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& + request) override; + + StatusOr RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest 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 + grpc_stub_; + std::unique_ptr + operations_stub_; + std::unique_ptr + locations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_STUB_H diff --git a/google/cloud/ces/v1/internal/tool_stub_factory.cc b/google/cloud/ces/v1/internal/tool_stub_factory.cc new file mode 100644 index 0000000000000..6c52f472af306 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_stub_factory.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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_stub_factory.h" +#include "google/cloud/ces/v1/internal/tool_auth_decorator.h" +#include "google/cloud/ces/v1/internal/tool_logging_decorator.h" +#include "google/cloud/ces/v1/internal/tool_metadata_decorator.h" +#include "google/cloud/ces/v1/internal/tool_stub.h" +#include "google/cloud/ces/v1/internal/tool_tracing_stub.h" +#include "google/cloud/ces/v1/tool_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultToolServiceStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::ces::v1::ToolService::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 = MakeToolServiceTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/tool_stub_factory.h b/google/cloud/ces/v1/internal/tool_stub_factory.h new file mode 100644 index 0000000000000..1932244605d1f --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_STUB_FACTORY_H + +#include "google/cloud/ces/v1/internal/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultToolServiceStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_STUB_FACTORY_H diff --git a/google/cloud/ces/v1/internal/tool_tracing_connection.cc b/google/cloud/ces/v1/internal/tool_tracing_connection.cc new file mode 100644 index 0000000000000..0d838a0b4826d --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_tracing_connection.cc @@ -0,0 +1,125 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +ToolServiceTracingConnection::ToolServiceTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StatusOr +ToolServiceTracingConnection::ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const& request) { + auto span = internal::MakeSpan("ces_v1::ToolServiceConnection::ExecuteTool"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->ExecuteTool(request)); +} + +StatusOr +ToolServiceTracingConnection::RetrieveToolSchema( + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::ToolServiceConnection::RetrieveToolSchema"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->RetrieveToolSchema(request)); +} + +StatusOr +ToolServiceTracingConnection::RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::ToolServiceConnection::RetrieveTools"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->RetrieveTools(request)); +} + +StreamRange +ToolServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::ToolServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ToolServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("ces_v1::ToolServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +ToolServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::ToolServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ToolServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("ces_v1::ToolServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status ToolServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::ToolServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status ToolServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::ToolServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr MakeToolServiceTracingConnection( + 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 ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/tool_tracing_connection.h b/google/cloud/ces/v1/internal/tool_tracing_connection.h new file mode 100644 index 0000000000000..18c15cb59127c --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_tracing_connection.h @@ -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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_TRACING_CONNECTION_H + +#include "google/cloud/ces/v1/tool_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class ToolServiceTracingConnection : public ces_v1::ToolServiceConnection { + public: + ~ToolServiceTracingConnection() override = default; + + explicit ToolServiceTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StatusOr ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const& request) override; + + StatusOr + RetrieveToolSchema(google::cloud::ces::v1::RetrieveToolSchemaRequest const& + request) override; + + StatusOr RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest 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 MakeToolServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_TRACING_CONNECTION_H diff --git a/google/cloud/ces/v1/internal/tool_tracing_stub.cc b/google/cloud/ces/v1/internal/tool_tracing_stub.cc new file mode 100644 index 0000000000000..2424caf5f0ff9 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_tracing_stub.cc @@ -0,0 +1,150 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/internal/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +ToolServiceTracingStub::ToolServiceTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +StatusOr +ToolServiceTracingStub::ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", "ExecuteTool"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ExecuteTool(context, options, request)); +} + +StatusOr +ToolServiceTracingStub::RetrieveToolSchema( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", + "RetrieveToolSchema"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->RetrieveToolSchema(context, options, request)); +} + +StatusOr +ToolServiceTracingStub::RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", + "RetrieveTools"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->RetrieveTools(context, options, request)); +} + +StatusOr +ToolServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr ToolServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +ToolServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr ToolServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status ToolServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status ToolServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.ToolService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +std::shared_ptr MakeToolServiceTracingStub( + std::shared_ptr stub) { + return std::make_shared(std::move(stub)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/tool_tracing_stub.h b/google/cloud/ces/v1/internal/tool_tracing_stub.h new file mode 100644 index 0000000000000..e8a0b4df0ea28 --- /dev/null +++ b/google/cloud/ces/v1/internal/tool_tracing_stub.h @@ -0,0 +1,101 @@ +// 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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_TRACING_STUB_H + +#include "google/cloud/ces/v1/internal/tool_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class ToolServiceTracingStub : public ToolServiceStub { + public: + ~ToolServiceTracingStub() override = default; + + explicit ToolServiceTracingStub(std::shared_ptr child); + + StatusOr ExecuteTool( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::ExecuteToolRequest const& request) override; + + StatusOr + RetrieveToolSchema(grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolSchemaRequest const& + request) override; + + StatusOr RetrieveTools( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::RetrieveToolsRequest 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 MakeToolServiceTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_TOOL_TRACING_STUB_H diff --git a/google/cloud/ces/v1/internal/widget_auth_decorator.cc b/google/cloud/ces/v1/internal/widget_auth_decorator.cc new file mode 100644 index 0000000000000..816c764752445 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_auth_decorator.cc @@ -0,0 +1,101 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_auth_decorator.h" +#include "google/cloud/ces/v1/widget_service.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WidgetServiceAuth::WidgetServiceAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr +WidgetServiceAuth::GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GenerateChatToken(context, options, request); +} + +StatusOr +WidgetServiceAuth::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 WidgetServiceAuth::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 +WidgetServiceAuth::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 WidgetServiceAuth::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 WidgetServiceAuth::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 WidgetServiceAuth::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/widget_auth_decorator.h b/google/cloud/ces/v1/internal/widget_auth_decorator.h new file mode 100644 index 0000000000000..9629e59b175e0 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_auth_decorator.h @@ -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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_AUTH_DECORATOR_H + +#include "google/cloud/ces/v1/internal/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WidgetServiceAuth : public WidgetServiceStub { + public: + ~WidgetServiceAuth() override = default; + WidgetServiceAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_AUTH_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/widget_connection_impl.cc b/google/cloud/ces/v1/internal/widget_connection_impl.cc new file mode 100644 index 0000000000000..7156e4753203d --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_connection_impl.cc @@ -0,0 +1,198 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_connection_impl.h" +#include "google/cloud/ces/v1/internal/widget_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 ces_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(); +} + +} // namespace + +WidgetServiceConnectionImpl::WidgetServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions(std::move(options), + WidgetServiceConnection::options())) {} + +StatusOr +WidgetServiceConnectionImpl::GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GenerateChatToken(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + return stub_->GenerateChatToken(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +WidgetServiceConnectionImpl::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 +WidgetServiceConnectionImpl::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 +WidgetServiceConnectionImpl::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 +WidgetServiceConnectionImpl::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 WidgetServiceConnectionImpl::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 WidgetServiceConnectionImpl::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 ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/widget_connection_impl.h b/google/cloud/ces/v1/internal/widget_connection_impl.h new file mode 100644 index 0000000000000..2aa1a972c9df3 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_connection_impl.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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_CONNECTION_IMPL_H + +#include "google/cloud/ces/v1/internal/widget_retry_traits.h" +#include "google/cloud/ces/v1/internal/widget_stub.h" +#include "google/cloud/ces/v1/widget_connection.h" +#include "google/cloud/ces/v1/widget_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/widget_options.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WidgetServiceConnectionImpl : public ces_v1::WidgetServiceConnection { + public: + ~WidgetServiceConnectionImpl() override = default; + + WidgetServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options); + + Options options() override { return options_; } + + StatusOr GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_CONNECTION_IMPL_H diff --git a/google/cloud/ces/v1/internal/widget_logging_decorator.cc b/google/cloud/ces/v1/internal/widget_logging_decorator.cc new file mode 100644 index 0000000000000..3fbb098efb69b --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_logging_decorator.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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_logging_decorator.h" +#include "google/cloud/ces/v1/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WidgetServiceLogging::WidgetServiceLogging( + std::shared_ptr child, TracingOptions tracing_options, + std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +StatusOr +WidgetServiceLogging::GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + return child_->GenerateChatToken(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WidgetServiceLogging::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 WidgetServiceLogging::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 +WidgetServiceLogging::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 WidgetServiceLogging::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 WidgetServiceLogging::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 WidgetServiceLogging::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/widget_logging_decorator.h b/google/cloud/ces/v1/internal/widget_logging_decorator.h new file mode 100644 index 0000000000000..20c3130ab1ffb --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_logging_decorator.h @@ -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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_LOGGING_DECORATOR_H + +#include "google/cloud/ces/v1/internal/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WidgetServiceLogging : public WidgetServiceStub { + public: + ~WidgetServiceLogging() override = default; + WidgetServiceLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const& components); + + StatusOr GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest 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_; +}; // WidgetServiceLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_LOGGING_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/widget_metadata_decorator.cc b/google/cloud/ces/v1/internal/widget_metadata_decorator.cc new file mode 100644 index 0000000000000..b1d5b8cb741e7 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_metadata_decorator.cc @@ -0,0 +1,128 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_metadata_decorator.h" +#include "google/cloud/ces/v1/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WidgetServiceMetadata::WidgetServiceMetadata( + 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 +WidgetServiceMetadata::GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GenerateChatToken(context, options, request); +} + +StatusOr +WidgetServiceMetadata::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 WidgetServiceMetadata::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 +WidgetServiceMetadata::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 WidgetServiceMetadata::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 WidgetServiceMetadata::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 WidgetServiceMetadata::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 WidgetServiceMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void WidgetServiceMetadata::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/widget_metadata_decorator.h b/google/cloud/ces/v1/internal/widget_metadata_decorator.h new file mode 100644 index 0000000000000..4db9741a873e2 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_metadata_decorator.h @@ -0,0 +1,89 @@ +// 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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_METADATA_DECORATOR_H + +#include "google/cloud/ces/v1/internal/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WidgetServiceMetadata : public WidgetServiceStub { + public: + ~WidgetServiceMetadata() override = default; + WidgetServiceMetadata(std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + StatusOr GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest 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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_METADATA_DECORATOR_H diff --git a/google/cloud/ces/v1/internal/widget_option_defaults.cc b/google/cloud/ces/v1/internal/widget_option_defaults.cc new file mode 100644 index 0000000000000..ffd69d3e72285 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_option_defaults.cc @@ -0,0 +1,64 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_option_defaults.h" +#include "google/cloud/ces/v1/widget_connection.h" +#include "google/cloud/ces/v1/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options WidgetServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_WIDGET_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_WIDGET_SERVICE_AUTHORITY", "ces.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + ces_v1::WidgetServiceLimitedTimeRetryPolicy(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( + ces_v1::MakeDefaultWidgetServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/widget_option_defaults.h b/google/cloud/ces/v1/internal/widget_option_defaults.h new file mode 100644 index 0000000000000..d3d4dd82bf778 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options WidgetServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_OPTION_DEFAULTS_H diff --git a/google/cloud/ces/v1/internal/widget_retry_traits.h b/google/cloud/ces/v1/internal/widget_retry_traits.h new file mode 100644 index 0000000000000..abbd28fa56b33 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct WidgetServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_RETRY_TRAITS_H diff --git a/google/cloud/ces/v1/internal/widget_sources.cc b/google/cloud/ces/v1/internal/widget_sources.cc new file mode 100644 index 0000000000000..e2a7c2e2615e9 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_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/ces/v1/widget_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/ces/v1/internal/widget_auth_decorator.cc" +#include "google/cloud/ces/v1/internal/widget_connection_impl.cc" +#include "google/cloud/ces/v1/internal/widget_logging_decorator.cc" +#include "google/cloud/ces/v1/internal/widget_metadata_decorator.cc" +#include "google/cloud/ces/v1/internal/widget_option_defaults.cc" +#include "google/cloud/ces/v1/internal/widget_stub.cc" +#include "google/cloud/ces/v1/internal/widget_stub_factory.cc" +#include "google/cloud/ces/v1/internal/widget_tracing_connection.cc" +#include "google/cloud/ces/v1/internal/widget_tracing_stub.cc" +#include "google/cloud/ces/v1/widget_client.cc" +#include "google/cloud/ces/v1/widget_connection.cc" +#include "google/cloud/ces/v1/widget_connection_idempotency_policy.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/ces/v1/internal/widget_stub.cc b/google/cloud/ces/v1/internal/widget_stub.cc new file mode 100644 index 0000000000000..46083972aa37e --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_stub.cc @@ -0,0 +1,122 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_stub.h" +#include "google/cloud/ces/v1/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WidgetServiceStub::~WidgetServiceStub() = default; + +StatusOr +DefaultWidgetServiceStub::GenerateChatToken( + grpc::ClientContext& context, Options const&, + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + google::cloud::ces::v1::GenerateChatTokenResponse response; + auto status = grpc_stub_->GenerateChatToken(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWidgetServiceStub::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 +DefaultWidgetServiceStub::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 +DefaultWidgetServiceStub::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 DefaultWidgetServiceStub::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 DefaultWidgetServiceStub::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 DefaultWidgetServiceStub::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 ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/widget_stub.h b/google/cloud/ces/v1/internal/widget_stub.h new file mode 100644 index 0000000000000..3926d810b596d --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_stub.h @@ -0,0 +1,131 @@ +// 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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_STUB_H + +#include "google/cloud/ces/v1/widget_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WidgetServiceStub { + public: + virtual ~WidgetServiceStub() = 0; + + virtual StatusOr + GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest 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 DefaultWidgetServiceStub : public WidgetServiceStub { + public: + explicit DefaultWidgetServiceStub( + 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 GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest 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 + grpc_stub_; + std::unique_ptr + operations_stub_; + std::unique_ptr + locations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_STUB_H diff --git a/google/cloud/ces/v1/internal/widget_stub_factory.cc b/google/cloud/ces/v1/internal/widget_stub_factory.cc new file mode 100644 index 0000000000000..a4e9dd3bed944 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_stub_factory.h" +#include "google/cloud/ces/v1/internal/widget_auth_decorator.h" +#include "google/cloud/ces/v1/internal/widget_logging_decorator.h" +#include "google/cloud/ces/v1/internal/widget_metadata_decorator.h" +#include "google/cloud/ces/v1/internal/widget_stub.h" +#include "google/cloud/ces/v1/internal/widget_tracing_stub.h" +#include "google/cloud/ces/v1/widget_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultWidgetServiceStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::ces::v1::WidgetService::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 = MakeWidgetServiceTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/widget_stub_factory.h b/google/cloud/ces/v1/internal/widget_stub_factory.h new file mode 100644 index 0000000000000..91880f653a868 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_STUB_FACTORY_H + +#include "google/cloud/ces/v1/internal/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultWidgetServiceStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_STUB_FACTORY_H diff --git a/google/cloud/ces/v1/internal/widget_tracing_connection.cc b/google/cloud/ces/v1/internal/widget_tracing_connection.cc new file mode 100644 index 0000000000000..9ccdc7ee4edb2 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_tracing_connection.cc @@ -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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WidgetServiceTracingConnection::WidgetServiceTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StatusOr +WidgetServiceTracingConnection::GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::WidgetServiceConnection::GenerateChatToken"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GenerateChatToken(request)); +} + +StreamRange +WidgetServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::WidgetServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WidgetServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::WidgetServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +WidgetServiceTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = + internal::MakeSpan("ces_v1::WidgetServiceConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WidgetServiceTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::WidgetServiceConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status WidgetServiceTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::WidgetServiceConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status WidgetServiceTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = + internal::MakeSpan("ces_v1::WidgetServiceConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr +MakeWidgetServiceTracingConnection( + 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 ces_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/internal/widget_tracing_connection.h b/google/cloud/ces/v1/internal/widget_tracing_connection.h new file mode 100644 index 0000000000000..91182d3214b39 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_tracing_connection.h @@ -0,0 +1,80 @@ +// 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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_TRACING_CONNECTION_H + +#include "google/cloud/ces/v1/widget_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WidgetServiceTracingConnection : public ces_v1::WidgetServiceConnection { + public: + ~WidgetServiceTracingConnection() override = default; + + explicit WidgetServiceTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StatusOr GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest 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 +MakeWidgetServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_TRACING_CONNECTION_H diff --git a/google/cloud/ces/v1/internal/widget_tracing_stub.cc b/google/cloud/ces/v1/internal/widget_tracing_stub.cc new file mode 100644 index 0000000000000..fbbc67894c481 --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_tracing_stub.cc @@ -0,0 +1,127 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/internal/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WidgetServiceTracingStub::WidgetServiceTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +StatusOr +WidgetServiceTracingStub::GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.WidgetService", + "GenerateChatToken"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->GenerateChatToken(context, options, request)); +} + +StatusOr +WidgetServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.WidgetService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +WidgetServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.WidgetService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +WidgetServiceTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.WidgetService", + "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr WidgetServiceTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.WidgetService", + "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status WidgetServiceTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.WidgetService", + "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status WidgetServiceTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.ces.v1.WidgetService", + "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +std::shared_ptr MakeWidgetServiceTracingStub( + std::shared_ptr stub) { + return std::make_shared(std::move(stub)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/ces/v1/internal/widget_tracing_stub.h b/google/cloud/ces/v1/internal/widget_tracing_stub.h new file mode 100644 index 0000000000000..036813e6af8ea --- /dev/null +++ b/google/cloud/ces/v1/internal/widget_tracing_stub.h @@ -0,0 +1,92 @@ +// 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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_TRACING_STUB_H + +#include "google/cloud/ces/v1/internal/widget_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 ces_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WidgetServiceTracingStub : public WidgetServiceStub { + public: + ~WidgetServiceTracingStub() override = default; + + explicit WidgetServiceTracingStub(std::shared_ptr child); + + StatusOr GenerateChatToken( + grpc::ClientContext& context, Options const& options, + google::cloud::ces::v1::GenerateChatTokenRequest 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 MakeWidgetServiceTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_INTERNAL_WIDGET_TRACING_STUB_H diff --git a/google/cloud/ces/v1/mocks/mock_agent_connection.h b/google/cloud/ces/v1/mocks/mock_agent_connection.h new file mode 100644 index 0000000000000..117974e9e6775 --- /dev/null +++ b/google/cloud/ces/v1/mocks/mock_agent_connection.h @@ -0,0 +1,471 @@ +// 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/ces/v1/agent_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_AGENT_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_AGENT_CONNECTION_H + +#include "google/cloud/ces/v1/agent_connection.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `AgentServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `AgentServiceClient`. To do so, + * construct an object of type `AgentServiceClient` 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 MockAgentServiceConnection : public ces_v1::AgentServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD((StreamRange), ListApps, + (google::cloud::ces::v1::ListAppsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetApp, + (google::cloud::ces::v1::GetAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreateApp(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, CreateApp, + (google::cloud::ces::v1::CreateAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, CreateApp(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, CreateApp, + (NoAwaitTag, + google::cloud::ces::v1::CreateAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, CreateApp(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, CreateApp, + (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, UpdateApp, + (google::cloud::ces::v1::UpdateAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeleteApp(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeleteApp, + (google::cloud::ces::v1::DeleteAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeleteApp(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, DeleteApp, + (NoAwaitTag, + google::cloud::ces::v1::DeleteAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, DeleteApp(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeleteApp, (google::longrunning::Operation const& operation), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// ExportApp(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + ExportApp, + (google::cloud::ces::v1::ExportAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, ExportApp(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, ExportApp, + (NoAwaitTag, + google::cloud::ces::v1::ExportAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, ExportApp(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + ExportApp, (google::longrunning::Operation const& operation), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// ImportApp(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + ImportApp, + (google::cloud::ces::v1::ImportAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, ImportApp(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, ImportApp, + (NoAwaitTag, + google::cloud::ces::v1::ImportAppRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, ImportApp(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + ImportApp, (google::longrunning::Operation const& operation), + (override)); + + MOCK_METHOD((StreamRange), ListAgents, + (google::cloud::ces::v1::ListAgentsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetAgent, + (google::cloud::ces::v1::GetAgentRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, CreateAgent, + (google::cloud::ces::v1::CreateAgentRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, UpdateAgent, + (google::cloud::ces::v1::UpdateAgentRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteAgent, + (google::cloud::ces::v1::DeleteAgentRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListExamples, + (google::cloud::ces::v1::ListExamplesRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetExample, + (google::cloud::ces::v1::GetExampleRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, CreateExample, + (google::cloud::ces::v1::CreateExampleRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, UpdateExample, + (google::cloud::ces::v1::UpdateExampleRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteExample, + (google::cloud::ces::v1::DeleteExampleRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListTools, + (google::cloud::ces::v1::ListToolsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetTool, + (google::cloud::ces::v1::GetToolRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), + ListConversations, + (google::cloud::ces::v1::ListConversationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetConversation, + (google::cloud::ces::v1::GetConversationRequest const& request), + (override)); + + MOCK_METHOD( + Status, DeleteConversation, + (google::cloud::ces::v1::DeleteConversationRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// BatchDeleteConversations(Matcher(_))) + /// @endcode + MOCK_METHOD( + future< + StatusOr>, + BatchDeleteConversations, + (google::cloud::ces::v1::BatchDeleteConversationsRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, BatchDeleteConversations(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, BatchDeleteConversations, + (NoAwaitTag, + google::cloud::ces::v1::BatchDeleteConversationsRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// BatchDeleteConversations(Matcher(_))) + /// @endcode + MOCK_METHOD( + future< + StatusOr>, + BatchDeleteConversations, + (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, CreateTool, + (google::cloud::ces::v1::CreateToolRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, UpdateTool, + (google::cloud::ces::v1::UpdateToolRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteTool, + (google::cloud::ces::v1::DeleteToolRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListGuardrails, + (google::cloud::ces::v1::ListGuardrailsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetGuardrail, + (google::cloud::ces::v1::GetGuardrailRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, CreateGuardrail, + (google::cloud::ces::v1::CreateGuardrailRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, UpdateGuardrail, + (google::cloud::ces::v1::UpdateGuardrailRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteGuardrail, + (google::cloud::ces::v1::DeleteGuardrailRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), + ListDeployments, + (google::cloud::ces::v1::ListDeploymentsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetDeployment, + (google::cloud::ces::v1::GetDeploymentRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, CreateDeployment, + (google::cloud::ces::v1::CreateDeploymentRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, UpdateDeployment, + (google::cloud::ces::v1::UpdateDeploymentRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteDeployment, + (google::cloud::ces::v1::DeleteDeploymentRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListToolsets, + (google::cloud::ces::v1::ListToolsetsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetToolset, + (google::cloud::ces::v1::GetToolsetRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, CreateToolset, + (google::cloud::ces::v1::CreateToolsetRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, UpdateToolset, + (google::cloud::ces::v1::UpdateToolsetRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteToolset, + (google::cloud::ces::v1::DeleteToolsetRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), + ListAppVersions, + (google::cloud::ces::v1::ListAppVersionsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetAppVersion, + (google::cloud::ces::v1::GetAppVersionRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, CreateAppVersion, + (google::cloud::ces::v1::CreateAppVersionRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteAppVersion, + (google::cloud::ces::v1::DeleteAppVersionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// RestoreAppVersion(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + RestoreAppVersion, + (google::cloud::ces::v1::RestoreAppVersionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, RestoreAppVersion(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, RestoreAppVersion, + (NoAwaitTag, + google::cloud::ces::v1::RestoreAppVersionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// RestoreAppVersion(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + RestoreAppVersion, (google::longrunning::Operation const& operation), + (override)); + + MOCK_METHOD((StreamRange), ListChangelogs, + (google::cloud::ces::v1::ListChangelogsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetChangelog, + (google::cloud::ces::v1::GetChangelogRequest 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 ces_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_AGENT_CONNECTION_H diff --git a/google/cloud/ces/v1/mocks/mock_session_connection.h b/google/cloud/ces/v1/mocks/mock_session_connection.h new file mode 100644 index 0000000000000..1e104dd842589 --- /dev/null +++ b/google/cloud/ces/v1/mocks/mock_session_connection.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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_SESSION_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_SESSION_CONNECTION_H + +#include "google/cloud/ces/v1/session_connection.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `SessionServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `SessionServiceClient`. To do so, + * construct an object of type `SessionServiceClient` 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 MockSessionServiceConnection : public ces_v1::SessionServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD(StatusOr, RunSession, + (google::cloud::ces::v1::RunSessionRequest const& request), + (override)); + + MOCK_METHOD((std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>>), + AsyncBidiRunSession, (), (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 ces_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_SESSION_CONNECTION_H diff --git a/google/cloud/ces/v1/mocks/mock_tool_connection.h b/google/cloud/ces/v1/mocks/mock_tool_connection.h new file mode 100644 index 0000000000000..715f067c4d420 --- /dev/null +++ b/google/cloud/ces/v1/mocks/mock_tool_connection.h @@ -0,0 +1,94 @@ +// 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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_TOOL_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_TOOL_CONNECTION_H + +#include "google/cloud/ces/v1/tool_connection.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `ToolServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `ToolServiceClient`. To do so, + * construct an object of type `ToolServiceClient` 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 MockToolServiceConnection : public ces_v1::ToolServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD(StatusOr, + ExecuteTool, + (google::cloud::ces::v1::ExecuteToolRequest const& request), + (override)); + + MOCK_METHOD( + StatusOr, + RetrieveToolSchema, + (google::cloud::ces::v1::RetrieveToolSchemaRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + RetrieveTools, + (google::cloud::ces::v1::RetrieveToolsRequest 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 ces_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_TOOL_CONNECTION_H diff --git a/google/cloud/ces/v1/mocks/mock_widget_connection.h b/google/cloud/ces/v1/mocks/mock_widget_connection.h new file mode 100644 index 0000000000000..728d6784b5f7f --- /dev/null +++ b/google/cloud/ces/v1/mocks/mock_widget_connection.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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_WIDGET_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_WIDGET_CONNECTION_H + +#include "google/cloud/ces/v1/widget_connection.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `WidgetServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `WidgetServiceClient`. To do so, + * construct an object of type `WidgetServiceClient` 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 MockWidgetServiceConnection : public ces_v1::WidgetServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD(StatusOr, + GenerateChatToken, + (google::cloud::ces::v1::GenerateChatTokenRequest 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 ces_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_MOCKS_MOCK_WIDGET_CONNECTION_H diff --git a/google/cloud/ces/v1/samples/agent_client_samples.cc b/google/cloud/ces/v1/samples/agent_client_samples.cc new file mode 100644 index 0000000000000..ed547d22e94d1 --- /dev/null +++ b/google/cloud/ces/v1/samples/agent_client_samples.cc @@ -0,0 +1,220 @@ +// 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/ces/v1/agent_service.proto + +#include "google/cloud/ces/v1/agent_client.h" +#include "google/cloud/ces/v1/agent_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/agent_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: ces_v1::AgentServiceClient +// 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::ces_v1::AgentServiceClient( + google::cloud::ces_v1::MakeAgentServiceConnection(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::ces_v1::AgentServiceClient( + google::cloud::ces_v1::MakeAgentServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::ces_v1::AgentServiceConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr< + google::cloud::ces_v1::AgentServiceConnectionIdempotencyPolicy> + 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::ces_v1::AgentServiceLimitedErrorCountRetryPolicy(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::ces_v1::MakeAgentServiceConnection(options); + + // c1 and c2 share the same retry policies + auto c1 = google::cloud::ces_v1::AgentServiceClient(connection); + auto c2 = google::cloud::ces_v1::AgentServiceClient(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::ces_v1::AgentServiceClient( + connection, + google::cloud::Options{} + .set( + google::cloud::ces_v1::AgentServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::ces_v1::AgentServiceLimitedErrorCountRetryPolicy(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::ces_v1::AgentServiceRetryPolicyOption::Type, + google::cloud::ces_v1::AgentServiceBackoffPolicyOption::Type>( + google::cloud::ces_v1::AgentServiceLimitedTimeRetryPolicy( + /*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::ces_v1::MakeAgentServiceConnection(options); + + // c1 and c2 share the same polling policies. + auto c1 = google::cloud::ces_v1::AgentServiceClient(connection); + auto c2 = google::cloud::ces_v1::AgentServiceClient(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::ces_v1::AgentServiceClient( + google::cloud::ces_v1::MakeAgentServiceConnection(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/ces/v1/samples/session_client_samples.cc b/google/cloud/ces/v1/samples/session_client_samples.cc new file mode 100644 index 0000000000000..3107865f4cdd7 --- /dev/null +++ b/google/cloud/ces/v1/samples/session_client_samples.cc @@ -0,0 +1,180 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/session_client.h" +#include "google/cloud/ces/v1/session_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/session_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: ces_v1::SessionServiceClient +// 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::ces_v1::SessionServiceClient( + google::cloud::ces_v1::MakeSessionServiceConnection(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::ces_v1::SessionServiceClient( + google::cloud::ces_v1::MakeSessionServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::ces_v1::SessionServiceConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr< + google::cloud::ces_v1::SessionServiceConnectionIdempotencyPolicy> + 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::ces_v1::SessionServiceLimitedErrorCountRetryPolicy( + 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::ces_v1::MakeSessionServiceConnection(options); + + // c1 and c2 share the same retry policies + auto c1 = google::cloud::ces_v1::SessionServiceClient(connection); + auto c2 = google::cloud::ces_v1::SessionServiceClient(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::ces_v1::SessionServiceClient( + connection, + google::cloud::Options{} + .set( + google::cloud::ces_v1::SessionServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::ces_v1::SessionServiceLimitedErrorCountRetryPolicy(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::ces_v1::SessionServiceClient( + google::cloud::ces_v1::MakeSessionServiceConnection(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/ces/v1/samples/tool_client_samples.cc b/google/cloud/ces/v1/samples/tool_client_samples.cc new file mode 100644 index 0000000000000..0b923afc4dcdd --- /dev/null +++ b/google/cloud/ces/v1/samples/tool_client_samples.cc @@ -0,0 +1,177 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/tool_client.h" +#include "google/cloud/ces/v1/tool_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/tool_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: ces_v1::ToolServiceClient +// 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::ces_v1::ToolServiceClient( + google::cloud::ces_v1::MakeToolServiceConnection(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::ces_v1::ToolServiceClient( + google::cloud::ces_v1::MakeToolServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::ces_v1::ToolServiceConnectionIdempotencyPolicy { + 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::ces_v1::ToolServiceLimitedErrorCountRetryPolicy(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::ces_v1::MakeToolServiceConnection(options); + + // c1 and c2 share the same retry policies + auto c1 = google::cloud::ces_v1::ToolServiceClient(connection); + auto c2 = google::cloud::ces_v1::ToolServiceClient(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::ces_v1::ToolServiceClient( + connection, + google::cloud::Options{} + .set( + google::cloud::ces_v1::ToolServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::ces_v1::ToolServiceLimitedErrorCountRetryPolicy(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::ces_v1::ToolServiceClient( + google::cloud::ces_v1::MakeToolServiceConnection(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/ces/v1/samples/widget_client_samples.cc b/google/cloud/ces/v1/samples/widget_client_samples.cc new file mode 100644 index 0000000000000..f48b9bf64f9ca --- /dev/null +++ b/google/cloud/ces/v1/samples/widget_client_samples.cc @@ -0,0 +1,179 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/widget_client.h" +#include "google/cloud/ces/v1/widget_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/widget_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: ces_v1::WidgetServiceClient +// 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::ces_v1::WidgetServiceClient( + google::cloud::ces_v1::MakeWidgetServiceConnection(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::ces_v1::WidgetServiceClient( + google::cloud::ces_v1::MakeWidgetServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::ces_v1::WidgetServiceConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr< + google::cloud::ces_v1::WidgetServiceConnectionIdempotencyPolicy> + 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::ces_v1::WidgetServiceLimitedErrorCountRetryPolicy( + 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::ces_v1::MakeWidgetServiceConnection(options); + + // c1 and c2 share the same retry policies + auto c1 = google::cloud::ces_v1::WidgetServiceClient(connection); + auto c2 = google::cloud::ces_v1::WidgetServiceClient(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::ces_v1::WidgetServiceClient( + connection, + google::cloud::Options{} + .set( + google::cloud::ces_v1::WidgetServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::ces_v1::WidgetServiceLimitedErrorCountRetryPolicy(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::ces_v1::WidgetServiceClient( + google::cloud::ces_v1::MakeWidgetServiceConnection(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/ces/v1/session_client.cc b/google/cloud/ces/v1/session_client.cc new file mode 100644 index 0000000000000..64ee8fcf074d9 --- /dev/null +++ b/google/cloud/ces/v1/session_client.cc @@ -0,0 +1,125 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/session_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SessionServiceClient::SessionServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +SessionServiceClient::~SessionServiceClient() = default; + +StatusOr +SessionServiceClient::RunSession( + google::cloud::ces::v1::RunSessionRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RunSession(request); +} + +std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> +SessionServiceClient::AsyncBidiRunSession(Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->AsyncBidiRunSession(); +} + +StreamRange +SessionServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr SessionServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange +SessionServiceClient::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 +SessionServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr SessionServiceClient::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 SessionServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status SessionServiceClient::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 SessionServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status SessionServiceClient::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 SessionServiceClient::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 ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/session_client.h b/google/cloud/ces/v1/session_client.h new file mode 100644 index 0000000000000..7e945dddf1b3f --- /dev/null +++ b/google/cloud/ces/v1/session_client.h @@ -0,0 +1,572 @@ +// 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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CLIENT_H + +#include "google/cloud/ces/v1/session_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Session service provides APIs for interacting with CES agents. +/// +/// @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 SessionServiceClient { + public: + explicit SessionServiceClient( + std::shared_ptr connection, Options opts = {}); + ~SessionServiceClient(); + + ///@{ + /// @name Copy and move support + SessionServiceClient(SessionServiceClient const&) = default; + SessionServiceClient& operator=(SessionServiceClient const&) = default; + SessionServiceClient(SessionServiceClient&&) = default; + SessionServiceClient& operator=(SessionServiceClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(SessionServiceClient const& a, + SessionServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(SessionServiceClient const& a, + SessionServiceClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Initiates a single turn interaction with the CES agent within a + /// session. + /// + /// @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.ces.v1.RunSessionRequest]. + /// 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.ces.v1.RunSessionResponse]) + /// 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.ces.v1.RunSessionRequest]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L403} + /// [google.cloud.ces.v1.RunSessionResponse]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L413} + /// + // clang-format on + StatusOr RunSession( + google::cloud::ces::v1::RunSessionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Establishes a bidirectional streaming connection with the CES agent. + /// The agent processes continuous multimodal inputs (e.g., text, audio) and + /// generates real-time multimodal output streams. + /// + /// - Client Request Stream - + /// The client streams requests in the following order: + /// + /// 1. Initialization: + /// The first message must contain + /// [SessionConfig][google.cloud.ces.v1.BidiSessionClientMessage.config]. + /// For audio sessions, this should also include + /// [InputAudioConfig][google.cloud.ces.v1.SessionConfig.input_audio_config] + /// and + /// [OutputAudioConfig][google.cloud.ces.v1.SessionConfig.output_audio_config] + /// to define audio processing and synthesis parameters. + /// + /// 2. Interaction: + /// Subsequent messages stream + /// [SessionInput][google.cloud.ces.v1.BidiSessionClientMessage.realtime_input] + /// containing real-time user input data. + /// + /// 3. Termination: + /// The client should half-close the stream when there is no more user + /// input. It should also half-close upon receiving + /// [EndSession][google.cloud.ces.v1.BidiSessionServerMessage.end_session] + /// or [GoAway][google.cloud.ces.v1.BidiSessionServerMessage.go_away] from + /// the agent. + /// + /// - Server Response Stream - + /// For each interaction turn, the agent streams messages in the following + /// sequence: + /// + /// 1. Speech Recognition (First N messages): + /// Contains + /// [RecognitionResult][google.cloud.ces.v1.BidiSessionServerMessage.recognition_result] + /// representing the concatenated user speech segments captured so far. + /// This is only populated for audio sessions. + /// + /// 2. Response (Next M messages): + /// Contains + /// [SessionOutput][google.cloud.ces.v1.BidiSessionServerMessage.session_output] + /// delivering the agent's response in various modalities (e.g., text, + /// audio). + /// + /// 3. Turn Completion (Final message of the turn): + /// Contains + /// [SessionOutput][google.cloud.ces.v1.BidiSessionServerMessage.session_output] + /// with [turn_completed][google.cloud.ces.v1.SessionOutput.turn_completed] + /// set to true. This signals the end of the current turn and includes + /// [DiagnosticInfo][google.cloud.ces.v1.SessionOutput.diagnostic_info] + /// with execution details. + /// + /// - Audio Best Practices - + /// 1. Streaming: + /// Stream [audio data][google.cloud.ces.v1.SessionInput.audio] + /// **CONTINUOUSLY**, even during silence. Recommended chunk size: 40-120ms + /// (balances latency vs. efficiency). + /// + /// 2. Playback & Interruption: + /// Play [audio responses][google.cloud.ces.v1.SessionOutput.audio] upon + /// receipt. Stop playback immediately if an + /// [InterruptionSignal][google.cloud.ces.v1.BidiSessionServerMessage.interruption_signal] + /// is received (e.g., user barge-in or new agent response). + /// + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return An object representing the bidirectional streaming + /// RPC. Applications can send multiple request messages and receive + /// multiple response messages through this API. Bidirectional streaming + /// RPCs can impose restrictions on the sequence of request and response + /// messages. Please consult the service documentation for details. + /// The request message type ([google.cloud.ces.v1.BidiSessionClientMessage]) and response messages + /// ([google.cloud.ces.v1.BidiSessionServerMessage]) are mapped to C++ classes 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 + /// [`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.ces.v1.BidiSessionClientMessage]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L421} + /// [google.cloud.ces.v1.BidiSessionClientMessage.config]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L425} + /// [google.cloud.ces.v1.BidiSessionClientMessage.realtime_input]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L428} + /// [google.cloud.ces.v1.BidiSessionServerMessage]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L435} + /// [google.cloud.ces.v1.BidiSessionServerMessage.end_session]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L450} + /// [google.cloud.ces.v1.BidiSessionServerMessage.go_away]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L454} + /// [google.cloud.ces.v1.BidiSessionServerMessage.interruption_signal]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L446} + /// [google.cloud.ces.v1.BidiSessionServerMessage.recognition_result]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L442} + /// [google.cloud.ces.v1.BidiSessionServerMessage.session_output]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L439} + /// [google.cloud.ces.v1.SessionConfig.input_audio_config]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L190} + /// [google.cloud.ces.v1.SessionConfig.output_audio_config]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L194} + /// [google.cloud.ces.v1.SessionInput.audio]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L285} + /// [google.cloud.ces.v1.SessionOutput.audio]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L336} + /// [google.cloud.ces.v1.SessionOutput.diagnostic_info]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L367} + /// [google.cloud.ces.v1.SessionOutput.turn_completed]: @googleapis_reference_link{google/cloud/ces/v1/session_service.proto#L362} + /// + // clang-format on + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession(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 ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CLIENT_H diff --git a/google/cloud/ces/v1/session_connection.cc b/google/cloud/ces/v1/session_connection.cc new file mode 100644 index 0000000000000..14ada5eb017af --- /dev/null +++ b/google/cloud/ces/v1/session_connection.cc @@ -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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/session_connection.h" +#include "google/cloud/ces/v1/internal/session_connection_impl.h" +#include "google/cloud/ces/v1/internal/session_option_defaults.h" +#include "google/cloud/ces/v1/internal/session_stub_factory.h" +#include "google/cloud/ces/v1/internal/session_tracing_connection.h" +#include "google/cloud/ces/v1/session_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SessionServiceConnection::~SessionServiceConnection() = default; + +StatusOr +SessionServiceConnection::RunSession( + google::cloud::ces::v1::RunSessionRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> +SessionServiceConnection::AsyncBidiRunSession() { + return std::make_unique< + ::google::cloud::internal::AsyncStreamingReadWriteRpcError< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +SessionServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SessionServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +SessionServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SessionServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status SessionServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr MakeSessionServiceConnection( + Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = ces_v1_internal::SessionServiceDefaultOptions(std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = ces_v1_internal::CreateDefaultSessionServiceStub(std::move(auth), + options); + return ces_v1_internal::MakeSessionServiceTracingConnection( + std::make_shared( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/session_connection.h b/google/cloud/ces/v1/session_connection.h new file mode 100644 index 0000000000000..48a9e1ceec634 --- /dev/null +++ b/google/cloud/ces/v1/session_connection.h @@ -0,0 +1,242 @@ +// 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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CONNECTION_H + +#include "google/cloud/ces/v1/internal/session_retry_traits.h" +#include "google/cloud/ces/v1/session_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/session_service.pb.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/internal/async_read_write_stream_impl.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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `SessionServiceConnection`. +class SessionServiceRetryPolicy : 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 `SessionServiceConnection` 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 SessionServiceLimitedErrorCountRetryPolicy + : public SessionServiceRetryPolicy { + 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 SessionServiceLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + SessionServiceLimitedErrorCountRetryPolicy( + SessionServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : SessionServiceLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + SessionServiceLimitedErrorCountRetryPolicy( + SessionServiceLimitedErrorCountRetryPolicy const& rhs) noexcept + : SessionServiceLimitedErrorCountRetryPolicy(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 = SessionServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + ces_v1_internal::SessionServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `SessionServiceConnection` 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 SessionServiceLimitedTimeRetryPolicy : public SessionServiceRetryPolicy { + 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 SessionServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + SessionServiceLimitedTimeRetryPolicy( + SessionServiceLimitedTimeRetryPolicy&& rhs) noexcept + : SessionServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + SessionServiceLimitedTimeRetryPolicy( + SessionServiceLimitedTimeRetryPolicy const& rhs) noexcept + : SessionServiceLimitedTimeRetryPolicy(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 = SessionServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + ces_v1_internal::SessionServiceRetryTraits> + impl_; +}; + +/** + * The `SessionServiceConnection` object for `SessionServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `SessionServiceClient`. This allows users to inject custom behavior + * (e.g., with a Google Mock object) when writing tests that use objects of type + * `SessionServiceClient`. + * + * To create a concrete instance, see `MakeSessionServiceConnection()`. + * + * For mocking, see `ces_v1_mocks::MockSessionServiceConnection`. + */ +class SessionServiceConnection { + public: + virtual ~SessionServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StatusOr RunSession( + google::cloud::ces::v1::RunSessionRequest const& request); + + virtual std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::cloud::ces::v1::BidiSessionClientMessage, + google::cloud::ces::v1::BidiSessionServerMessage>> + AsyncBidiRunSession(); + + 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 `SessionServiceConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of SessionServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `SessionServiceConnection`. Expected options are any of the types in + * the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::ces_v1::SessionServicePolicyOptionList` + * + * @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 `SessionServiceConnection` created by + * this function. + */ +std::shared_ptr MakeSessionServiceConnection( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CONNECTION_H diff --git a/google/cloud/ces/v1/session_connection_idempotency_policy.cc b/google/cloud/ces/v1/session_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..4443e42587b0c --- /dev/null +++ b/google/cloud/ces/v1/session_connection_idempotency_policy.cc @@ -0,0 +1,80 @@ +// 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/ces/v1/session_service.proto + +#include "google/cloud/ces/v1/session_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +SessionServiceConnectionIdempotencyPolicy:: + ~SessionServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +SessionServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency SessionServiceConnectionIdempotencyPolicy::RunSession( + google::cloud::ces::v1::RunSessionRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SessionServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SessionServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SessionServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SessionServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultSessionServiceConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/session_connection_idempotency_policy.h b/google/cloud/ces/v1/session_connection_idempotency_policy.h new file mode 100644 index 0000000000000..0b77dfbdaa45f --- /dev/null +++ b/google/cloud/ces/v1/session_connection_idempotency_policy.h @@ -0,0 +1,72 @@ +// 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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/ces/v1/session_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SessionServiceConnectionIdempotencyPolicy { + public: + virtual ~SessionServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() + const; + + virtual google::cloud::Idempotency RunSession( + google::cloud::ces::v1::RunSessionRequest 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 +MakeDefaultSessionServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/ces/v1/session_options.h b/google/cloud/ces/v1/session_options.h new file mode 100644 index 0000000000000..40f11db72571a --- /dev/null +++ b/google/cloud/ces/v1/session_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/ces/v1/session_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_OPTIONS_H + +#include "google/cloud/ces/v1/session_connection.h" +#include "google/cloud/ces/v1/session_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-ces-options + */ +struct SessionServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-ces-options + */ +struct SessionServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-ces-options + */ +struct SessionServiceConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to SessionService. + * + * @ingroup google-cloud-ces-options + */ +using SessionServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_SESSION_OPTIONS_H diff --git a/google/cloud/ces/v1/tool_client.cc b/google/cloud/ces/v1/tool_client.cc new file mode 100644 index 0000000000000..c59f9255bdfdb --- /dev/null +++ b/google/cloud/ces/v1/tool_client.cc @@ -0,0 +1,129 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/tool_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +ToolServiceClient::ToolServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +ToolServiceClient::~ToolServiceClient() = default; + +StatusOr +ToolServiceClient::ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ExecuteTool(request); +} + +StatusOr +ToolServiceClient::RetrieveToolSchema( + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RetrieveToolSchema(request); +} + +StatusOr +ToolServiceClient::RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RetrieveTools(request); +} + +StreamRange ToolServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ToolServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange ToolServiceClient::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 ToolServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr ToolServiceClient::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 ToolServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status ToolServiceClient::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 ToolServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status ToolServiceClient::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 ToolServiceClient::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 ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/tool_client.h b/google/cloud/ces/v1/tool_client.h new file mode 100644 index 0000000000000..9dc0eaecbaa4d --- /dev/null +++ b/google/cloud/ces/v1/tool_client.h @@ -0,0 +1,530 @@ +// 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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CLIENT_H + +#include "google/cloud/ces/v1/tool_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Tool service provides APIs for interacting with CES tools. +/// +/// @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 ToolServiceClient { + public: + explicit ToolServiceClient(std::shared_ptr connection, + Options opts = {}); + ~ToolServiceClient(); + + ///@{ + /// @name Copy and move support + ToolServiceClient(ToolServiceClient const&) = default; + ToolServiceClient& operator=(ToolServiceClient const&) = default; + ToolServiceClient(ToolServiceClient&&) = default; + ToolServiceClient& operator=(ToolServiceClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(ToolServiceClient const& a, + ToolServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(ToolServiceClient const& a, + ToolServiceClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Executes the given tool with the given arguments. + /// + /// @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.ces.v1.ExecuteToolRequest]. + /// 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.ces.v1.ExecuteToolResponse]) + /// 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.ces.v1.ExecuteToolRequest]: @googleapis_reference_link{google/cloud/ces/v1/tool_service.proto#L69} + /// [google.cloud.ces.v1.ExecuteToolResponse]: @googleapis_reference_link{google/cloud/ces/v1/tool_service.proto#L100} + /// + // clang-format on + StatusOr ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Retrieve the schema of the given tool. The schema is computed on the fly + /// for the given instance of the tool. + /// + /// @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.ces.v1.RetrieveToolSchemaRequest]. + /// 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.ces.v1.RetrieveToolSchemaResponse]) + /// 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.ces.v1.RetrieveToolSchemaRequest]: @googleapis_reference_link{google/cloud/ces/v1/tool_service.proto#L121} + /// [google.cloud.ces.v1.RetrieveToolSchemaResponse]: @googleapis_reference_link{google/cloud/ces/v1/tool_service.proto#L149} + /// + // clang-format on + StatusOr + RetrieveToolSchema( + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Retrieve the list of tools included in the specified toolset. + /// + /// @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.ces.v1.RetrieveToolsRequest]. + /// 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.ces.v1.RetrieveToolsResponse]) + /// 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.ces.v1.RetrieveToolsRequest]: @googleapis_reference_link{google/cloud/ces/v1/tool_service.proto#L170} + /// [google.cloud.ces.v1.RetrieveToolsResponse]: @googleapis_reference_link{google/cloud/ces/v1/tool_service.proto#L186} + /// + // clang-format on + StatusOr RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest 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 ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CLIENT_H diff --git a/google/cloud/ces/v1/tool_connection.cc b/google/cloud/ces/v1/tool_connection.cc new file mode 100644 index 0000000000000..abbb839aaca3b --- /dev/null +++ b/google/cloud/ces/v1/tool_connection.cc @@ -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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/tool_connection.h" +#include "google/cloud/ces/v1/internal/tool_connection_impl.h" +#include "google/cloud/ces/v1/internal/tool_option_defaults.h" +#include "google/cloud/ces/v1/internal/tool_stub_factory.h" +#include "google/cloud/ces/v1/internal/tool_tracing_connection.h" +#include "google/cloud/ces/v1/tool_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +ToolServiceConnection::~ToolServiceConnection() = default; + +StatusOr +ToolServiceConnection::ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ToolServiceConnection::RetrieveToolSchema( + google::cloud::ces::v1::RetrieveToolSchemaRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ToolServiceConnection::RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +ToolServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ToolServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +ToolServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ToolServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ToolServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status ToolServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr MakeToolServiceConnection( + Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = ces_v1_internal::ToolServiceDefaultOptions(std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = + ces_v1_internal::CreateDefaultToolServiceStub(std::move(auth), options); + return ces_v1_internal::MakeToolServiceTracingConnection( + std::make_shared( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/tool_connection.h b/google/cloud/ces/v1/tool_connection.h new file mode 100644 index 0000000000000..2a05b36103273 --- /dev/null +++ b/google/cloud/ces/v1/tool_connection.h @@ -0,0 +1,242 @@ +// 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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CONNECTION_H + +#include "google/cloud/ces/v1/internal/tool_retry_traits.h" +#include "google/cloud/ces/v1/tool_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/tool_service.pb.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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `ToolServiceConnection`. +class ToolServiceRetryPolicy : 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 `ToolServiceConnection` 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 ToolServiceLimitedErrorCountRetryPolicy : public ToolServiceRetryPolicy { + 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 ToolServiceLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + ToolServiceLimitedErrorCountRetryPolicy( + ToolServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : ToolServiceLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + ToolServiceLimitedErrorCountRetryPolicy( + ToolServiceLimitedErrorCountRetryPolicy const& rhs) noexcept + : ToolServiceLimitedErrorCountRetryPolicy(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 = ToolServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + ces_v1_internal::ToolServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `ToolServiceConnection` 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 ToolServiceLimitedTimeRetryPolicy : public ToolServiceRetryPolicy { + 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 ToolServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + ToolServiceLimitedTimeRetryPolicy( + ToolServiceLimitedTimeRetryPolicy&& rhs) noexcept + : ToolServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + ToolServiceLimitedTimeRetryPolicy( + ToolServiceLimitedTimeRetryPolicy const& rhs) noexcept + : ToolServiceLimitedTimeRetryPolicy(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 = ToolServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + ces_v1_internal::ToolServiceRetryTraits> + impl_; +}; + +/** + * The `ToolServiceConnection` object for `ToolServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `ToolServiceClient`. This allows users to inject custom behavior + * (e.g., with a Google Mock object) when writing tests that use objects of type + * `ToolServiceClient`. + * + * To create a concrete instance, see `MakeToolServiceConnection()`. + * + * For mocking, see `ces_v1_mocks::MockToolServiceConnection`. + */ +class ToolServiceConnection { + public: + virtual ~ToolServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StatusOr ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const& request); + + virtual StatusOr + RetrieveToolSchema( + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request); + + virtual StatusOr RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest 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 `ToolServiceConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of ToolServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `ToolServiceConnection`. Expected options are any of the types in + * the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::ces_v1::ToolServicePolicyOptionList` + * + * @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 `ToolServiceConnection` created by + * this function. + */ +std::shared_ptr MakeToolServiceConnection( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CONNECTION_H diff --git a/google/cloud/ces/v1/tool_connection_idempotency_policy.cc b/google/cloud/ces/v1/tool_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..f2ca90c41835c --- /dev/null +++ b/google/cloud/ces/v1/tool_connection_idempotency_policy.cc @@ -0,0 +1,90 @@ +// 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/ces/v1/tool_service.proto + +#include "google/cloud/ces/v1/tool_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +ToolServiceConnectionIdempotencyPolicy:: + ~ToolServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +ToolServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::RetrieveToolSchema( + google::cloud::ces::v1::RetrieveToolSchemaRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency ToolServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultToolServiceConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/tool_connection_idempotency_policy.h b/google/cloud/ces/v1/tool_connection_idempotency_policy.h new file mode 100644 index 0000000000000..a5fbdfced6f9b --- /dev/null +++ b/google/cloud/ces/v1/tool_connection_idempotency_policy.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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/ces/v1/tool_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class ToolServiceConnectionIdempotencyPolicy { + public: + virtual ~ToolServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() const; + + virtual google::cloud::Idempotency ExecuteTool( + google::cloud::ces::v1::ExecuteToolRequest const& request); + + virtual google::cloud::Idempotency RetrieveToolSchema( + google::cloud::ces::v1::RetrieveToolSchemaRequest const& request); + + virtual google::cloud::Idempotency RetrieveTools( + google::cloud::ces::v1::RetrieveToolsRequest 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 +MakeDefaultToolServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/ces/v1/tool_options.h b/google/cloud/ces/v1/tool_options.h new file mode 100644 index 0000000000000..8b7868f1650e4 --- /dev/null +++ b/google/cloud/ces/v1/tool_options.h @@ -0,0 +1,75 @@ +// 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/ces/v1/tool_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_OPTIONS_H + +#include "google/cloud/ces/v1/tool_connection.h" +#include "google/cloud/ces/v1/tool_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-ces-options + */ +struct ToolServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-ces-options + */ +struct ToolServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-ces-options + */ +struct ToolServiceConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to ToolService. + * + * @ingroup google-cloud-ces-options + */ +using ToolServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_TOOL_OPTIONS_H diff --git a/google/cloud/ces/v1/widget_client.cc b/google/cloud/ces/v1/widget_client.cc new file mode 100644 index 0000000000000..e3fed48a9956e --- /dev/null +++ b/google/cloud/ces/v1/widget_client.cc @@ -0,0 +1,116 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/widget_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WidgetServiceClient::WidgetServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +WidgetServiceClient::~WidgetServiceClient() = default; + +StatusOr +WidgetServiceClient::GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GenerateChatToken(request); +} + +StreamRange +WidgetServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr WidgetServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange WidgetServiceClient::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 WidgetServiceClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr WidgetServiceClient::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 WidgetServiceClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status WidgetServiceClient::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 WidgetServiceClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status WidgetServiceClient::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 WidgetServiceClient::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 ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/widget_client.h b/google/cloud/ces/v1/widget_client.h new file mode 100644 index 0000000000000..c5aef4613edfa --- /dev/null +++ b/google/cloud/ces/v1/widget_client.h @@ -0,0 +1,467 @@ +// 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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CLIENT_H + +#include "google/cloud/ces/v1/widget_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Provides APIs for widgets to interact with CES APIs. +/// +/// @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 WidgetServiceClient { + public: + explicit WidgetServiceClient( + std::shared_ptr connection, Options opts = {}); + ~WidgetServiceClient(); + + ///@{ + /// @name Copy and move support + WidgetServiceClient(WidgetServiceClient const&) = default; + WidgetServiceClient& operator=(WidgetServiceClient const&) = default; + WidgetServiceClient(WidgetServiceClient&&) = default; + WidgetServiceClient& operator=(WidgetServiceClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(WidgetServiceClient const& a, + WidgetServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(WidgetServiceClient const& a, + WidgetServiceClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Generates a session scoped token for chat widget to authenticate with + /// Session APIs. + /// + /// @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.ces.v1.GenerateChatTokenRequest]. + /// 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.ces.v1.GenerateChatTokenResponse]) + /// 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.ces.v1.GenerateChatTokenRequest]: @googleapis_reference_link{google/cloud/ces/v1/widget_service.proto#L50} + /// [google.cloud.ces.v1.GenerateChatTokenResponse]: @googleapis_reference_link{google/cloud/ces/v1/widget_service.proto#L73} + /// + // clang-format on + StatusOr GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest 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 ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CLIENT_H diff --git a/google/cloud/ces/v1/widget_connection.cc b/google/cloud/ces/v1/widget_connection.cc new file mode 100644 index 0000000000000..6494a44498973 --- /dev/null +++ b/google/cloud/ces/v1/widget_connection.cc @@ -0,0 +1,103 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/widget_connection.h" +#include "google/cloud/ces/v1/internal/widget_connection_impl.h" +#include "google/cloud/ces/v1/internal/widget_option_defaults.h" +#include "google/cloud/ces/v1/internal/widget_stub_factory.h" +#include "google/cloud/ces/v1/internal/widget_tracing_connection.h" +#include "google/cloud/ces/v1/widget_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WidgetServiceConnection::~WidgetServiceConnection() = default; + +StatusOr +WidgetServiceConnection::GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +WidgetServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +WidgetServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +WidgetServiceConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr WidgetServiceConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WidgetServiceConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WidgetServiceConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr MakeWidgetServiceConnection( + Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = ces_v1_internal::WidgetServiceDefaultOptions(std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = + ces_v1_internal::CreateDefaultWidgetServiceStub(std::move(auth), options); + return ces_v1_internal::MakeWidgetServiceTracingConnection( + std::make_shared( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/widget_connection.h b/google/cloud/ces/v1/widget_connection.h new file mode 100644 index 0000000000000..c5ea0446d1f6a --- /dev/null +++ b/google/cloud/ces/v1/widget_connection.h @@ -0,0 +1,237 @@ +// 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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CONNECTION_H + +#include "google/cloud/ces/v1/internal/widget_retry_traits.h" +#include "google/cloud/ces/v1/widget_connection_idempotency_policy.h" +#include "google/cloud/ces/v1/widget_service.pb.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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `WidgetServiceConnection`. +class WidgetServiceRetryPolicy : 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 `WidgetServiceConnection` 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 WidgetServiceLimitedErrorCountRetryPolicy + : public WidgetServiceRetryPolicy { + 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 WidgetServiceLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + WidgetServiceLimitedErrorCountRetryPolicy( + WidgetServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : WidgetServiceLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + WidgetServiceLimitedErrorCountRetryPolicy( + WidgetServiceLimitedErrorCountRetryPolicy const& rhs) noexcept + : WidgetServiceLimitedErrorCountRetryPolicy(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 = WidgetServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + ces_v1_internal::WidgetServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `WidgetServiceConnection` 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 WidgetServiceLimitedTimeRetryPolicy : public WidgetServiceRetryPolicy { + 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 WidgetServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + WidgetServiceLimitedTimeRetryPolicy( + WidgetServiceLimitedTimeRetryPolicy&& rhs) noexcept + : WidgetServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + WidgetServiceLimitedTimeRetryPolicy( + WidgetServiceLimitedTimeRetryPolicy const& rhs) noexcept + : WidgetServiceLimitedTimeRetryPolicy(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 = WidgetServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + ces_v1_internal::WidgetServiceRetryTraits> + impl_; +}; + +/** + * The `WidgetServiceConnection` object for `WidgetServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `WidgetServiceClient`. This allows users to inject custom behavior + * (e.g., with a Google Mock object) when writing tests that use objects of type + * `WidgetServiceClient`. + * + * To create a concrete instance, see `MakeWidgetServiceConnection()`. + * + * For mocking, see `ces_v1_mocks::MockWidgetServiceConnection`. + */ +class WidgetServiceConnection { + public: + virtual ~WidgetServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StatusOr + GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest 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 `WidgetServiceConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of WidgetServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `WidgetServiceConnection`. Expected options are any of the types in + * the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::ces_v1::WidgetServicePolicyOptionList` + * + * @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 `WidgetServiceConnection` created by + * this function. + */ +std::shared_ptr MakeWidgetServiceConnection( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CONNECTION_H diff --git a/google/cloud/ces/v1/widget_connection_idempotency_policy.cc b/google/cloud/ces/v1/widget_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..834cdab91212a --- /dev/null +++ b/google/cloud/ces/v1/widget_connection_idempotency_policy.cc @@ -0,0 +1,80 @@ +// 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/ces/v1/widget_service.proto + +#include "google/cloud/ces/v1/widget_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +WidgetServiceConnectionIdempotencyPolicy:: + ~WidgetServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +WidgetServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency WidgetServiceConnectionIdempotencyPolicy::GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WidgetServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WidgetServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WidgetServiceConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WidgetServiceConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WidgetServiceConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WidgetServiceConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultWidgetServiceConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ces/v1/widget_connection_idempotency_policy.h b/google/cloud/ces/v1/widget_connection_idempotency_policy.h new file mode 100644 index 0000000000000..1ea699776382e --- /dev/null +++ b/google/cloud/ces/v1/widget_connection_idempotency_policy.h @@ -0,0 +1,72 @@ +// 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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/ces/v1/widget_service.grpc.pb.h" +#include "google/cloud/location/locations.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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WidgetServiceConnectionIdempotencyPolicy { + public: + virtual ~WidgetServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() + const; + + virtual google::cloud::Idempotency GenerateChatToken( + google::cloud::ces::v1::GenerateChatTokenRequest 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 +MakeDefaultWidgetServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/ces/v1/widget_options.h b/google/cloud/ces/v1/widget_options.h new file mode 100644 index 0000000000000..9c329d70250fa --- /dev/null +++ b/google/cloud/ces/v1/widget_options.h @@ -0,0 +1,75 @@ +// 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/ces/v1/widget_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_OPTIONS_H + +#include "google/cloud/ces/v1/widget_connection.h" +#include "google/cloud/ces/v1/widget_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 ces_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-ces-options + */ +struct WidgetServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-ces-options + */ +struct WidgetServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-ces-options + */ +struct WidgetServiceConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to WidgetService. + * + * @ingroup google-cloud-ces-options + */ +using WidgetServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ces_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_CES_V1_WIDGET_OPTIONS_H diff --git a/google/cloud/visionai/v1/warehouse_client.h b/google/cloud/visionai/v1/warehouse_client.h index 603d258a25841..e981dda785bc9 100644 --- a/google/cloud/visionai/v1/warehouse_client.h +++ b/google/cloud/visionai/v1/warehouse_client.h @@ -2574,7 +2574,7 @@ class WarehouseClient { /// Creates a search configuration inside a corpus. /// /// Please follow the rules below to create a valid CreateSearchConfigRequest. - /// General Rules: + /// - General Rules - /// 1. Request.search_config_id must not be associated with an existing /// SearchConfig. /// 2. Request must contain at least one non-empty search_criteria_property or @@ -2622,7 +2622,7 @@ class WarehouseClient { /// Creates a search configuration inside a corpus. /// /// Please follow the rules below to create a valid CreateSearchConfigRequest. - /// General Rules: + /// - General Rules - /// 1. Request.search_config_id must not be associated with an existing /// SearchConfig. /// 2. Request must contain at least one non-empty search_criteria_property or @@ -2667,7 +2667,7 @@ class WarehouseClient { /// Updates a search configuration inside a corpus. /// /// Please follow the rules below to create a valid UpdateSearchConfigRequest. - /// General Rules: + /// - General Rules - /// 1. Request.search_configuration.name must already exist. /// 2. Request must contain at least one non-empty search_criteria_property or /// facet_property. @@ -2712,7 +2712,7 @@ class WarehouseClient { /// Updates a search configuration inside a corpus. /// /// Please follow the rules below to create a valid UpdateSearchConfigRequest. - /// General Rules: + /// - General Rules - /// 1. Request.search_configuration.name must already exist. /// 2. Request must contain at least one non-empty search_criteria_property or /// facet_property. diff --git a/libraries.bzl b/libraries.bzl index 686abeefdd091..69060fe50ca39 100644 --- a/libraries.bzl +++ b/libraries.bzl @@ -51,6 +51,7 @@ GOOGLE_CLOUD_CPP_GA_LIBRARIES = [ "billing", "binaryauthorization", "certificatemanager", + "ces", "channel", "chronicle", "cloudbuild",