diff --git a/CHANGELOG.md b/CHANGELOG.md index 97bf398e84348..408cef24ef171 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,9 @@ for details on updating existing applications using v1.x.y or v2.x.y. We are happy to announce the following GA libraries. Unless specifically noted, the APIs in these libraries are stable, and are ready for production use. +- [Gemini Enterprise for Customer Experience API](google/cloud/ces/README.md) - [Vision AI API](/google/cloud/visionai/README.md) +- [Workload Manager](/google/cloud/workloadmanager/README.md) ## v3.2.0 - 2026-02 diff --git a/README.md b/README.md index 96cd5f3bd33f6..e27e630f5d5a3 100644 --- a/README.md +++ b/README.md @@ -563,6 +563,9 @@ See each library's `README.md` file for more information about: - [Workflow Executions API](google/cloud/workflows/README.md) [[quickstart]](google/cloud/workflows/quickstart/README.md) [[reference]](https://cloud.google.com/cpp/docs/reference/workflows/latest) +- [Workload Manager API](google/cloud/workloadmanager/README.md) + [[quickstart]](google/cloud/workloadmanager/quickstart/README.md) + [[reference]](https://cloud.google.com/cpp/docs/reference/workloadmanager/latest) - [Cloud Workstations API](google/cloud/workstations/README.md) [[quickstart]](google/cloud/workstations/quickstart/README.md) [[reference]](https://cloud.google.com/cpp/docs/reference/workstations/latest) diff --git a/ci/abi-dumps/google_cloud_cpp_workloadmanager.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_workloadmanager.expected.abi.dump.gz new file mode 100644 index 0000000000000..3d85b9b183459 Binary files /dev/null and b/ci/abi-dumps/google_cloud_cpp_workloadmanager.expected.abi.dump.gz differ diff --git a/ci/etc/expected_install_directories b/ci/etc/expected_install_directories index f79126b8dfe5f..f3426ee849677 100644 --- a/ci/etc/expected_install_directories +++ b/ci/etc/expected_install_directories @@ -1216,6 +1216,10 @@ ./include/google/cloud/workflows/v1 ./include/google/cloud/workflows/v1/internal ./include/google/cloud/workflows/v1/mocks +./include/google/cloud/workloadmanager +./include/google/cloud/workloadmanager/v1 +./include/google/cloud/workloadmanager/v1/internal +./include/google/cloud/workloadmanager/v1/mocks ./include/google/cloud/workstations ./include/google/cloud/workstations/v1 ./include/google/cloud/workstations/v1/internal @@ -1586,5 +1590,7 @@ ./lib64/cmake/google_cloud_cpp_websecurityscanner_mocks ./lib64/cmake/google_cloud_cpp_workflows ./lib64/cmake/google_cloud_cpp_workflows_mocks +./lib64/cmake/google_cloud_cpp_workloadmanager +./lib64/cmake/google_cloud_cpp_workloadmanager_mocks ./lib64/cmake/google_cloud_cpp_workstations ./lib64/cmake/google_cloud_cpp_workstations_mocks diff --git a/cmake/GoogleCloudCppFeatures.cmake b/cmake/GoogleCloudCppFeatures.cmake index 25561b78911d0..45e0edc5e497f 100644 --- a/cmake/GoogleCloudCppFeatures.cmake +++ b/cmake/GoogleCloudCppFeatures.cmake @@ -196,6 +196,7 @@ set(GOOGLE_CLOUD_CPP_GA_LIBRARIES "webrisk" "websecurityscanner" "workflows" + "workloadmanager" "workstations") set(GOOGLE_CLOUD_CPP_COMPUTE_LIBRARIES diff --git a/external/googleapis/protodeps/workloadmanager.deps b/external/googleapis/protodeps/workloadmanager.deps new file mode 100644 index 0000000000000..3a69eb58546e0 --- /dev/null +++ b/external/googleapis/protodeps/workloadmanager.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/workloadmanager.list b/external/googleapis/protolists/workloadmanager.list new file mode 100644 index 0000000000000..ce90280dbc802 --- /dev/null +++ b/external/googleapis/protolists/workloadmanager.list @@ -0,0 +1 @@ +@googleapis//google/cloud/workloadmanager/v1:service.proto diff --git a/external/googleapis/update_libraries.sh b/external/googleapis/update_libraries.sh index 3a1370e92a8d9..ca9595c156431 100755 --- a/external/googleapis/update_libraries.sh +++ b/external/googleapis/update_libraries.sh @@ -351,6 +351,7 @@ declare -A -r LIBRARIES=( "@googleapis//google/cloud/workflows/type:type_cc_grpc" \ "@googleapis//google/cloud/workflows/executions/v1:executions_cc_grpc" )" + ["workloadmanager"]="@googleapis//google/cloud/workloadmanager/v1:workloadmanager_cc_grpc" ["workstations"]="$( printf ",%s" \ "@googleapis//google/cloud/workstations/logging/v1:logging_cc_grpc" \ diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index 210c7b6e89a6f..59e79839593a5 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -4165,6 +4165,14 @@ service { retryable_status_codes: ["kUnavailable"] } +# Workload Manager +service { + service_proto_path: "google/cloud/workloadmanager/v1/service.proto" + product_path: "google/cloud/workloadmanager/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] +} + # Workstations service { service_proto_path: "google/cloud/workstations/v1/workstations.proto" diff --git a/google/cloud/workloadmanager/BUILD.bazel b/google/cloud/workloadmanager/BUILD.bazel new file mode 100644 index 0000000000000..d43e336b24af1 --- /dev/null +++ b/google/cloud/workloadmanager/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/workloadmanager/v1:workloadmanager_cc_grpc", +] + +cc_gapic_library( + name = "workloadmanager", + googleapis_deps = googleapis_deps, + service_dirs = service_dirs, +) diff --git a/google/cloud/workloadmanager/CMakeLists.txt b/google/cloud/workloadmanager/CMakeLists.txt new file mode 100644 index 0000000000000..c825e6687093c --- /dev/null +++ b/google/cloud/workloadmanager/CMakeLists.txt @@ -0,0 +1,35 @@ +# ~~~ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +include(GoogleCloudCppLibrary) + +google_cloud_cpp_add_gapic_library(workloadmanager "Workload Manager API" + SERVICE_DIRS "v1/") + +if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS) + add_executable(workloadmanager_quickstart "quickstart/quickstart.cc") + target_link_libraries(workloadmanager_quickstart + PRIVATE google-cloud-cpp::workloadmanager) + google_cloud_cpp_add_common_options(workloadmanager_quickstart) + add_test( + NAME workloadmanager_quickstart + COMMAND + cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake" + $ GOOGLE_CLOUD_PROJECT + GOOGLE_CLOUD_CPP_TEST_REGION) + set_tests_properties(workloadmanager_quickstart + PROPERTIES LABELS "integration-test;quickstart") +endif () diff --git a/google/cloud/workloadmanager/README.md b/google/cloud/workloadmanager/README.md new file mode 100644 index 0000000000000..f856aca88dc40 --- /dev/null +++ b/google/cloud/workloadmanager/README.md @@ -0,0 +1,63 @@ +# Workload Manager API C++ Client Library + +This directory contains an idiomatic C++ client library for the +[Workload Manager API][cloud-service-docs]. + +Workload Manager is a service that provides tooling for enterprise workloads to +automate the deployment and validation of your workloads against best practices +and recommendations. + +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/workloadmanager/v1/workload_manager_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 workloadmanager = ::google::cloud::workloadmanager_v1; + auto client = workloadmanager::WorkloadManagerClient( + workloadmanager::MakeWorkloadManagerConnection()); + + for (auto r : client.ListEvaluations(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 [Workload Manager 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/workload-manager/docs +[doxygen-link]: https://cloud.google.com/cpp/docs/reference/workloadmanager/latest/ +[source-link]: https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/workloadmanager diff --git a/google/cloud/workloadmanager/doc/environment-variables.dox b/google/cloud/workloadmanager/doc/environment-variables.dox new file mode 100644 index 0000000000000..bd4c3459c1035 --- /dev/null +++ b/google/cloud/workloadmanager/doc/environment-variables.dox @@ -0,0 +1,49 @@ +/*! +@page workloadmanager-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 workloadmanager-env-endpoint Endpoint Overrides + + + +- `GOOGLE_CLOUD_CPP_WORKLOAD_MANAGER_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "workloadmanager.googleapis.com") + used by `MakeWorkloadManagerConnection()`. + + + +@see google::cloud::EndpointOption + +@section workloadmanager-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 workloadmanager-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/workloadmanager/doc/main.dox b/google/cloud/workloadmanager/doc/main.dox new file mode 100644 index 0000000000000..c2274b0aff035 --- /dev/null +++ b/google/cloud/workloadmanager/doc/main.dox @@ -0,0 +1,50 @@ +/*! + +@mainpage Workload Manager API C++ Client Library + +An idiomatic C++ client library for the [Workload Manager API][cloud-service-docs]. + +Workload Manager is a service that provides tooling for enterprise +workloads to automate the deployment and validation of your workloads +against best practices and recommendations. + +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/workloadmanager/quickstart/` directory, +which should give you a taste of the Workload Manager API C++ client library API. + +@snippet quickstart.cc all + +## Main classes + + +The main class in this library is +[`workloadmanager_v1::WorkloadManagerClient`](@ref google::cloud::workloadmanager_v1::WorkloadManagerClient). All RPCs are exposed +as member functions of this class. Other classes provide helpers, configuration +parameters, and infrastructure to mock +[`workloadmanager_v1::WorkloadManagerClient`](@ref google::cloud::workloadmanager_v1::WorkloadManagerClient) when testing your +application. + + +## More Information + +- @ref common-error-handling - describes how the library reports errors. +- @ref workloadmanager-override-endpoint - describes how to override the default + endpoint. +- @ref workloadmanager-override-authentication - describes how to change the + authentication credentials used by the library. +- @ref workloadmanager-override-retry - describes how to change the default retry + policies. +- @ref workloadmanager-env - describes environment variables that can configure the + behavior of the library. +- @ref workloadmanager-override-universe-domain - describes how to override the default universe domain. + +[cloud-service-docs]: https://docs.cloud.google.com/workload-manager/docs + +*/ diff --git a/google/cloud/workloadmanager/doc/options.dox b/google/cloud/workloadmanager/doc/options.dox new file mode 100644 index 0000000000000..5e6391ae1b68b --- /dev/null +++ b/google/cloud/workloadmanager/doc/options.dox @@ -0,0 +1,10 @@ +/*! +@defgroup google-cloud-workloadmanager-options Workload Manager 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/workloadmanager/doc/override-authentication.dox b/google/cloud/workloadmanager/doc/override-authentication.dox new file mode 100644 index 0000000000000..c88623cf0cf26 --- /dev/null +++ b/google/cloud/workloadmanager/doc/override-authentication.dox @@ -0,0 +1,35 @@ +/*! +@page workloadmanager-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 workload_manager_client_samples.cc with-service-account + + + +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 workloadmanager_v1::WorkloadManagerClient-service-account-snippet Override workloadmanager_v1::WorkloadManagerClient Authentication Defaults + +@snippet google/cloud/workloadmanager/v1/samples/workload_manager_client_samples.cc with-service-account + +*/ +// diff --git a/google/cloud/workloadmanager/doc/override-endpoint.dox b/google/cloud/workloadmanager/doc/override-endpoint.dox new file mode 100644 index 0000000000000..29a45e7dc1152 --- /dev/null +++ b/google/cloud/workloadmanager/doc/override-endpoint.dox @@ -0,0 +1,25 @@ +/*! +@page workloadmanager-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 `workloadmanager_v1::WorkloadManagerClient`: + +@snippet workload_manager_client_samples.cc set-client-endpoint + + + +*/ + +// + +/*! @page workloadmanager_v1::WorkloadManagerClient-endpoint-snippet Override workloadmanager_v1::WorkloadManagerClient Endpoint Configuration + +@snippet google/cloud/workloadmanager/v1/samples/workload_manager_client_samples.cc set-client-endpoint + +*/ +// diff --git a/google/cloud/workloadmanager/doc/override-retry-policies.dox b/google/cloud/workloadmanager/doc/override-retry-policies.dox new file mode 100644 index 0000000000000..a686e4500bbea --- /dev/null +++ b/google/cloud/workloadmanager/doc/override-retry-policies.dox @@ -0,0 +1,108 @@ +/*! +@page workloadmanager-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 workloadmanager-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 workloadmanager-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 workloadmanager-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 workloadmanager-override-retry-example Example + + +For example, this will override the retry policies for `workloadmanager_v1::WorkloadManagerClient`: + +@snippet workload_manager_client_samples.cc set-retry-policy + +This assumes you have created a custom idempotency policy. Such as: + +@snippet workload_manager_client_samples.cc custom-idempotency-policy + +This will override the polling policies for `workloadmanager_v1::WorkloadManagerClient` + +@snippet workload_manager_client_samples.cc set-polling-policy + + + + +@section workloadmanager-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 workloadmanager_v1::WorkloadManagerClient-retry-snippet Override workloadmanager_v1::WorkloadManagerClient Retry Policies + +This shows how to override the retry policies for workloadmanager_v1::WorkloadManagerClient: + +@snippet google/cloud/workloadmanager/v1/samples/workload_manager_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/workloadmanager/v1/samples/workload_manager_client_samples.cc custom-idempotency-policy + +*/ +// diff --git a/google/cloud/workloadmanager/doc/override-universe-domain.dox b/google/cloud/workloadmanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..0bf06728649f3 --- /dev/null +++ b/google/cloud/workloadmanager/doc/override-universe-domain.dox @@ -0,0 +1,24 @@ +/*! +@page workloadmanager-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 `workloadmanager_v1::WorkloadManagerClient`: + +@snippet workload_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page workloadmanager_v1::WorkloadManagerClient-universe-domain-snippet Override workloadmanager_v1::WorkloadManagerClient Universe Domain + +@snippet google/cloud/workloadmanager/v1/samples/workload_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/workloadmanager/quickstart/.bazelrc b/google/cloud/workloadmanager/quickstart/.bazelrc new file mode 100644 index 0000000000000..c884db46c2b4d --- /dev/null +++ b/google/cloud/workloadmanager/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/workloadmanager/quickstart/BUILD.bazel b/google/cloud/workloadmanager/quickstart/BUILD.bazel new file mode 100644 index 0000000000000..0d1df16d51c6c --- /dev/null +++ b/google/cloud/workloadmanager/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//:workloadmanager", + ], +) diff --git a/google/cloud/workloadmanager/quickstart/CMakeLists.txt b/google/cloud/workloadmanager/quickstart/CMakeLists.txt new file mode 100644 index 0000000000000..ea9c6a1b94f07 --- /dev/null +++ b/google/cloud/workloadmanager/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 Workload Manager API C++ client library from a +# larger CMake project. + +cmake_minimum_required(VERSION 3.22...3.31) +project(google-cloud-cpp-workloadmanager-quickstart CXX) + +find_package(google_cloud_cpp_workloadmanager 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::workloadmanager) diff --git a/google/cloud/workloadmanager/quickstart/Makefile b/google/cloud/workloadmanager/quickstart/Makefile new file mode 100644 index 0000000000000..e8e75c309e9ea --- /dev/null +++ b/google/cloud/workloadmanager/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 Workload Manager 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 Workload Manager API C++ +# client library. +CLIENT_MODULE := google_cloud_cpp_workloadmanager +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/workloadmanager/quickstart/README.md b/google/cloud/workloadmanager/quickstart/README.md new file mode 100644 index 0000000000000..bb0d9b44d7008 --- /dev/null +++ b/google/cloud/workloadmanager/quickstart/README.md @@ -0,0 +1,135 @@ +# HOWTO: using the Workload Manager API C++ client in your project + +This directory contains small examples showing how to use the Workload Manager +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, Workload Manager 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/workloadmanager/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,workloadmanager] + ``` + + 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/workloadmanager/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/workloadmanager/quickstart/WORKSPACE.bazel b/google/cloud/workloadmanager/quickstart/WORKSPACE.bazel new file mode 100644 index 0000000000000..e93ff813a590e --- /dev/null +++ b/google/cloud/workloadmanager/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 Workload Manager 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/workloadmanager/quickstart/quickstart.cc b/google/cloud/workloadmanager/quickstart/quickstart.cc new file mode 100644 index 0000000000000..089dffd1e3d8e --- /dev/null +++ b/google/cloud/workloadmanager/quickstart/quickstart.cc @@ -0,0 +1,42 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! [all] +#include "google/cloud/workloadmanager/v1/workload_manager_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 workloadmanager = ::google::cloud::workloadmanager_v1; + auto client = workloadmanager::WorkloadManagerClient( + workloadmanager::MakeWorkloadManagerConnection()); + + for (auto r : client.ListEvaluations(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/workloadmanager/v1/.repo-metadata.json b/google/cloud/workloadmanager/v1/.repo-metadata.json new file mode 100644 index 0000000000000..05dc57006f644 --- /dev/null +++ b/google/cloud/workloadmanager/v1/.repo-metadata.json @@ -0,0 +1,14 @@ +{ + "api_id": "workloadmanager.googleapis.com", + "api_shortname": "workloadmanager", + "client_documentation": "https://cloud.google.com/cpp/docs/reference/workloadmanager/latest", + "distribution_name": "google-cloud-cpp", + "issue_tracker": "https://issuetracker.google.com/issues?q=componentid:1631482%20status=open", + "language": "cpp", + "library_type": "GAPIC_AUTO", + "name_pretty": "Workload Manager API", + "product_documentation": "https://docs.cloud.google.com/workload-manager/docs", + "release_level": "stable", + "repo": "googleapis/google-cloud-cpp", + "requires_billing": true +} diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.cc new file mode 100644 index 0000000000000..e4d50b6159e9c --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.cc @@ -0,0 +1,339 @@ +// 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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.h" +#include "google/cloud/workloadmanager/v1/service.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WorkloadManagerAuth::WorkloadManagerAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr +WorkloadManagerAuth::ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListEvaluations(context, options, request); +} + +StatusOr +WorkloadManagerAuth::GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetEvaluation(context, options, request); +} + +future> +WorkloadManagerAuth::AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest 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->AsyncCreateEvaluation(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr WorkloadManagerAuth::CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateEvaluation(context, options, request); +} + +future> +WorkloadManagerAuth::AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest 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->AsyncUpdateEvaluation(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr WorkloadManagerAuth::UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateEvaluation(context, options, request); +} + +future> +WorkloadManagerAuth::AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest 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->AsyncDeleteEvaluation(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr WorkloadManagerAuth::DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteEvaluation(context, options, request); +} + +StatusOr +WorkloadManagerAuth::ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListExecutions(context, options, request); +} + +StatusOr +WorkloadManagerAuth::GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetExecution(context, options, request); +} + +future> +WorkloadManagerAuth::AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest 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->AsyncRunEvaluation(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr WorkloadManagerAuth::RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->RunEvaluation(context, options, request); +} + +future> +WorkloadManagerAuth::AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest 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->AsyncDeleteExecution(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr WorkloadManagerAuth::DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteExecution(context, options, request); +} + +StatusOr +WorkloadManagerAuth::ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListExecutionResults(context, options, request); +} + +StatusOr +WorkloadManagerAuth::ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListRules(context, options, request); +} + +StatusOr +WorkloadManagerAuth::ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListScannedResources(context, options, request); +} + +StatusOr +WorkloadManagerAuth::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 WorkloadManagerAuth::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 +WorkloadManagerAuth::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 WorkloadManagerAuth::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 WorkloadManagerAuth::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 WorkloadManagerAuth::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> +WorkloadManagerAuth::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 WorkloadManagerAuth::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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.h b/google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.h new file mode 100644 index 0000000000000..e445fe39002e7 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.h @@ -0,0 +1,192 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_AUTH_DECORATOR_H + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WorkloadManagerAuth : public WorkloadManagerStub { + public: + ~WorkloadManagerAuth() override = default; + WorkloadManagerAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr + ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) + override; + + StatusOr GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) + override; + + future> AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + StatusOr CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + future> AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + StatusOr UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + future> AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr + ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) + override; + + StatusOr GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) + override; + + future> AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + StatusOr RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + future> AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr + ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) override; + + StatusOr ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) + override; + + StatusOr + ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_AUTH_DECORATOR_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.cc new file mode 100644 index 0000000000000..96bfd93aa44bc --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.cc @@ -0,0 +1,857 @@ +// 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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_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 workloadmanager_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 + +WorkloadManagerConnectionImpl::WorkloadManagerConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions(std::move(options), + WorkloadManagerConnection::options())) {} + +StreamRange +WorkloadManagerConnectionImpl::ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListEvaluations(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::workloadmanager::v1::ListEvaluationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1:: + ListEvaluationsRequest const& request) { + return stub->ListEvaluations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::workloadmanager::v1::ListEvaluationsResponse r) { + std::vector result( + r.evaluations().size()); + auto& messages = *r.mutable_evaluations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +WorkloadManagerConnectionImpl::GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetEvaluation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& + request) { + return stub_->GetEvaluation(context, options, request); + }, + *current, request, __func__); +} + +future> +WorkloadManagerConnectionImpl::CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->CreateEvaluation(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::workloadmanager::v1::Evaluation>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + return stub->AsyncCreateEvaluation(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::workloadmanager::v1::Evaluation>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +WorkloadManagerConnectionImpl::CreateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateEvaluation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + return stub_->CreateEvaluation(context, options, request); + }, + *current, request, __func__); +} + +future> +WorkloadManagerConnectionImpl::CreateEvaluation( + 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 CreateEvaluation", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::workloadmanager::v1::Evaluation>( + 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::workloadmanager::v1::Evaluation>, + polling_policy(*current), __func__); +} + +future> +WorkloadManagerConnectionImpl::UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->UpdateEvaluation(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::workloadmanager::v1::Evaluation>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + return stub->AsyncUpdateEvaluation(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::workloadmanager::v1::Evaluation>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +WorkloadManagerConnectionImpl::UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateEvaluation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + return stub_->UpdateEvaluation(context, options, request); + }, + *current, request, __func__); +} + +future> +WorkloadManagerConnectionImpl::UpdateEvaluation( + 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 UpdateEvaluation", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::workloadmanager::v1::Evaluation>( + 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::workloadmanager::v1::Evaluation>, + polling_policy(*current), __func__); +} + +future> +WorkloadManagerConnectionImpl::DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->DeleteEvaluation(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::workloadmanager::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::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + return stub->AsyncDeleteEvaluation(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::workloadmanager::v1::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +WorkloadManagerConnectionImpl::DeleteEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteEvaluation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + return stub_->DeleteEvaluation(context, options, request); + }, + *current, request, __func__); +} + +future> +WorkloadManagerConnectionImpl::DeleteEvaluation( + 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 DeleteEvaluation", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::workloadmanager::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::workloadmanager::v1::OperationMetadata>, + polling_policy(*current), __func__); +} + +StreamRange +WorkloadManagerConnectionImpl::ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListExecutions(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::workloadmanager::v1::ListExecutionsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& + request) { + return stub->ListExecutions(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::workloadmanager::v1::ListExecutionsResponse r) { + std::vector result( + r.executions().size()); + auto& messages = *r.mutable_executions(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +WorkloadManagerConnectionImpl::GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetExecution(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& + request) { + return stub_->GetExecution(context, options, request); + }, + *current, request, __func__); +} + +future> +WorkloadManagerConnectionImpl::RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->RunEvaluation(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::workloadmanager::v1::Execution>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& + request) { + return stub->AsyncRunEvaluation(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::workloadmanager::v1::Execution>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +WorkloadManagerConnectionImpl::RunEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->RunEvaluation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& + request) { + return stub_->RunEvaluation(context, options, request); + }, + *current, request, __func__); +} + +future> +WorkloadManagerConnectionImpl::RunEvaluation( + 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 RunEvaluation", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::workloadmanager::v1::Execution>( + 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::workloadmanager::v1::Execution>, + polling_policy(*current), __func__); +} + +future> +WorkloadManagerConnectionImpl::DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->DeleteExecution(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::cloud::workloadmanager::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::workloadmanager::v1::DeleteExecutionRequest const& + request) { + return stub->AsyncDeleteExecution(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::workloadmanager::v1::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +WorkloadManagerConnectionImpl::DeleteExecution( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteExecution(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request) { + return stub_->DeleteExecution(context, options, request); + }, + *current, request, __func__); +} + +future> +WorkloadManagerConnectionImpl::DeleteExecution( + 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 DeleteExecution", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::cloud::workloadmanager::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::workloadmanager::v1::OperationMetadata>, + polling_policy(*current), __func__); +} + +StreamRange +WorkloadManagerConnectionImpl::ListExecutionResults( + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = + idempotency_policy(*current)->ListExecutionResults(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::workloadmanager::v1::ListExecutionResultsRequest const& + r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1:: + ListExecutionResultsRequest const& request) { + return stub->ListExecutionResults(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::workloadmanager::v1::ListExecutionResultsResponse r) { + std::vector result( + r.execution_results().size()); + auto& messages = *r.mutable_execution_results(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +WorkloadManagerConnectionImpl::ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->ListRules(request), + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + return stub_->ListRules(context, options, request); + }, + *current, request, __func__); +} + +StreamRange +WorkloadManagerConnectionImpl::ListScannedResources( + google::cloud::workloadmanager::v1::ListScannedResourcesRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = + idempotency_policy(*current)->ListScannedResources(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::workloadmanager::v1::ListScannedResourcesRequest const& + r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1:: + ListScannedResourcesRequest const& request) { + return stub->ListScannedResources(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::workloadmanager::v1::ListScannedResourcesResponse r) { + std::vector result( + r.scanned_resources().size()); + auto& messages = *r.mutable_scanned_resources(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StreamRange +WorkloadManagerConnectionImpl::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 +WorkloadManagerConnectionImpl::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 +WorkloadManagerConnectionImpl::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 +WorkloadManagerConnectionImpl::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 WorkloadManagerConnectionImpl::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 WorkloadManagerConnectionImpl::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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.h b/google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.h new file mode 100644 index 0000000000000..aadc87cdf5bb3 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.h @@ -0,0 +1,178 @@ +// 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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_CONNECTION_IMPL_H + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_retry_traits.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_stub.h" +#include "google/cloud/workloadmanager/v1/workload_manager_connection.h" +#include "google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.h" +#include "google/cloud/workloadmanager/v1/workload_manager_options.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include + +namespace google { +namespace cloud { +namespace workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WorkloadManagerConnectionImpl + : public workloadmanager_v1::WorkloadManagerConnection { + public: + ~WorkloadManagerConnectionImpl() override = default; + + WorkloadManagerConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options); + + Options options() override { return options_; } + + StreamRange ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest request) + override; + + StatusOr GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) + override; + + future> + CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + StatusOr CreateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + future> + CreateEvaluation(google::longrunning::Operation const& operation) override; + + future> + UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + StatusOr UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + future> + UpdateEvaluation(google::longrunning::Operation const& operation) override; + + future> + DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr DeleteEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + future> + DeleteEvaluation(google::longrunning::Operation const& operation) override; + + StreamRange ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest request) + override; + + StatusOr GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) + override; + + future> RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + StatusOr RunEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + future> RunEvaluation( + google::longrunning::Operation const& operation) override; + + future> + DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr DeleteExecution( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + future> + DeleteExecution(google::longrunning::Operation const& operation) override; + + StreamRange + ListExecutionResults( + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request) + override; + + StatusOr ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const& request) + override; + + StreamRange + ListScannedResources( + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_CONNECTION_IMPL_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.cc new file mode 100644 index 0000000000000..ae88dc4fb5c2b --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.cc @@ -0,0 +1,409 @@ +// 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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.h" +#include "google/cloud/workloadmanager/v1/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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WorkloadManagerLogging::WorkloadManagerLogging( + std::shared_ptr child, TracingOptions tracing_options, + std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +StatusOr +WorkloadManagerLogging::ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& + request) { + return child_->ListEvaluations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkloadManagerLogging::GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& + request) { + return child_->GetEvaluation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +WorkloadManagerLogging::AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + return child_->AsyncCreateEvaluation(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +WorkloadManagerLogging::CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + return child_->CreateEvaluation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +WorkloadManagerLogging::AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + return child_->AsyncUpdateEvaluation(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +WorkloadManagerLogging::UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + return child_->UpdateEvaluation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +WorkloadManagerLogging::AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + return child_->AsyncDeleteEvaluation(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +WorkloadManagerLogging::DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + return child_->DeleteEvaluation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkloadManagerLogging::ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& + request) { + return child_->ListExecutions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkloadManagerLogging::GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& + request) { + return child_->GetExecution(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +WorkloadManagerLogging::AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& + request) { + return child_->AsyncRunEvaluation(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr WorkloadManagerLogging::RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& + request) { + return child_->RunEvaluation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +WorkloadManagerLogging::AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request) { + return child_->AsyncDeleteExecution(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +WorkloadManagerLogging::DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request) { + return child_->DeleteExecution(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkloadManagerLogging::ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) { + return child_->ListExecutionResults(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkloadManagerLogging::ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + return child_->ListRules(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkloadManagerLogging::ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest const& + request) { + return child_->ListScannedResources(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkloadManagerLogging::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 WorkloadManagerLogging::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 +WorkloadManagerLogging::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 WorkloadManagerLogging::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 WorkloadManagerLogging::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 WorkloadManagerLogging::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> +WorkloadManagerLogging::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 WorkloadManagerLogging::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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.h b/google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.h new file mode 100644 index 0000000000000..504a5c1b9349f --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.h @@ -0,0 +1,192 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_LOGGING_DECORATOR_H + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WorkloadManagerLogging : public WorkloadManagerStub { + public: + ~WorkloadManagerLogging() override = default; + WorkloadManagerLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const& components); + + StatusOr + ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) + override; + + StatusOr GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) + override; + + future> AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + StatusOr CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + future> AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + StatusOr UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + future> AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr + ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) + override; + + StatusOr GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) + override; + + future> AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + StatusOr RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + future> AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr + ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) override; + + StatusOr ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) + override; + + StatusOr + ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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_; +}; // WorkloadManagerLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_LOGGING_DECORATOR_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.cc new file mode 100644 index 0000000000000..67edc95cfd9b7 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.cc @@ -0,0 +1,320 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.h" +#include "google/cloud/workloadmanager/v1/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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WorkloadManagerMetadata::WorkloadManagerMetadata( + 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 +WorkloadManagerMetadata::ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListEvaluations(context, options, request); +} + +StatusOr +WorkloadManagerMetadata::GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetEvaluation(context, options, request); +} + +future> +WorkloadManagerMetadata::AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + SetMetadata(*context, *options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AsyncCreateEvaluation(cq, std::move(context), + std::move(options), request); +} + +StatusOr +WorkloadManagerMetadata::CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreateEvaluation(context, options, request); +} + +future> +WorkloadManagerMetadata::AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + SetMetadata(*context, *options, + absl::StrCat("evaluation.name=", + internal::UrlEncode(request.evaluation().name()))); + return child_->AsyncUpdateEvaluation(cq, std::move(context), + std::move(options), request); +} + +StatusOr +WorkloadManagerMetadata::UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("evaluation.name=", + internal::UrlEncode(request.evaluation().name()))); + return child_->UpdateEvaluation(context, options, request); +} + +future> +WorkloadManagerMetadata::AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncDeleteEvaluation(cq, std::move(context), + std::move(options), request); +} + +StatusOr +WorkloadManagerMetadata::DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteEvaluation(context, options, request); +} + +StatusOr +WorkloadManagerMetadata::ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListExecutions(context, options, request); +} + +StatusOr +WorkloadManagerMetadata::GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetExecution(context, options, request); +} + +future> +WorkloadManagerMetadata::AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncRunEvaluation(cq, std::move(context), std::move(options), + request); +} + +StatusOr WorkloadManagerMetadata::RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->RunEvaluation(context, options, request); +} + +future> +WorkloadManagerMetadata::AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncDeleteExecution(cq, std::move(context), + std::move(options), request); +} + +StatusOr +WorkloadManagerMetadata::DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeleteExecution(context, options, request); +} + +StatusOr +WorkloadManagerMetadata::ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListExecutionResults(context, options, request); +} + +StatusOr +WorkloadManagerMetadata::ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListRules(context, options, request); +} + +StatusOr +WorkloadManagerMetadata::ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListScannedResources(context, options, request); +} + +StatusOr +WorkloadManagerMetadata::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 +WorkloadManagerMetadata::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 +WorkloadManagerMetadata::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 WorkloadManagerMetadata::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 WorkloadManagerMetadata::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 WorkloadManagerMetadata::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> +WorkloadManagerMetadata::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 WorkloadManagerMetadata::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 WorkloadManagerMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void WorkloadManagerMetadata::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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.h b/google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.h new file mode 100644 index 0000000000000..ace230d880be7 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.h @@ -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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_METADATA_DECORATOR_H + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WorkloadManagerMetadata : public WorkloadManagerStub { + public: + ~WorkloadManagerMetadata() override = default; + WorkloadManagerMetadata( + std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + StatusOr + ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) + override; + + StatusOr GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) + override; + + future> AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + StatusOr CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + future> AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + StatusOr UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + future> AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr + ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) + override; + + StatusOr GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) + override; + + future> AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + StatusOr RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + future> AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr + ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) override; + + StatusOr ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) + override; + + StatusOr + ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_METADATA_DECORATOR_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_option_defaults.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_option_defaults.cc new file mode 100644 index 0000000000000..021144eecc896 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_option_defaults.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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_option_defaults.h" +#include "google/cloud/workloadmanager/v1/workload_manager_connection.h" +#include "google/cloud/workloadmanager/v1/workload_manager_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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options WorkloadManagerDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_WORKLOAD_MANAGER_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_WORKLOAD_MANAGER_AUTHORITY", + "workloadmanager.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + workloadmanager_v1::WorkloadManagerLimitedTimeRetryPolicy( + 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< + workloadmanager_v1::WorkloadManagerRetryPolicyOption::Type, + workloadmanager_v1::WorkloadManagerBackoffPolicyOption::Type>( + options.get() + ->clone(), + ExponentialBackoffPolicy(std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling) + .clone()) + .clone()); + } + if (!options.has()) { + options.set< + workloadmanager_v1::WorkloadManagerConnectionIdempotencyPolicyOption>( + workloadmanager_v1:: + MakeDefaultWorkloadManagerConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_option_defaults.h b/google/cloud/workloadmanager/v1/internal/workload_manager_option_defaults.h new file mode 100644 index 0000000000000..2e2a291e68550 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options WorkloadManagerDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_OPTION_DEFAULTS_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_retry_traits.h b/google/cloud/workloadmanager/v1/internal/workload_manager_retry_traits.h new file mode 100644 index 0000000000000..7dac520bd1335 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct WorkloadManagerRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_RETRY_TRAITS_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_sources.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_sources.cc new file mode 100644 index 0000000000000..3127a1b168606 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_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/workloadmanager/v1/service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.cc" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.cc" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.cc" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.cc" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_option_defaults.cc" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_stub.cc" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_stub_factory.cc" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.cc" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_tracing_stub.cc" +#include "google/cloud/workloadmanager/v1/workload_manager_client.cc" +#include "google/cloud/workloadmanager/v1/workload_manager_connection.cc" +#include "google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_stub.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_stub.cc new file mode 100644 index 0000000000000..b6df8aa66f785 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_stub.cc @@ -0,0 +1,398 @@ +// 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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_stub.h" +#include "google/cloud/workloadmanager/v1/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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WorkloadManagerStub::~WorkloadManagerStub() = default; + +StatusOr +DefaultWorkloadManagerStub::ListEvaluations( + grpc::ClientContext& context, Options const&, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) { + google::cloud::workloadmanager::v1::ListEvaluationsResponse response; + auto status = grpc_stub_->ListEvaluations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkloadManagerStub::GetEvaluation( + grpc::ClientContext& context, Options const&, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) { + google::cloud::workloadmanager::v1::Evaluation response; + auto status = grpc_stub_->GetEvaluation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultWorkloadManagerStub::AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + return internal::MakeUnaryRpcImpl< + google::cloud::workloadmanager::v1::CreateEvaluationRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncCreateEvaluation(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultWorkloadManagerStub::CreateEvaluation( + grpc::ClientContext& context, Options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + google::longrunning::Operation response; + auto status = grpc_stub_->CreateEvaluation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultWorkloadManagerStub::AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + return internal::MakeUnaryRpcImpl< + google::cloud::workloadmanager::v1::UpdateEvaluationRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncUpdateEvaluation(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultWorkloadManagerStub::UpdateEvaluation( + grpc::ClientContext& context, Options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + google::longrunning::Operation response; + auto status = grpc_stub_->UpdateEvaluation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultWorkloadManagerStub::AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + return internal::MakeUnaryRpcImpl< + google::cloud::workloadmanager::v1::DeleteEvaluationRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncDeleteEvaluation(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultWorkloadManagerStub::DeleteEvaluation( + grpc::ClientContext& context, Options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + google::longrunning::Operation response; + auto status = grpc_stub_->DeleteEvaluation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkloadManagerStub::ListExecutions( + grpc::ClientContext& context, Options const&, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) { + google::cloud::workloadmanager::v1::ListExecutionsResponse response; + auto status = grpc_stub_->ListExecutions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkloadManagerStub::GetExecution( + grpc::ClientContext& context, Options const&, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) { + google::cloud::workloadmanager::v1::Execution response; + auto status = grpc_stub_->GetExecution(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultWorkloadManagerStub::AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::workloadmanager::v1::RunEvaluationRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncRunEvaluation(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultWorkloadManagerStub::RunEvaluation( + grpc::ClientContext& context, Options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->RunEvaluation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultWorkloadManagerStub::AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + return internal::MakeUnaryRpcImpl< + google::cloud::workloadmanager::v1::DeleteExecutionRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncDeleteExecution(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultWorkloadManagerStub::DeleteExecution( + grpc::ClientContext& context, Options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->DeleteExecution(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkloadManagerStub::ListExecutionResults( + grpc::ClientContext& context, Options const&, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) { + google::cloud::workloadmanager::v1::ListExecutionResultsResponse response; + auto status = grpc_stub_->ListExecutionResults(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkloadManagerStub::ListRules( + grpc::ClientContext& context, Options const&, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + google::cloud::workloadmanager::v1::ListRulesResponse response; + auto status = grpc_stub_->ListRules(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkloadManagerStub::ListScannedResources( + grpc::ClientContext& context, Options const&, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest const& + request) { + google::cloud::workloadmanager::v1::ListScannedResourcesResponse response; + auto status = grpc_stub_->ListScannedResources(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkloadManagerStub::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 +DefaultWorkloadManagerStub::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 +DefaultWorkloadManagerStub::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 +DefaultWorkloadManagerStub::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 DefaultWorkloadManagerStub::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 DefaultWorkloadManagerStub::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> +DefaultWorkloadManagerStub::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 DefaultWorkloadManagerStub::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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_stub.h b/google/cloud/workloadmanager/v1/internal/workload_manager_stub.h new file mode 100644 index 0000000000000..90324054f25c6 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_stub.h @@ -0,0 +1,353 @@ +// 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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_STUB_H + +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/workloadmanager/v1/service.grpc.pb.h" +#include "google/cloud/completion_queue.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WorkloadManagerStub { + public: + virtual ~WorkloadManagerStub() = 0; + + virtual StatusOr + ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& + request) = 0; + + virtual StatusOr + GetEvaluation(grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& + request) = 0; + + virtual future> + AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) = 0; + + virtual StatusOr CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) = 0; + + virtual future> + AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) = 0; + + virtual StatusOr UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) = 0; + + virtual future> + AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) = 0; + + virtual StatusOr DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) = 0; + + virtual StatusOr + ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& + request) = 0; + + virtual StatusOr GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& + request) = 0; + + virtual future> AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& + request) = 0; + + virtual StatusOr RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& + request) = 0; + + virtual future> AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request) = 0; + + virtual StatusOr DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request) = 0; + + virtual StatusOr< + google::cloud::workloadmanager::v1::ListExecutionResultsResponse> + ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) = 0; + + virtual StatusOr + ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) = 0; + + virtual StatusOr< + google::cloud::workloadmanager::v1::ListScannedResourcesResponse> + ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 DefaultWorkloadManagerStub : public WorkloadManagerStub { + public: + DefaultWorkloadManagerStub( + std::unique_ptr< + google::cloud::workloadmanager::v1::WorkloadManager::StubInterface> + grpc_stub, + std::unique_ptr + locations_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_stub_(std::move(operations_stub)) {} + + StatusOr + ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) + override; + + StatusOr GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) + override; + + future> AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + StatusOr CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + future> AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + StatusOr UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + future> AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr + ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) + override; + + StatusOr GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) + override; + + future> AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + StatusOr RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + future> AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr + ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) override; + + StatusOr ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) + override; + + StatusOr + ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest const& + request) override; + + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::unique_ptr< + google::cloud::workloadmanager::v1::WorkloadManager::StubInterface> + grpc_stub_; + std::unique_ptr + locations_stub_; + std::unique_ptr + operations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_STUB_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_stub_factory.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_stub_factory.cc new file mode 100644 index 0000000000000..030a5540c06be --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_stub_factory.cc @@ -0,0 +1,82 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_stub_factory.h" +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_auth_decorator.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_logging_decorator.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_metadata_decorator.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_stub.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_tracing_stub.h" +#include "google/cloud/workloadmanager/v1/service.grpc.pb.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include + +// Must be included last. +#include "google/cloud/ports_def.inc" + +namespace google { +namespace cloud { +namespace workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultWorkloadManagerStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::workloadmanager::v1::WorkloadManager::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 = MakeWorkloadManagerTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_stub_factory.h b/google/cloud/workloadmanager/v1/internal/workload_manager_stub_factory.h new file mode 100644 index 0000000000000..714c2955df136 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_STUB_FACTORY_H + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultWorkloadManagerStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_STUB_FACTORY_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.cc new file mode 100644 index 0000000000000..f12a3ff9d3005 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.cc @@ -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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WorkloadManagerTracingConnection::WorkloadManagerTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StreamRange +WorkloadManagerTracingConnection::ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::ListEvaluations"); + internal::OTelScope scope(span); + auto sr = child_->ListEvaluations(std::move(request)); + return internal::MakeTracedStreamRange< + google::cloud::workloadmanager::v1::Evaluation>(std::move(span), + std::move(sr)); +} + +StatusOr +WorkloadManagerTracingConnection::GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::GetEvaluation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetEvaluation(request)); +} + +future> +WorkloadManagerTracingConnection::CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::CreateEvaluation"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateEvaluation(request)); +} + +StatusOr +WorkloadManagerTracingConnection::CreateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::CreateEvaluation"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->CreateEvaluation(NoAwaitTag{}, request)); +} + +future> +WorkloadManagerTracingConnection::CreateEvaluation( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::CreateEvaluation"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->CreateEvaluation(operation)); +} + +future> +WorkloadManagerTracingConnection::UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::UpdateEvaluation"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->UpdateEvaluation(request)); +} + +StatusOr +WorkloadManagerTracingConnection::UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::UpdateEvaluation"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->UpdateEvaluation(NoAwaitTag{}, request)); +} + +future> +WorkloadManagerTracingConnection::UpdateEvaluation( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::UpdateEvaluation"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->UpdateEvaluation(operation)); +} + +future> +WorkloadManagerTracingConnection::DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::DeleteEvaluation"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteEvaluation(request)); +} + +StatusOr +WorkloadManagerTracingConnection::DeleteEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::DeleteEvaluation"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->DeleteEvaluation(NoAwaitTag{}, request)); +} + +future> +WorkloadManagerTracingConnection::DeleteEvaluation( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::DeleteEvaluation"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->DeleteEvaluation(operation)); +} + +StreamRange +WorkloadManagerTracingConnection::ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::ListExecutions"); + internal::OTelScope scope(span); + auto sr = child_->ListExecutions(std::move(request)); + return internal::MakeTracedStreamRange< + google::cloud::workloadmanager::v1::Execution>(std::move(span), + std::move(sr)); +} + +StatusOr +WorkloadManagerTracingConnection::GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::GetExecution"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetExecution(request)); +} + +future> +WorkloadManagerTracingConnection::RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::RunEvaluation"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->RunEvaluation(request)); +} + +StatusOr +WorkloadManagerTracingConnection::RunEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::RunEvaluation"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->RunEvaluation(NoAwaitTag{}, request)); +} + +future> +WorkloadManagerTracingConnection::RunEvaluation( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::RunEvaluation"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->RunEvaluation(operation)); +} + +future> +WorkloadManagerTracingConnection::DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::DeleteExecution"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteExecution(request)); +} + +StatusOr +WorkloadManagerTracingConnection::DeleteExecution( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::DeleteExecution"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->DeleteExecution(NoAwaitTag{}, request)); +} + +future> +WorkloadManagerTracingConnection::DeleteExecution( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::DeleteExecution"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteExecution(operation)); +} + +StreamRange +WorkloadManagerTracingConnection::ListExecutionResults( + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::ListExecutionResults"); + internal::OTelScope scope(span); + auto sr = child_->ListExecutionResults(std::move(request)); + return internal::MakeTracedStreamRange< + google::cloud::workloadmanager::v1::ExecutionResult>(std::move(span), + std::move(sr)); +} + +StatusOr +WorkloadManagerTracingConnection::ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::ListRules"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->ListRules(request)); +} + +StreamRange +WorkloadManagerTracingConnection::ListScannedResources( + google::cloud::workloadmanager::v1::ListScannedResourcesRequest request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::ListScannedResources"); + internal::OTelScope scope(span); + auto sr = child_->ListScannedResources(std::move(request)); + return internal::MakeTracedStreamRange< + google::cloud::workloadmanager::v1::ScannedResource>(std::move(span), + std::move(sr)); +} + +StreamRange +WorkloadManagerTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WorkloadManagerTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +WorkloadManagerTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WorkloadManagerTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status WorkloadManagerTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status WorkloadManagerTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan( + "workloadmanager_v1::WorkloadManagerConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr +MakeWorkloadManagerTracingConnection( + 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 workloadmanager_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.h b/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.h new file mode 100644 index 0000000000000..22d55ab128208 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.h @@ -0,0 +1,172 @@ +// 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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_TRACING_CONNECTION_H + +#include "google/cloud/workloadmanager/v1/workload_manager_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WorkloadManagerTracingConnection + : public workloadmanager_v1::WorkloadManagerConnection { + public: + ~WorkloadManagerTracingConnection() override = default; + + explicit WorkloadManagerTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StreamRange ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest request) + override; + + StatusOr GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) + override; + + future> + CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + StatusOr CreateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + future> + CreateEvaluation(google::longrunning::Operation const& operation) override; + + future> + UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + StatusOr UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + future> + UpdateEvaluation(google::longrunning::Operation const& operation) override; + + future> + DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr DeleteEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + future> + DeleteEvaluation(google::longrunning::Operation const& operation) override; + + StreamRange ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest request) + override; + + StatusOr GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) + override; + + future> RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + StatusOr RunEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + future> RunEvaluation( + google::longrunning::Operation const& operation) override; + + future> + DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr DeleteExecution( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + future> + DeleteExecution(google::longrunning::Operation const& operation) override; + + StreamRange + ListExecutionResults( + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request) + override; + + StatusOr ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const& request) + override; + + StreamRange + ListScannedResources( + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 +MakeWorkloadManagerTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_TRACING_CONNECTION_H diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_stub.cc b/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_stub.cc new file mode 100644 index 0000000000000..eaea46f70a2cf --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_stub.cc @@ -0,0 +1,372 @@ +// 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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WorkloadManagerTracingStub::WorkloadManagerTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +StatusOr +WorkloadManagerTracingStub::ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "ListEvaluations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListEvaluations(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "GetEvaluation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetEvaluation(context, options, request)); +} + +future> +WorkloadManagerTracingStub::AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "CreateEvaluation"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncCreateEvaluation(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +WorkloadManagerTracingStub::CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "CreateEvaluation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CreateEvaluation(context, options, request)); +} + +future> +WorkloadManagerTracingStub::AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "UpdateEvaluation"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncUpdateEvaluation(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +WorkloadManagerTracingStub::UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "UpdateEvaluation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->UpdateEvaluation(context, options, request)); +} + +future> +WorkloadManagerTracingStub::AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "DeleteEvaluation"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncDeleteEvaluation(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +WorkloadManagerTracingStub::DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "DeleteEvaluation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteEvaluation(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "ListExecutions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListExecutions(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "GetExecution"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetExecution(context, options, request)); +} + +future> +WorkloadManagerTracingStub::AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "RunEvaluation"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncRunEvaluation(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +WorkloadManagerTracingStub::RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "RunEvaluation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->RunEvaluation(context, options, request)); +} + +future> +WorkloadManagerTracingStub::AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "DeleteExecution"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = + child_->AsyncDeleteExecution(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +WorkloadManagerTracingStub::DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "DeleteExecution"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteExecution(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.cloud.workloadmanager.v1.WorkloadManager", + "ListExecutionResults"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->ListExecutionResults(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "ListRules"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListRules(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.cloud.workloadmanager.v1.WorkloadManager", + "ListScannedResources"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->ListScannedResources(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::ListOperations( + grpc::ClientContext& context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "ListOperations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListOperations(context, options, request)); +} + +StatusOr +WorkloadManagerTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +Status WorkloadManagerTracingStub::DeleteOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->DeleteOperation(context, options, request)); +} + +Status WorkloadManagerTracingStub::CancelOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workloadmanager.v1.WorkloadManager", "CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->CancelOperation(context, options, request)); +} + +future> +WorkloadManagerTracingStub::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 WorkloadManagerTracingStub::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 MakeWorkloadManagerTracingStub( + std::shared_ptr stub) { + return std::make_shared(std::move(stub)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" diff --git a/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_stub.h b/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_stub.h new file mode 100644 index 0000000000000..9da129e3f8c93 --- /dev/null +++ b/google/cloud/workloadmanager/v1/internal/workload_manager_tracing_stub.h @@ -0,0 +1,200 @@ +// 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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_TRACING_STUB_H + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_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 workloadmanager_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WorkloadManagerTracingStub : public WorkloadManagerStub { + public: + ~WorkloadManagerTracingStub() override = default; + + explicit WorkloadManagerTracingStub( + std::shared_ptr child); + + StatusOr + ListEvaluations( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListEvaluationsRequest const& request) + override; + + StatusOr GetEvaluation( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request) + override; + + future> AsyncCreateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + StatusOr CreateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request) override; + + future> AsyncUpdateEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + StatusOr UpdateEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request) override; + + future> AsyncDeleteEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr DeleteEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request) override; + + StatusOr + ListExecutions( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionsRequest const& request) + override; + + StatusOr GetExecution( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::GetExecutionRequest const& request) + override; + + future> AsyncRunEvaluation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + StatusOr RunEvaluation( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request) + override; + + future> AsyncDeleteExecution( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr DeleteExecution( + grpc::ClientContext& context, Options options, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request) + override; + + StatusOr + ListExecutionResults( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListExecutionResultsRequest const& + request) override; + + StatusOr ListRules( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListRulesRequest const& request) + override; + + StatusOr + ListScannedResources( + grpc::ClientContext& context, Options const& options, + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 MakeWorkloadManagerTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1_internal +} // namespace cloud +} // namespace google + +#include "google/cloud/ports_undef.inc" + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_INTERNAL_WORKLOAD_MANAGER_TRACING_STUB_H diff --git a/google/cloud/workloadmanager/v1/mocks/mock_workload_manager_connection.h b/google/cloud/workloadmanager/v1/mocks/mock_workload_manager_connection.h new file mode 100644 index 0000000000000..8e7aabaa73601 --- /dev/null +++ b/google/cloud/workloadmanager/v1/mocks/mock_workload_manager_connection.h @@ -0,0 +1,323 @@ +// 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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_MOCKS_MOCK_WORKLOAD_MANAGER_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_MOCKS_MOCK_WORKLOAD_MANAGER_CONNECTION_H + +#include "google/cloud/workloadmanager/v1/workload_manager_connection.h" +#include + +namespace google { +namespace cloud { +namespace workloadmanager_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `WorkloadManagerConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `WorkloadManagerClient`. To do so, + * construct an object of type `WorkloadManagerClient` 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 MockWorkloadManagerConnection + : public workloadmanager_v1::WorkloadManagerConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD( + (StreamRange), + ListEvaluations, + (google::cloud::workloadmanager::v1::ListEvaluationsRequest request), + (override)); + + MOCK_METHOD( + StatusOr, GetEvaluation, + (google::cloud::workloadmanager::v1::GetEvaluationRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreateEvaluation(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + CreateEvaluation, + (google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, CreateEvaluation(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, CreateEvaluation, + (NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, CreateEvaluation(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + CreateEvaluation, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// UpdateEvaluation(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + UpdateEvaluation, + (google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, UpdateEvaluation(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, UpdateEvaluation, + (NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, UpdateEvaluation(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + UpdateEvaluation, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeleteEvaluation(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeleteEvaluation, + (google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeleteEvaluation(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, DeleteEvaluation, + (NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, DeleteEvaluation(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeleteEvaluation, (google::longrunning::Operation const& operation), + (override)); + + MOCK_METHOD( + (StreamRange), + ListExecutions, + (google::cloud::workloadmanager::v1::ListExecutionsRequest request), + (override)); + + MOCK_METHOD( + StatusOr, GetExecution, + (google::cloud::workloadmanager::v1::GetExecutionRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// RunEvaluation(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + RunEvaluation, + (google::cloud::workloadmanager::v1::RunEvaluationRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, RunEvaluation(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, RunEvaluation, + (NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, RunEvaluation(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + RunEvaluation, (google::longrunning::Operation const& operation), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeleteExecution(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeleteExecution, + (google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeleteExecution(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, DeleteExecution, + (NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, DeleteExecution(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeleteExecution, (google::longrunning::Operation const& operation), + (override)); + + MOCK_METHOD( + (StreamRange), + ListExecutionResults, + (google::cloud::workloadmanager::v1::ListExecutionResultsRequest request), + (override)); + + MOCK_METHOD( + StatusOr, + ListRules, + (google::cloud::workloadmanager::v1::ListRulesRequest const& request), + (override)); + + MOCK_METHOD( + (StreamRange), + ListScannedResources, + (google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 workloadmanager_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_MOCKS_MOCK_WORKLOAD_MANAGER_CONNECTION_H diff --git a/google/cloud/workloadmanager/v1/samples/workload_manager_client_samples.cc b/google/cloud/workloadmanager/v1/samples/workload_manager_client_samples.cc new file mode 100644 index 0000000000000..8fbee830d5600 --- /dev/null +++ b/google/cloud/workloadmanager/v1/samples/workload_manager_client_samples.cc @@ -0,0 +1,236 @@ +// 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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/workload_manager_client.h" +#include "google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.h" +#include "google/cloud/workloadmanager/v1/workload_manager_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: workloadmanager_v1::WorkloadManagerClient +// 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::workloadmanager_v1::WorkloadManagerClient( + google::cloud::workloadmanager_v1::MakeWorkloadManagerConnection( + 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::workloadmanager_v1::WorkloadManagerClient( + google::cloud::workloadmanager_v1::MakeWorkloadManagerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy : public google::cloud::workloadmanager_v1:: + WorkloadManagerConnectionIdempotencyPolicy { + 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::workloadmanager_v1:: + WorkloadManagerLimitedErrorCountRetryPolicy(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::workloadmanager_v1::MakeWorkloadManagerConnection(options); + + // c1 and c2 share the same retry policies + auto c1 = + google::cloud::workloadmanager_v1::WorkloadManagerClient(connection); + auto c2 = + google::cloud::workloadmanager_v1::WorkloadManagerClient(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::workloadmanager_v1::WorkloadManagerClient( + connection, + google::cloud::Options{} + .set( + google::cloud::workloadmanager_v1:: + WorkloadManagerLimitedTimeRetryPolicy(std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::workloadmanager_v1::WorkloadManagerLimitedErrorCountRetryPolicy(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::workloadmanager_v1:: + WorkloadManagerRetryPolicyOption::Type, + google::cloud::workloadmanager_v1:: + WorkloadManagerBackoffPolicyOption::Type>( + google::cloud::workloadmanager_v1:: + WorkloadManagerLimitedTimeRetryPolicy( + /*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::workloadmanager_v1::MakeWorkloadManagerConnection(options); + + // c1 and c2 share the same polling policies. + auto c1 = + google::cloud::workloadmanager_v1::WorkloadManagerClient(connection); + auto c2 = + google::cloud::workloadmanager_v1::WorkloadManagerClient(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::workloadmanager_v1::WorkloadManagerClient( + google::cloud::workloadmanager_v1::MakeWorkloadManagerConnection( + 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/workloadmanager/v1/workload_manager_client.cc b/google/cloud/workloadmanager/v1/workload_manager_client.cc new file mode 100644 index 0000000000000..94ed9665d87c8 --- /dev/null +++ b/google/cloud/workloadmanager/v1/workload_manager_client.cc @@ -0,0 +1,450 @@ +// 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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/workload_manager_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace workloadmanager_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WorkloadManagerClient::WorkloadManagerClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +WorkloadManagerClient::~WorkloadManagerClient() = default; + +StreamRange +WorkloadManagerClient::ListEvaluations(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::ListEvaluationsRequest request; + request.set_parent(parent); + return connection_->ListEvaluations(request); +} + +StreamRange +WorkloadManagerClient::ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListEvaluations(std::move(request)); +} + +StatusOr +WorkloadManagerClient::GetEvaluation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::GetEvaluationRequest request; + request.set_name(name); + return connection_->GetEvaluation(request); +} + +StatusOr +WorkloadManagerClient::GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetEvaluation(request); +} + +future> +WorkloadManagerClient::CreateEvaluation( + std::string const& parent, + google::cloud::workloadmanager::v1::Evaluation const& evaluation, + std::string const& evaluation_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::CreateEvaluationRequest request; + request.set_parent(parent); + *request.mutable_evaluation() = evaluation; + request.set_evaluation_id(evaluation_id); + return connection_->CreateEvaluation(request); +} + +StatusOr +WorkloadManagerClient::CreateEvaluation( + NoAwaitTag, std::string const& parent, + google::cloud::workloadmanager::v1::Evaluation const& evaluation, + std::string const& evaluation_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::CreateEvaluationRequest request; + request.set_parent(parent); + *request.mutable_evaluation() = evaluation; + request.set_evaluation_id(evaluation_id); + return connection_->CreateEvaluation(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateEvaluation(request); +} + +StatusOr +WorkloadManagerClient::CreateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateEvaluation(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::CreateEvaluation( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateEvaluation(operation); +} + +future> +WorkloadManagerClient::UpdateEvaluation( + google::cloud::workloadmanager::v1::Evaluation const& evaluation, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::UpdateEvaluationRequest request; + *request.mutable_evaluation() = evaluation; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateEvaluation(request); +} + +StatusOr +WorkloadManagerClient::UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::Evaluation const& evaluation, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::UpdateEvaluationRequest request; + *request.mutable_evaluation() = evaluation; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateEvaluation(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateEvaluation(request); +} + +StatusOr +WorkloadManagerClient::UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateEvaluation(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::UpdateEvaluation( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateEvaluation(operation); +} + +future> +WorkloadManagerClient::DeleteEvaluation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::DeleteEvaluationRequest request; + request.set_name(name); + return connection_->DeleteEvaluation(request); +} + +StatusOr +WorkloadManagerClient::DeleteEvaluation(NoAwaitTag, std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::DeleteEvaluationRequest request; + request.set_name(name); + return connection_->DeleteEvaluation(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteEvaluation(request); +} + +StatusOr +WorkloadManagerClient::DeleteEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteEvaluation(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::DeleteEvaluation( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteEvaluation(operation); +} + +StreamRange +WorkloadManagerClient::ListExecutions(std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::ListExecutionsRequest request; + request.set_parent(parent); + return connection_->ListExecutions(request); +} + +StreamRange +WorkloadManagerClient::ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListExecutions(std::move(request)); +} + +StatusOr +WorkloadManagerClient::GetExecution(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::GetExecutionRequest request; + request.set_name(name); + return connection_->GetExecution(request); +} + +StatusOr +WorkloadManagerClient::GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetExecution(request); +} + +future> +WorkloadManagerClient::RunEvaluation( + std::string const& name, + google::cloud::workloadmanager::v1::Execution const& execution, + std::string const& execution_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::RunEvaluationRequest request; + request.set_name(name); + *request.mutable_execution() = execution; + request.set_execution_id(execution_id); + return connection_->RunEvaluation(request); +} + +StatusOr WorkloadManagerClient::RunEvaluation( + NoAwaitTag, std::string const& name, + google::cloud::workloadmanager::v1::Execution const& execution, + std::string const& execution_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::RunEvaluationRequest request; + request.set_name(name); + *request.mutable_execution() = execution; + request.set_execution_id(execution_id); + return connection_->RunEvaluation(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RunEvaluation(request); +} + +StatusOr WorkloadManagerClient::RunEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RunEvaluation(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::RunEvaluation( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->RunEvaluation(operation); +} + +future> +WorkloadManagerClient::DeleteExecution(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::DeleteExecutionRequest request; + request.set_name(name); + return connection_->DeleteExecution(request); +} + +StatusOr WorkloadManagerClient::DeleteExecution( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::DeleteExecutionRequest request; + request.set_name(name); + return connection_->DeleteExecution(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteExecution(request); +} + +StatusOr WorkloadManagerClient::DeleteExecution( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteExecution(NoAwaitTag{}, request); +} + +future> +WorkloadManagerClient::DeleteExecution( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteExecution(operation); +} + +StreamRange +WorkloadManagerClient::ListExecutionResults(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request; + request.set_parent(parent); + return connection_->ListExecutionResults(request); +} + +StreamRange +WorkloadManagerClient::ListExecutionResults( + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListExecutionResults(std::move(request)); +} + +StatusOr +WorkloadManagerClient::ListRules(std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::ListRulesRequest request; + request.set_parent(parent); + return connection_->ListRules(request); +} + +StatusOr +WorkloadManagerClient::ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListRules(request); +} + +StreamRange +WorkloadManagerClient::ListScannedResources(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::workloadmanager::v1::ListScannedResourcesRequest request; + request.set_parent(parent); + return connection_->ListScannedResources(request); +} + +StreamRange +WorkloadManagerClient::ListScannedResources( + google::cloud::workloadmanager::v1::ListScannedResourcesRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListScannedResources(std::move(request)); +} + +StreamRange +WorkloadManagerClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr WorkloadManagerClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange +WorkloadManagerClient::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 +WorkloadManagerClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr WorkloadManagerClient::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 WorkloadManagerClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status WorkloadManagerClient::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 WorkloadManagerClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status WorkloadManagerClient::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 WorkloadManagerClient::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 workloadmanager_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/workloadmanager/v1/workload_manager_client.h b/google/cloud/workloadmanager/v1/workload_manager_client.h new file mode 100644 index 0000000000000..4c15ac78eaf8e --- /dev/null +++ b/google/cloud/workloadmanager/v1/workload_manager_client.h @@ -0,0 +1,1506 @@ +// 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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CLIENT_H + +#include "google/cloud/workloadmanager/v1/workload_manager_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 workloadmanager_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// The Workload Manager provides various tools to deploy, validate and observe +/// your workloads running on Google Cloud. +/// +/// @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 WorkloadManagerClient { + public: + explicit WorkloadManagerClient( + std::shared_ptr connection, Options opts = {}); + ~WorkloadManagerClient(); + + ///@{ + /// @name Copy and move support + WorkloadManagerClient(WorkloadManagerClient const&) = default; + WorkloadManagerClient& operator=(WorkloadManagerClient const&) = default; + WorkloadManagerClient(WorkloadManagerClient&&) = default; + WorkloadManagerClient& operator=(WorkloadManagerClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(WorkloadManagerClient const& a, + WorkloadManagerClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(WorkloadManagerClient const& a, + WorkloadManagerClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Lists Evaluations in a given project and location. + /// + /// @param parent Required. Parent value for ListEvaluationsRequest. + /// @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.workloadmanager.v1.Evaluation], 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.workloadmanager.v1.Evaluation]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L178} + /// [google.cloud.workloadmanager.v1.ListEvaluationsRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L330} + /// + // clang-format on + StreamRange ListEvaluations( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists Evaluations in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.workloadmanager.v1.ListEvaluationsRequest]. + /// 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.workloadmanager.v1.Evaluation], 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.workloadmanager.v1.Evaluation]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L178} + /// [google.cloud.workloadmanager.v1.ListEvaluationsRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L330} + /// + // clang-format on + StreamRange ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Evaluation. + /// + /// @param name Required. Name of the resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.workloadmanager.v1.Evaluation]) + /// 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.workloadmanager.v1.Evaluation]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L178} + /// [google.cloud.workloadmanager.v1.GetEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L366} + /// + // clang-format on + StatusOr GetEvaluation( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Evaluation. + /// + /// @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.workloadmanager.v1.GetEvaluationRequest]. + /// 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.workloadmanager.v1.Evaluation]) + /// 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.workloadmanager.v1.Evaluation]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L178} + /// [google.cloud.workloadmanager.v1.GetEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L366} + /// + // clang-format on + StatusOr GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new Evaluation in a given project and location. + /// + /// @param parent Required. The resource prefix of the evaluation location using the form: + /// `projects/{project_id}/locations/{location_id}`. + /// @param evaluation Required. The resource being created. + /// @param evaluation_id Required. Id of the requesting object. + /// @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.workloadmanager.v1.Evaluation] 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.workloadmanager.v1.CreateEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L377} + /// [google.cloud.workloadmanager.v1.Evaluation]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L178} + /// + // clang-format on + future> + CreateEvaluation( + std::string const& parent, + google::cloud::workloadmanager::v1::Evaluation const& evaluation, + std::string const& evaluation_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateEvaluation + /// + /// 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 CreateEvaluation( + NoAwaitTag, std::string const& parent, + google::cloud::workloadmanager::v1::Evaluation const& evaluation, + std::string const& evaluation_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new Evaluation in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.workloadmanager.v1.CreateEvaluationRequest]. + /// 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.workloadmanager.v1.Evaluation] 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.workloadmanager.v1.CreateEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L377} + /// [google.cloud.workloadmanager.v1.Evaluation]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L178} + /// + // clang-format on + future> + CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateEvaluation + /// + /// 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 CreateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateEvaluation + /// + /// 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> + CreateEvaluation(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Updates the parameters of a single Evaluation. + /// + /// @param evaluation Required. The resource being updated. + /// @param update_mask Required. Field mask is used to specify the fields to be overwritten in the + /// Evaluation resource by the update. + /// The fields specified in the update_mask are relative to the resource, not + /// the full request. A field will be overwritten if it is in the mask. + /// @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.workloadmanager.v1.Evaluation] 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.workloadmanager.v1.Evaluation]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L178} + /// [google.cloud.workloadmanager.v1.UpdateEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L410} + /// + // clang-format on + future> + UpdateEvaluation( + google::cloud::workloadmanager::v1::Evaluation const& evaluation, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateEvaluation + /// + /// 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 UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::Evaluation const& evaluation, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the parameters of a single Evaluation. + /// + /// @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.workloadmanager.v1.UpdateEvaluationRequest]. + /// 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.workloadmanager.v1.Evaluation] 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.workloadmanager.v1.Evaluation]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L178} + /// [google.cloud.workloadmanager.v1.UpdateEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L410} + /// + // clang-format on + future> + UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateEvaluation + /// + /// 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 UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateEvaluation + /// + /// 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> + UpdateEvaluation(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Deletes a single Evaluation. + /// + /// @param name Required. Name of the resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.workloadmanager.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.workloadmanager.v1.DeleteEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L438} + /// [google.cloud.workloadmanager.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L891} + /// + // clang-format on + future> + DeleteEvaluation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteEvaluation + /// + /// 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 DeleteEvaluation( + NoAwaitTag, std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a single Evaluation. + /// + /// @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.workloadmanager.v1.DeleteEvaluationRequest]. + /// 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.workloadmanager.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.workloadmanager.v1.DeleteEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L438} + /// [google.cloud.workloadmanager.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L891} + /// + // clang-format on + future> + DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteEvaluation + /// + /// 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 DeleteEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteEvaluation + /// + /// 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> + DeleteEvaluation(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Lists Executions in a given project and location. + /// + /// @param parent Required. The resource prefix of the Execution using the form: + /// `projects/{project}/locations/{location}/evaluations/{evaluation}`. + /// @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.workloadmanager.v1.Execution], 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.workloadmanager.v1.Execution]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L468} + /// [google.cloud.workloadmanager.v1.ListExecutionsRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L644} + /// + // clang-format on + StreamRange ListExecutions( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists Executions in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.workloadmanager.v1.ListExecutionsRequest]. + /// 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.workloadmanager.v1.Execution], 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.workloadmanager.v1.Execution]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L468} + /// [google.cloud.workloadmanager.v1.ListExecutionsRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L644} + /// + // clang-format on + StreamRange ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Execution. + /// + /// @param name Required. Name of the resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.workloadmanager.v1.Execution]) + /// 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.workloadmanager.v1.Execution]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L468} + /// [google.cloud.workloadmanager.v1.GetExecutionRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L681} + /// + // clang-format on + StatusOr GetExecution( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Execution. + /// + /// @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.workloadmanager.v1.GetExecutionRequest]. + /// 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.workloadmanager.v1.Execution]) + /// 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.workloadmanager.v1.Execution]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L468} + /// [google.cloud.workloadmanager.v1.GetExecutionRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L681} + /// + // clang-format on + StatusOr GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new Execution in a given project and location. + /// + /// @param name Required. The resource name of the Evaluation using the form: + /// `projects/{project}/locations/{location}/evaluations/{evaluation}`. + /// @param execution Required. The resource being created. + /// @param execution_id Required. ID of the execution which will be created. + /// @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.workloadmanager.v1.Execution] 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.workloadmanager.v1.Execution]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L468} + /// [google.cloud.workloadmanager.v1.RunEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L692} + /// + // clang-format on + future> RunEvaluation( + std::string const& name, + google::cloud::workloadmanager::v1::Execution const& execution, + std::string const& execution_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief RunEvaluation + /// + /// 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 RunEvaluation( + NoAwaitTag, std::string const& name, + google::cloud::workloadmanager::v1::Execution const& execution, + std::string const& execution_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new Execution in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.workloadmanager.v1.RunEvaluationRequest]. + /// 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.workloadmanager.v1.Execution] 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.workloadmanager.v1.Execution]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L468} + /// [google.cloud.workloadmanager.v1.RunEvaluationRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L692} + /// + // clang-format on + future> RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief RunEvaluation + /// + /// 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 RunEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief RunEvaluation + /// + /// 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> RunEvaluation( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Deletes a single Execution. + /// + /// @param name Required. Name of the resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.workloadmanager.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.workloadmanager.v1.DeleteExecutionRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L725} + /// [google.cloud.workloadmanager.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L891} + /// + // clang-format on + future> + DeleteExecution(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteExecution + /// + /// 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 DeleteExecution( + NoAwaitTag, std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a single Execution. + /// + /// @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.workloadmanager.v1.DeleteExecutionRequest]. + /// 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.workloadmanager.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.workloadmanager.v1.DeleteExecutionRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L725} + /// [google.cloud.workloadmanager.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L891} + /// + // clang-format on + future> + DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteExecution + /// + /// 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 DeleteExecution( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteExecution + /// + /// 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> + DeleteExecution(google::longrunning::Operation const& operation, + Options opts = {}); + + // clang-format off + /// + /// Lists the result of a single evaluation. + /// + /// @param parent Required. The execution results. + /// Format: {parent}/evaluations/*/executions/*/results. + /// @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.workloadmanager.v1.ExecutionResult], 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.workloadmanager.v1.ExecutionResult]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L778} + /// [google.cloud.workloadmanager.v1.ListExecutionResultsRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L751} + /// + // clang-format on + StreamRange + ListExecutionResults(std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists the result of a single evaluation. + /// + /// @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.workloadmanager.v1.ListExecutionResultsRequest]. + /// 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.workloadmanager.v1.ExecutionResult], 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.workloadmanager.v1.ExecutionResult]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L778} + /// [google.cloud.workloadmanager.v1.ListExecutionResultsRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L751} + /// + // clang-format on + StreamRange + ListExecutionResults( + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request, + Options opts = {}); + + // clang-format off + /// + /// Lists rules in a given project. + /// + /// @param parent Required. The [project] on which to execute the request. The format is: + /// projects/{project_id}/locations/{location} + /// Currently, the pre-defined rules are global available to all projects and + /// all regions. + /// @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.workloadmanager.v1.ListRulesResponse]) + /// 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.workloadmanager.v1.ListRulesRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L983} + /// [google.cloud.workloadmanager.v1.ListRulesResponse]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L1015} + /// + // clang-format on + StatusOr ListRules( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists rules in a given project. + /// + /// @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.workloadmanager.v1.ListRulesRequest]. + /// 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.workloadmanager.v1.ListRulesResponse]) + /// 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.workloadmanager.v1.ListRulesRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L983} + /// [google.cloud.workloadmanager.v1.ListRulesResponse]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L1015} + /// + // clang-format on + StatusOr ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// List all scanned resources for a single Execution. + /// + /// @param parent Required. Parent for ListScannedResourcesRequest. + /// @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.workloadmanager.v1.ScannedResource], 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.workloadmanager.v1.ListScannedResourcesRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L1021} + /// [google.cloud.workloadmanager.v1.ScannedResource]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L1053} + /// + // clang-format on + StreamRange + ListScannedResources(std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// List all scanned resources for a single Execution. + /// + /// @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.workloadmanager.v1.ListScannedResourcesRequest]. + /// 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.workloadmanager.v1.ScannedResource], 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.workloadmanager.v1.ListScannedResourcesRequest]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L1021} + /// [google.cloud.workloadmanager.v1.ScannedResource]: @googleapis_reference_link{google/cloud/workloadmanager/v1/service.proto#L1053} + /// + // clang-format on + StreamRange + ListScannedResources( + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 workloadmanager_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CLIENT_H diff --git a/google/cloud/workloadmanager/v1/workload_manager_connection.cc b/google/cloud/workloadmanager/v1/workload_manager_connection.cc new file mode 100644 index 0000000000000..9568bbe48444f --- /dev/null +++ b/google/cloud/workloadmanager/v1/workload_manager_connection.cc @@ -0,0 +1,270 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/workload_manager_connection.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_connection_impl.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_option_defaults.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_stub_factory.h" +#include "google/cloud/workloadmanager/v1/internal/workload_manager_tracing_connection.h" +#include "google/cloud/workloadmanager/v1/workload_manager_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 workloadmanager_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +WorkloadManagerConnection::~WorkloadManagerConnection() = default; + +StreamRange +WorkloadManagerConnection::ListEvaluations( + google::cloud::workloadmanager::v1:: + ListEvaluationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +WorkloadManagerConnection::GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +WorkloadManagerConnection::CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +WorkloadManagerConnection::CreateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +WorkloadManagerConnection::CreateEvaluation( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +WorkloadManagerConnection::UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +WorkloadManagerConnection::UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +WorkloadManagerConnection::UpdateEvaluation( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +WorkloadManagerConnection::DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +WorkloadManagerConnection::DeleteEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +WorkloadManagerConnection::DeleteEvaluation( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +WorkloadManagerConnection::ListExecutions( + google::cloud::workloadmanager::v1:: + ListExecutionsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +WorkloadManagerConnection::GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +WorkloadManagerConnection::RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +WorkloadManagerConnection::RunEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +WorkloadManagerConnection::RunEvaluation( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +WorkloadManagerConnection::DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +WorkloadManagerConnection::DeleteExecution( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +WorkloadManagerConnection::DeleteExecution( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +WorkloadManagerConnection::ListExecutionResults( + google::cloud::workloadmanager::v1:: + ListExecutionResultsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +WorkloadManagerConnection::ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +WorkloadManagerConnection::ListScannedResources( + google::cloud::workloadmanager::v1:: + ListScannedResourcesRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StreamRange +WorkloadManagerConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +WorkloadManagerConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +WorkloadManagerConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +WorkloadManagerConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WorkloadManagerConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status WorkloadManagerConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr MakeWorkloadManagerConnection( + Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = workloadmanager_v1_internal::WorkloadManagerDefaultOptions( + std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = workloadmanager_v1_internal::CreateDefaultWorkloadManagerStub( + std::move(auth), options); + return workloadmanager_v1_internal::MakeWorkloadManagerTracingConnection( + std::make_shared< + workloadmanager_v1_internal::WorkloadManagerConnectionImpl>( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/workloadmanager/v1/workload_manager_connection.h b/google/cloud/workloadmanager/v1/workload_manager_connection.h new file mode 100644 index 0000000000000..dd8720223512c --- /dev/null +++ b/google/cloud/workloadmanager/v1/workload_manager_connection.h @@ -0,0 +1,333 @@ +// 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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CONNECTION_H + +#include "google/cloud/workloadmanager/v1/internal/workload_manager_retry_traits.h" +#include "google/cloud/workloadmanager/v1/service.pb.h" +#include "google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.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 workloadmanager_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `WorkloadManagerConnection`. +class WorkloadManagerRetryPolicy : 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 `WorkloadManagerConnection` 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 WorkloadManagerLimitedErrorCountRetryPolicy + : public WorkloadManagerRetryPolicy { + 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 WorkloadManagerLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + WorkloadManagerLimitedErrorCountRetryPolicy( + WorkloadManagerLimitedErrorCountRetryPolicy&& rhs) noexcept + : WorkloadManagerLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + WorkloadManagerLimitedErrorCountRetryPolicy( + WorkloadManagerLimitedErrorCountRetryPolicy const& rhs) noexcept + : WorkloadManagerLimitedErrorCountRetryPolicy(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 = WorkloadManagerRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + workloadmanager_v1_internal::WorkloadManagerRetryTraits> + impl_; +}; + +/** + * A retry policy for `WorkloadManagerConnection` 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 WorkloadManagerLimitedTimeRetryPolicy + : public WorkloadManagerRetryPolicy { + 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 WorkloadManagerLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + WorkloadManagerLimitedTimeRetryPolicy( + WorkloadManagerLimitedTimeRetryPolicy&& rhs) noexcept + : WorkloadManagerLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + WorkloadManagerLimitedTimeRetryPolicy( + WorkloadManagerLimitedTimeRetryPolicy const& rhs) noexcept + : WorkloadManagerLimitedTimeRetryPolicy(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 = WorkloadManagerRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + workloadmanager_v1_internal::WorkloadManagerRetryTraits> + impl_; +}; + +/** + * The `WorkloadManagerConnection` object for `WorkloadManagerClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `WorkloadManagerClient`. This allows users to inject custom behavior + * (e.g., with a Google Mock object) when writing tests that use objects of type + * `WorkloadManagerClient`. + * + * To create a concrete instance, see `MakeWorkloadManagerConnection()`. + * + * For mocking, see `workloadmanager_v1_mocks::MockWorkloadManagerConnection`. + */ +class WorkloadManagerConnection { + public: + virtual ~WorkloadManagerConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StreamRange + ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest request); + + virtual StatusOr + GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request); + + virtual future> + CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request); + + virtual StatusOr CreateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request); + + virtual future> + CreateEvaluation(google::longrunning::Operation const& operation); + + virtual future> + UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request); + + virtual StatusOr UpdateEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request); + + virtual future> + UpdateEvaluation(google::longrunning::Operation const& operation); + + virtual future< + StatusOr> + DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request); + + virtual StatusOr DeleteEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request); + + virtual future< + StatusOr> + DeleteEvaluation(google::longrunning::Operation const& operation); + + virtual StreamRange + ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest request); + + virtual StatusOr GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const& request); + + virtual future> + RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request); + + virtual StatusOr RunEvaluation( + NoAwaitTag, + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request); + + virtual future> + RunEvaluation(google::longrunning::Operation const& operation); + + virtual future< + StatusOr> + DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request); + + virtual StatusOr DeleteExecution( + NoAwaitTag, + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request); + + virtual future< + StatusOr> + DeleteExecution(google::longrunning::Operation const& operation); + + virtual StreamRange + ListExecutionResults( + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request); + + virtual StatusOr + ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const& request); + + virtual StreamRange + ListScannedResources( + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 + * `WorkloadManagerConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of WorkloadManagerClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `WorkloadManagerConnection`. Expected options are any of the types + * in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::workloadmanager_v1::WorkloadManagerPolicyOptionList` + * + * @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 `WorkloadManagerConnection` created + * by this function. + */ +std::shared_ptr MakeWorkloadManagerConnection( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CONNECTION_H diff --git a/google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.cc b/google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..62d71c82878e4 --- /dev/null +++ b/google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.cc @@ -0,0 +1,137 @@ +// 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/workloadmanager/v1/service.proto + +#include "google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace workloadmanager_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +WorkloadManagerConnectionIdempotencyPolicy:: + ~WorkloadManagerConnectionIdempotencyPolicy() = default; + +std::unique_ptr +WorkloadManagerConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::ListExecutionResults( + google::cloud::workloadmanager::v1:: + ListExecutionResultsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::ListScannedResources( + google::cloud::workloadmanager::v1:: + ListScannedResourcesRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency WorkloadManagerConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultWorkloadManagerConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.h b/google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.h new file mode 100644 index 0000000000000..9476b1a08a793 --- /dev/null +++ b/google/cloud/workloadmanager/v1/workload_manager_connection_idempotency_policy.h @@ -0,0 +1,109 @@ +// 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/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/location/locations.grpc.pb.h" +#include "google/cloud/workloadmanager/v1/service.grpc.pb.h" +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include + +namespace google { +namespace cloud { +namespace workloadmanager_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class WorkloadManagerConnectionIdempotencyPolicy { + public: + virtual ~WorkloadManagerConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() + const; + + virtual google::cloud::Idempotency ListEvaluations( + google::cloud::workloadmanager::v1::ListEvaluationsRequest request); + + virtual google::cloud::Idempotency GetEvaluation( + google::cloud::workloadmanager::v1::GetEvaluationRequest const& request); + + virtual google::cloud::Idempotency CreateEvaluation( + google::cloud::workloadmanager::v1::CreateEvaluationRequest const& + request); + + virtual google::cloud::Idempotency UpdateEvaluation( + google::cloud::workloadmanager::v1::UpdateEvaluationRequest const& + request); + + virtual google::cloud::Idempotency DeleteEvaluation( + google::cloud::workloadmanager::v1::DeleteEvaluationRequest const& + request); + + virtual google::cloud::Idempotency ListExecutions( + google::cloud::workloadmanager::v1::ListExecutionsRequest request); + + virtual google::cloud::Idempotency GetExecution( + google::cloud::workloadmanager::v1::GetExecutionRequest const& request); + + virtual google::cloud::Idempotency RunEvaluation( + google::cloud::workloadmanager::v1::RunEvaluationRequest const& request); + + virtual google::cloud::Idempotency DeleteExecution( + google::cloud::workloadmanager::v1::DeleteExecutionRequest const& + request); + + virtual google::cloud::Idempotency ListExecutionResults( + google::cloud::workloadmanager::v1::ListExecutionResultsRequest request); + + virtual google::cloud::Idempotency ListRules( + google::cloud::workloadmanager::v1::ListRulesRequest const& request); + + virtual google::cloud::Idempotency ListScannedResources( + google::cloud::workloadmanager::v1::ListScannedResourcesRequest 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 +MakeDefaultWorkloadManagerConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/workloadmanager/v1/workload_manager_options.h b/google/cloud/workloadmanager/v1/workload_manager_options.h new file mode 100644 index 0000000000000..5a3bc07fa3356 --- /dev/null +++ b/google/cloud/workloadmanager/v1/workload_manager_options.h @@ -0,0 +1,87 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/workloadmanager/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_OPTIONS_H + +#include "google/cloud/workloadmanager/v1/workload_manager_connection.h" +#include "google/cloud/workloadmanager/v1/workload_manager_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 workloadmanager_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-workloadmanager-options + */ +struct WorkloadManagerRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-workloadmanager-options + */ +struct WorkloadManagerBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-workloadmanager-options + */ +struct WorkloadManagerConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the long-running operations + * polling policy. + * + * @ingroup google-cloud-workloadmanager-options + */ +struct WorkloadManagerPollingPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to WorkloadManager. + * + * @ingroup google-cloud-workloadmanager-options + */ +using WorkloadManagerPolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace workloadmanager_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_WORKLOADMANAGER_V1_WORKLOAD_MANAGER_OPTIONS_H diff --git a/libraries.bzl b/libraries.bzl index 69060fe50ca39..5793bb3b65b23 100644 --- a/libraries.bzl +++ b/libraries.bzl @@ -256,5 +256,6 @@ GOOGLE_CLOUD_CPP_GA_LIBRARIES = [ "webrisk", "websecurityscanner", "workflows", + "workloadmanager", "workstations", ]