diff --git a/CHANGELOG.md b/CHANGELOG.md index 247037edd340c..5f8b78f9cc329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,17 @@ breaking changes in the upcoming 3.x release. This release is scheduled for ## v2.37.0 - TBD +### New Libraries + 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. - [Financial Services API](/google/cloud/financialservices/README.md) +### Updated Libraries + +- [iam](/google/cloud/iam/README.md) - add v3 version of the library + **BREAKING CHANGES** Client library `resourcesettings` is being removed because the service has been turned down. diff --git a/ci/abi-dumps/google_cloud_cpp_iam.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_iam.expected.abi.dump.gz index bd94c44020cb5..d35b9ea5c910d 100644 Binary files a/ci/abi-dumps/google_cloud_cpp_iam.expected.abi.dump.gz and b/ci/abi-dumps/google_cloud_cpp_iam.expected.abi.dump.gz differ diff --git a/ci/cloudbuild/builds/cmake-install.sh b/ci/cloudbuild/builds/cmake-install.sh index 306575c7493e8..e18dccbef9865 100755 --- a/ci/cloudbuild/builds/cmake-install.sh +++ b/ci/cloudbuild/builds/cmake-install.sh @@ -153,6 +153,7 @@ expected_dirs+=( ./lib64/cmake/google_cloud_cpp_grpc_utils ./lib64/cmake/google_cloud_cpp_logging_type ./lib64/cmake/google_cloud_cpp_iam_v2 + ./lib64/cmake/google_cloud_cpp_iam_v3 ./lib64/cmake/google_cloud_cpp_mocks ./lib64/cmake/google_cloud_cpp_oauth2 ./lib64/cmake/google_cloud_cpp_opentelemetry diff --git a/ci/etc/expected_install_directories b/ci/etc/expected_install_directories index 5d212dbd2e829..6112e6eae4932 100644 --- a/ci/etc/expected_install_directories +++ b/ci/etc/expected_install_directories @@ -799,6 +799,9 @@ ./include/google/cloud/iam/v2 ./include/google/cloud/iam/v2/internal ./include/google/cloud/iam/v2/mocks +./include/google/cloud/iam/v3 +./include/google/cloud/iam/v3/internal +./include/google/cloud/iam/v3/mocks ./include/google/cloud/iap ./include/google/cloud/iap/mocks ./include/google/cloud/iap/v1 @@ -1240,6 +1243,7 @@ ./include/google/iam/credentials/v1 ./include/google/iam/v1 ./include/google/iam/v2 +./include/google/iam/v3 ./include/google/identity ./include/google/identity/accesscontextmanager ./include/google/identity/accesscontextmanager/v1 diff --git a/external/googleapis/protodeps/iam_v3.deps b/external/googleapis/protodeps/iam_v3.deps new file mode 100644 index 0000000000000..ea852ac64f42a --- /dev/null +++ b/external/googleapis/protodeps/iam_v3.deps @@ -0,0 +1,10 @@ +@com_google_googleapis//google/api:annotations_proto +@com_google_googleapis//google/api:client_proto +@com_google_googleapis//google/api:field_behavior_proto +@com_google_googleapis//google/api:field_info_proto +@com_google_googleapis//google/api:http_proto +@com_google_googleapis//google/api:launch_stage_proto +@com_google_googleapis//google/api:resource_proto +@com_google_googleapis//google/longrunning:operations_proto +@com_google_googleapis//google/rpc:status_proto +@com_google_googleapis//google/type:expr_proto diff --git a/external/googleapis/protolists/iam_v3.list b/external/googleapis/protolists/iam_v3.list new file mode 100644 index 0000000000000..da1849ff962ab --- /dev/null +++ b/external/googleapis/protolists/iam_v3.list @@ -0,0 +1,5 @@ +@com_google_googleapis//google/iam/v3:operation_metadata.proto +@com_google_googleapis//google/iam/v3:policy_binding_resources.proto +@com_google_googleapis//google/iam/v3:policy_bindings_service.proto +@com_google_googleapis//google/iam/v3:principal_access_boundary_policies_service.proto +@com_google_googleapis//google/iam/v3:principal_access_boundary_policy_resources.proto diff --git a/external/googleapis/update_libraries.sh b/external/googleapis/update_libraries.sh index cfac88e11fd9c..4cb6ff62f70e8 100755 --- a/external/googleapis/update_libraries.sh +++ b/external/googleapis/update_libraries.sh @@ -166,6 +166,7 @@ declare -A -r LIBRARIES=( ["grafeas"]="@com_google_googleapis//grafeas/v1:grafeas_cc_grpc" ["iam"]="@com_google_googleapis//google/iam/admin/v1:admin_cc_grpc" ["iam_v2"]="@com_google_googleapis//google/iam/v2:iam_cc_grpc" + ["iam_v3"]="@com_google_googleapis//google/iam/v3:iam_cc_grpc" ["iap"]="@com_google_googleapis//google/cloud/iap/v1:iap_cc_grpc" ["ids"]="@com_google_googleapis//google/cloud/ids/v1:ids_cc_grpc" ["kms"]="$( diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index 7e94d5dce7c16..6a85860ddfdc4 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -2606,6 +2606,20 @@ service { retryable_status_codes: ["kUnavailable"] } +service { + service_proto_path: "google/iam/v3/policy_bindings_service.proto" + product_path: "google/cloud/iam/v3" + initial_copyright_year: "2025" + retryable_status_codes: ["kUnavailable"] +} + +service { + service_proto_path: "google/iam/v3/principal_access_boundary_policies_service.proto" + product_path: "google/cloud/iam/v3" + initial_copyright_year: "2025" + retryable_status_codes: ["kUnavailable"] +} + # Identity-Aware Proxy (IAP) service { service_proto_path: "google/cloud/iap/v1/service.proto" diff --git a/google/cloud/iam/BUILD.bazel b/google/cloud/iam/BUILD.bazel index eb32c33606d7a..48bd99fa12405 100644 --- a/google/cloud/iam/BUILD.bazel +++ b/google/cloud/iam/BUILD.bazel @@ -24,6 +24,7 @@ service_dirs = [ "credentials/v1/", "v1/", "v2/", + "v3/", ] googleapis_deps = [ @@ -31,6 +32,7 @@ googleapis_deps = [ "@com_google_googleapis//google/iam/credentials/v1:credentials_cc_grpc", "@com_google_googleapis//google/iam/v1:iam_cc_grpc", "@com_google_googleapis//google/iam/v2:iam_cc_grpc", + "@com_google_googleapis//google/iam/v3:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/iam/CMakeLists.txt b/google/cloud/iam/CMakeLists.txt index 0b03cd1cb3381..4bd15d82b7345 100644 --- a/google/cloud/iam/CMakeLists.txt +++ b/google/cloud/iam/CMakeLists.txt @@ -18,8 +18,8 @@ include(GoogleCloudCppLibrary) google_cloud_cpp_add_gapic_library( iam "Google Cloud IAM API" - SERVICE_DIRS "__EMPTY__" "admin/v1/" "credentials/v1/" "v1/" "v2/" - SHARED_PROTO_DEPS "iam_v2") + SERVICE_DIRS "__EMPTY__" "admin/v1/" "credentials/v1/" "v1/" "v2/" "v3/" + SHARED_PROTO_DEPS "iam_v2" "iam_v3") # Examples are enabled if possible, but package maintainers may want to disable # compilation to speed up their builds. diff --git a/google/cloud/iam/doc/environment-variables.dox b/google/cloud/iam/doc/environment-variables.dox index 0499f3d23d42e..5064fde26b726 100644 --- a/google/cloud/iam/doc/environment-variables.dox +++ b/google/cloud/iam/doc/environment-variables.dox @@ -26,6 +26,14 @@ environment variables are convenient when troubleshooting problems. `EndpointOption` (which defaults to "iam.googleapis.com") used by `MakePoliciesConnection()`. +- `GOOGLE_CLOUD_CPP_POLICY_BINDINGS_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "iam.googleapis.com") + used by `MakePolicyBindingsConnection()`. + +- `GOOGLE_CLOUD_CPP_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "iam.googleapis.com") + used by `MakePrincipalAccessBoundaryPoliciesConnection()`. + @see google::cloud::EndpointOption diff --git a/google/cloud/iam/doc/main.dox b/google/cloud/iam/doc/main.dox index 575d1916f971f..2f155983ae75d 100644 --- a/google/cloud/iam/doc/main.dox +++ b/google/cloud/iam/doc/main.dox @@ -34,6 +34,8 @@ application. - [\c iam_credentials_v1::IAMCredentialsClient](@ref google::cloud::iam_credentials_v1::IAMCredentialsClient) - [\c iam_v1::IAMPolicyClient](@ref google::cloud::iam_v1::IAMPolicyClient) - [\c iam_v2::PoliciesClient](@ref google::cloud::iam_v2::PoliciesClient) +- [\c iam_v3::PolicyBindingsClient](@ref google::cloud::iam_v3::PolicyBindingsClient) +- [\c iam_v3::PrincipalAccessBoundaryPoliciesClient](@ref google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesClient) ## Next Steps diff --git a/google/cloud/iam/doc/override-authentication.dox b/google/cloud/iam/doc/override-authentication.dox index db2ed8a75fd9e..fc7469a6663be 100644 --- a/google/cloud/iam/doc/override-authentication.dox +++ b/google/cloud/iam/doc/override-authentication.dox @@ -17,6 +17,8 @@ Follow these links to find examples for other \c *Client classes: - [\c iam_credentials_v1::IAMCredentialsClient](@ref iam_credentials_v1::IAMCredentialsClient-service-account-snippet) - [\c iam_v1::IAMPolicyClient](@ref iam_v1::IAMPolicyClient-service-account-snippet) - [\c iam_v2::PoliciesClient](@ref iam_v2::PoliciesClient-service-account-snippet) +- [\c iam_v3::PolicyBindingsClient](@ref iam_v3::PolicyBindingsClient-service-account-snippet) +- [\c iam_v3::PrincipalAccessBoundaryPoliciesClient](@ref iam_v3::PrincipalAccessBoundaryPoliciesClient-service-account-snippet) @@ -56,5 +58,17 @@ guide for more details. @snippet google/cloud/iam/v2/samples/policies_client_samples.cc with-service-account +*/ + +/*! @page iam_v3::PolicyBindingsClient-service-account-snippet Override iam_v3::PolicyBindingsClient Authentication Defaults + +@snippet google/cloud/iam/v3/samples/policy_bindings_client_samples.cc with-service-account + +*/ + +/*! @page iam_v3::PrincipalAccessBoundaryPoliciesClient-service-account-snippet Override iam_v3::PrincipalAccessBoundaryPoliciesClient Authentication Defaults + +@snippet google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc with-service-account + */ // diff --git a/google/cloud/iam/doc/override-endpoint.dox b/google/cloud/iam/doc/override-endpoint.dox index d6daa5802daea..4db719a32fde5 100644 --- a/google/cloud/iam/doc/override-endpoint.dox +++ b/google/cloud/iam/doc/override-endpoint.dox @@ -17,6 +17,8 @@ Follow these links to find examples for other \c *Client classes: - [\c iam_credentials_v1::IAMCredentialsClient](@ref iam_credentials_v1::IAMCredentialsClient-endpoint-snippet) - [\c iam_v1::IAMPolicyClient](@ref iam_v1::IAMPolicyClient-endpoint-snippet) - [\c iam_v2::PoliciesClient](@ref iam_v2::PoliciesClient-endpoint-snippet) +- [\c iam_v3::PolicyBindingsClient](@ref iam_v3::PolicyBindingsClient-endpoint-snippet) +- [\c iam_v3::PrincipalAccessBoundaryPoliciesClient](@ref iam_v3::PrincipalAccessBoundaryPoliciesClient-endpoint-snippet) @@ -46,5 +48,17 @@ Follow these links to find examples for other \c *Client classes: @snippet google/cloud/iam/v2/samples/policies_client_samples.cc set-client-endpoint +*/ + +/*! @page iam_v3::PolicyBindingsClient-endpoint-snippet Override iam_v3::PolicyBindingsClient Endpoint Configuration + +@snippet google/cloud/iam/v3/samples/policy_bindings_client_samples.cc set-client-endpoint + +*/ + +/*! @page iam_v3::PrincipalAccessBoundaryPoliciesClient-endpoint-snippet Override iam_v3::PrincipalAccessBoundaryPoliciesClient Endpoint Configuration + +@snippet google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc set-client-endpoint + */ // diff --git a/google/cloud/iam/doc/override-retry-policies.dox b/google/cloud/iam/doc/override-retry-policies.dox index e5abcddbfb228..7a07b28f4e993 100644 --- a/google/cloud/iam/doc/override-retry-policies.dox +++ b/google/cloud/iam/doc/override-retry-policies.dox @@ -83,6 +83,8 @@ Follow these links to find examples for other \c *Client classes: - [\c iam_credentials_v1::IAMCredentialsClient](@ref iam_credentials_v1::IAMCredentialsClient-retry-snippet) - [\c iam_v1::IAMPolicyClient](@ref iam_v1::IAMPolicyClient-retry-snippet) - [\c iam_v2::PoliciesClient](@ref iam_v2::PoliciesClient-retry-snippet) +- [\c iam_v3::PolicyBindingsClient](@ref iam_v3::PolicyBindingsClient-retry-snippet) +- [\c iam_v3::PrincipalAccessBoundaryPoliciesClient](@ref iam_v3::PrincipalAccessBoundaryPoliciesClient-retry-snippet) @@ -144,5 +146,29 @@ Assuming you have created a custom idempotency policy. Such as: @snippet google/cloud/iam/v2/samples/policies_client_samples.cc custom-idempotency-policy +*/ + +/*! @page iam_v3::PolicyBindingsClient-retry-snippet Override iam_v3::PolicyBindingsClient Retry Policies + +This shows how to override the retry policies for iam_v3::PolicyBindingsClient: + +@snippet google/cloud/iam/v3/samples/policy_bindings_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/iam/v3/samples/policy_bindings_client_samples.cc custom-idempotency-policy + +*/ + +/*! @page iam_v3::PrincipalAccessBoundaryPoliciesClient-retry-snippet Override iam_v3::PrincipalAccessBoundaryPoliciesClient Retry Policies + +This shows how to override the retry policies for iam_v3::PrincipalAccessBoundaryPoliciesClient: + +@snippet google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc custom-idempotency-policy + */ // diff --git a/google/cloud/iam/v3/.repo-metadata.json b/google/cloud/iam/v3/.repo-metadata.json new file mode 100644 index 0000000000000..f2ac1870b44af --- /dev/null +++ b/google/cloud/iam/v3/.repo-metadata.json @@ -0,0 +1,14 @@ +{ + "api_id": "iam.googleapis.com", + "api_shortname": "iam", + "client_documentation": "https://cloud.google.com/cpp/docs/reference/iam/latest", + "distribution_name": "google-cloud-cpp", + "issue_tracker": "https://issuetracker.google.com/issues?q=componentid:1077618%20status=open", + "language": "cpp", + "library_type": "GAPIC_AUTO", + "name_pretty": "Identity and Access Management (IAM) API", + "product_documentation": "https://cloud.google.com/iam/docs/overview", + "release_level": "stable", + "repo": "googleapis/google-cloud-cpp", + "requires_billing": true +} diff --git a/google/cloud/iam/v3/internal/policy_bindings_auth_decorator.cc b/google/cloud/iam/v3/internal/policy_bindings_auth_decorator.cc new file mode 100644 index 0000000000000..21f2cf5984a01 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_auth_decorator.cc @@ -0,0 +1,194 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_auth_decorator.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PolicyBindingsAuth::PolicyBindingsAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +future> +PolicyBindingsAuth::AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest 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->AsyncCreatePolicyBinding(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr +PolicyBindingsAuth::CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreatePolicyBinding(context, options, request); +} + +StatusOr PolicyBindingsAuth::GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetPolicyBinding(context, options, request); +} + +future> +PolicyBindingsAuth::AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest 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->AsyncUpdatePolicyBinding(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr +PolicyBindingsAuth::UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdatePolicyBinding(context, options, request); +} + +future> +PolicyBindingsAuth::AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest 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->AsyncDeletePolicyBinding(cq, *std::move(context), + std::move(options), request); + }); +} + +StatusOr +PolicyBindingsAuth::DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeletePolicyBinding(context, options, request); +} + +StatusOr +PolicyBindingsAuth::ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListPolicyBindings(context, options, request); +} + +StatusOr +PolicyBindingsAuth::SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SearchTargetPolicyBindings(context, options, request); +} + +StatusOr PolicyBindingsAuth::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); +} + +future> +PolicyBindingsAuth::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 PolicyBindingsAuth::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 iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_auth_decorator.h b/google/cloud/iam/v3/internal/policy_bindings_auth_decorator.h new file mode 100644 index 0000000000000..d93b241d9d2f7 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_auth_decorator.h @@ -0,0 +1,112 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_AUTH_DECORATOR_H + +#include "google/cloud/iam/v3/internal/policy_bindings_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/version.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PolicyBindingsAuth : public PolicyBindingsStub { + public: + ~PolicyBindingsAuth() override = default; + PolicyBindingsAuth( + std::shared_ptr auth, + std::shared_ptr child); + + future> AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) override; + + future> AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + StatusOr UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + future> AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) override; + + StatusOr + SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) + override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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 iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_AUTH_DECORATOR_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_connection_impl.cc b/google/cloud/iam/v3/internal/policy_bindings_connection_impl.cc new file mode 100644 index 0000000000000..c2ca0d6f1204b --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_connection_impl.cc @@ -0,0 +1,429 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_connection_impl.h" +#include "google/cloud/iam/v3/internal/policy_bindings_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 iam_v3_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 + +PolicyBindingsConnectionImpl::PolicyBindingsConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions(std::move(options), + PolicyBindingsConnection::options())) {} + +future> +PolicyBindingsConnectionImpl::CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->CreatePolicyBinding(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::iam::v3::PolicyBinding>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + return stub->AsyncCreatePolicyBinding(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::iam::v3::PolicyBinding>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +PolicyBindingsConnectionImpl::CreatePolicyBinding( + NoAwaitTag, google::iam::v3::CreatePolicyBindingRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreatePolicyBinding(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + return stub_->CreatePolicyBinding(context, options, request); + }, + *current, request, __func__); +} + +future> +PolicyBindingsConnectionImpl::CreatePolicyBinding( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata().Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to CreatePolicyBinding", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::iam::v3::PolicyBinding>( + 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::iam::v3::PolicyBinding>, + polling_policy(*current), __func__); +} + +StatusOr +PolicyBindingsConnectionImpl::GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetPolicyBinding(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) { + return stub_->GetPolicyBinding(context, options, request); + }, + *current, request, __func__); +} + +future> +PolicyBindingsConnectionImpl::UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->UpdatePolicyBinding(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::iam::v3::PolicyBinding>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + return stub->AsyncUpdatePolicyBinding(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::iam::v3::PolicyBinding>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +PolicyBindingsConnectionImpl::UpdatePolicyBinding( + NoAwaitTag, google::iam::v3::UpdatePolicyBindingRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdatePolicyBinding(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + return stub_->UpdatePolicyBinding(context, options, request); + }, + *current, request, __func__); +} + +future> +PolicyBindingsConnectionImpl::UpdatePolicyBinding( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata().Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to UpdatePolicyBinding", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::iam::v3::PolicyBinding>( + 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::iam::v3::PolicyBinding>, + polling_policy(*current), __func__); +} + +future> +PolicyBindingsConnectionImpl::DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->DeletePolicyBinding(request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::iam::v3::OperationMetadata>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + return stub->AsyncDeletePolicyBinding(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::iam::v3::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +PolicyBindingsConnectionImpl::DeletePolicyBinding( + NoAwaitTag, google::iam::v3::DeletePolicyBindingRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeletePolicyBinding(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + return stub_->DeletePolicyBinding(context, options, request); + }, + *current, request, __func__); +} + +future> +PolicyBindingsConnectionImpl::DeletePolicyBinding( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata().Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to DeletePolicyBinding", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::iam::v3::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::iam::v3::OperationMetadata>, + polling_policy(*current), __func__); +} + +StreamRange +PolicyBindingsConnectionImpl::ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListPolicyBindings(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::iam::v3::ListPolicyBindingsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) { + return stub->ListPolicyBindings(context, options, request); + }, + options, r, function_name); + }, + [](google::iam::v3::ListPolicyBindingsResponse r) { + std::vector result( + r.policy_bindings().size()); + auto& messages = *r.mutable_policy_bindings(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StreamRange +PolicyBindingsConnectionImpl::SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = + idempotency_policy(*current)->SearchTargetPolicyBindings(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::iam::v3::SearchTargetPolicyBindingsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& + request) { + return stub->SearchTargetPolicyBindings(context, options, + request); + }, + options, r, function_name); + }, + [](google::iam::v3::SearchTargetPolicyBindingsResponse r) { + std::vector result( + r.policy_bindings().size()); + auto& messages = *r.mutable_policy_bindings(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PolicyBindingsConnectionImpl::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__); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_connection_impl.h b/google/cloud/iam/v3/internal/policy_bindings_connection_impl.h new file mode 100644 index 0000000000000..6e1d75d0e0506 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_connection_impl.h @@ -0,0 +1,107 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_CONNECTION_IMPL_H + +#include "google/cloud/iam/v3/internal/policy_bindings_retry_traits.h" +#include "google/cloud/iam/v3/internal/policy_bindings_stub.h" +#include "google/cloud/iam/v3/policy_bindings_connection.h" +#include "google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.h" +#include "google/cloud/iam/v3/policy_bindings_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 +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PolicyBindingsConnectionImpl : public iam_v3::PolicyBindingsConnection { + public: + ~PolicyBindingsConnectionImpl() override = default; + + PolicyBindingsConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options); + + Options options() override { return options_; } + + future> CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr CreatePolicyBinding( + NoAwaitTag, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + future> CreatePolicyBinding( + google::longrunning::Operation const& operation) override; + + StatusOr GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const& request) override; + + future> UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + StatusOr UpdatePolicyBinding( + NoAwaitTag, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + future> UpdatePolicyBinding( + google::longrunning::Operation const& operation) override; + + future> DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr DeletePolicyBinding( + NoAwaitTag, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + future> DeletePolicyBinding( + google::longrunning::Operation const& operation) override; + + StreamRange ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest request) override; + + StreamRange SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + private: + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_CONNECTION_IMPL_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_logging_decorator.cc b/google/cloud/iam/v3/internal/policy_bindings_logging_decorator.cc new file mode 100644 index 0000000000000..19e38541dba59 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_logging_decorator.cc @@ -0,0 +1,214 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_logging_decorator.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PolicyBindingsLogging::PolicyBindingsLogging( + std::shared_ptr child, TracingOptions tracing_options, + std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +future> +PolicyBindingsLogging::AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + return child_->AsyncCreatePolicyBinding(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +PolicyBindingsLogging::CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + return child_->CreatePolicyBinding(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyBindingsLogging::GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) { + return child_->GetPolicyBinding(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +PolicyBindingsLogging::AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + return child_->AsyncUpdatePolicyBinding(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +PolicyBindingsLogging::UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + return child_->UpdatePolicyBinding(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +PolicyBindingsLogging::AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + return child_->AsyncDeletePolicyBinding(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +PolicyBindingsLogging::DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + return child_->DeletePolicyBinding(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyBindingsLogging::ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) { + return child_->ListPolicyBindings(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyBindingsLogging::SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) { + return child_->SearchTargetPolicyBindings(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PolicyBindingsLogging::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_); +} + +future> +PolicyBindingsLogging::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 PolicyBindingsLogging::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 iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_logging_decorator.h b/google/cloud/iam/v3/internal/policy_bindings_logging_decorator.h new file mode 100644 index 0000000000000..f7d48ec1bd76d --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_logging_decorator.h @@ -0,0 +1,112 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_LOGGING_DECORATOR_H + +#include "google/cloud/iam/v3/internal/policy_bindings_stub.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PolicyBindingsLogging : public PolicyBindingsStub { + public: + ~PolicyBindingsLogging() override = default; + PolicyBindingsLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set const& components); + + future> AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) override; + + future> AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + StatusOr UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + future> AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) override; + + StatusOr + SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) + override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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_; +}; // PolicyBindingsLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_LOGGING_DECORATOR_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.cc b/google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.cc new file mode 100644 index 0000000000000..ec19246c0cf40 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.cc @@ -0,0 +1,188 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/absl_str_cat_quiet.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/internal/url_encode.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PolicyBindingsMetadata::PolicyBindingsMetadata( + 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)) {} + +future> +PolicyBindingsMetadata::AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AsyncCreatePolicyBinding(cq, std::move(context), + std::move(options), request); +} + +StatusOr +PolicyBindingsMetadata::CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreatePolicyBinding(context, options, request); +} + +StatusOr +PolicyBindingsMetadata::GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetPolicyBinding(context, options, request); +} + +future> +PolicyBindingsMetadata::AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + SetMetadata( + *context, *options, + absl::StrCat("policy_binding.name=", + internal::UrlEncode(request.policy_binding().name()))); + return child_->AsyncUpdatePolicyBinding(cq, std::move(context), + std::move(options), request); +} + +StatusOr +PolicyBindingsMetadata::UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("policy_binding.name=", + internal::UrlEncode(request.policy_binding().name()))); + return child_->UpdatePolicyBinding(context, options, request); +} + +future> +PolicyBindingsMetadata::AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncDeletePolicyBinding(cq, std::move(context), + std::move(options), request); +} + +StatusOr +PolicyBindingsMetadata::DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeletePolicyBinding(context, options, request); +} + +StatusOr +PolicyBindingsMetadata::ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListPolicyBindings(context, options, request); +} + +StatusOr +PolicyBindingsMetadata::SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->SearchTargetPolicyBindings(context, options, request); +} + +StatusOr PolicyBindingsMetadata::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); +} + +future> +PolicyBindingsMetadata::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 PolicyBindingsMetadata::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 PolicyBindingsMetadata::SetMetadata(grpc::ClientContext& context, + Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void PolicyBindingsMetadata::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 iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.h b/google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.h new file mode 100644 index 0000000000000..3ccd82185f4aa --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.h @@ -0,0 +1,117 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_METADATA_DECORATOR_H + +#include "google/cloud/iam/v3/internal/policy_bindings_stub.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PolicyBindingsMetadata : public PolicyBindingsStub { + public: + ~PolicyBindingsMetadata() override = default; + PolicyBindingsMetadata(std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + future> AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) override; + + future> AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + StatusOr UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + future> AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) override; + + StatusOr + SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) + override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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 iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_METADATA_DECORATOR_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_option_defaults.cc b/google/cloud/iam/v3/internal/policy_bindings_option_defaults.cc new file mode 100644 index 0000000000000..67f08d3892321 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_option_defaults.cc @@ -0,0 +1,74 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_option_defaults.h" +#include "google/cloud/iam/v3/policy_bindings_connection.h" +#include "google/cloud/iam/v3/policy_bindings_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 iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options PolicyBindingsDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_POLICY_BINDINGS_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_POLICY_BINDINGS_AUTHORITY", "iam.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + iam_v3::PolicyBindingsLimitedTimeRetryPolicy(std::chrono::minutes(30)) + .clone()); + } + if (!options.has()) { + options.set( + ExponentialBackoffPolicy( + std::chrono::seconds(0), std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling, kBackoffScaling) + .clone()); + } + if (!options.has()) { + options.set( + GenericPollingPolicy( + options.get()->clone(), + ExponentialBackoffPolicy(std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling) + .clone()) + .clone()); + } + if (!options.has()) { + options.set( + iam_v3::MakeDefaultPolicyBindingsConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_option_defaults.h b/google/cloud/iam/v3/internal/policy_bindings_option_defaults.h new file mode 100644 index 0000000000000..6c6357d0c0071 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options PolicyBindingsDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_OPTION_DEFAULTS_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_retry_traits.h b/google/cloud/iam/v3/internal/policy_bindings_retry_traits.h new file mode 100644 index 0000000000000..37e2c1de47f87 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct PolicyBindingsRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_RETRY_TRAITS_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_sources.cc b/google/cloud/iam/v3/internal/policy_bindings_sources.cc new file mode 100644 index 0000000000000..468d1c1ed6bc8 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_sources.cc @@ -0,0 +1,32 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/iam/v3/internal/policy_bindings_auth_decorator.cc" +#include "google/cloud/iam/v3/internal/policy_bindings_connection_impl.cc" +#include "google/cloud/iam/v3/internal/policy_bindings_logging_decorator.cc" +#include "google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.cc" +#include "google/cloud/iam/v3/internal/policy_bindings_option_defaults.cc" +#include "google/cloud/iam/v3/internal/policy_bindings_stub.cc" +#include "google/cloud/iam/v3/internal/policy_bindings_stub_factory.cc" +#include "google/cloud/iam/v3/internal/policy_bindings_tracing_connection.cc" +#include "google/cloud/iam/v3/internal/policy_bindings_tracing_stub.cc" +#include "google/cloud/iam/v3/policy_bindings_client.cc" +#include "google/cloud/iam/v3/policy_bindings_connection.cc" +#include "google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/iam/v3/internal/policy_bindings_stub.cc b/google/cloud/iam/v3/internal/policy_bindings_stub.cc new file mode 100644 index 0000000000000..625aab21a7f23 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_stub.cc @@ -0,0 +1,212 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_stub.h" +#include "google/cloud/grpc_error_delegate.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PolicyBindingsStub::~PolicyBindingsStub() = default; + +future> +DefaultPolicyBindingsStub::AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::iam::v3::CreatePolicyBindingRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::iam::v3::CreatePolicyBindingRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncCreatePolicyBinding(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultPolicyBindingsStub::CreatePolicyBinding( + grpc::ClientContext& context, Options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->CreatePolicyBinding(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBindingsStub::GetPolicyBinding( + grpc::ClientContext& context, Options const&, + google::iam::v3::GetPolicyBindingRequest const& request) { + google::iam::v3::PolicyBinding response; + auto status = grpc_stub_->GetPolicyBinding(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultPolicyBindingsStub::AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::iam::v3::UpdatePolicyBindingRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncUpdatePolicyBinding(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultPolicyBindingsStub::UpdatePolicyBinding( + grpc::ClientContext& context, Options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->UpdatePolicyBinding(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultPolicyBindingsStub::AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::iam::v3::DeletePolicyBindingRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::iam::v3::DeletePolicyBindingRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncDeletePolicyBinding(context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultPolicyBindingsStub::DeletePolicyBinding( + grpc::ClientContext& context, Options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + google::longrunning::Operation response; + auto status = grpc_stub_->DeletePolicyBinding(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBindingsStub::ListPolicyBindings( + grpc::ClientContext& context, Options const&, + google::iam::v3::ListPolicyBindingsRequest const& request) { + google::iam::v3::ListPolicyBindingsResponse response; + auto status = grpc_stub_->ListPolicyBindings(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBindingsStub::SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const&, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) { + google::iam::v3::SearchTargetPolicyBindingsResponse response; + auto status = + grpc_stub_->SearchTargetPolicyBindings(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBindingsStub::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; +} + +future> +DefaultPolicyBindingsStub::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 DefaultPolicyBindingsStub::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 iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_stub.h b/google/cloud/iam/v3/internal/policy_bindings_stub.h new file mode 100644 index 0000000000000..8ba9339dd6f54 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_stub.h @@ -0,0 +1,185 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_STUB_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 +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PolicyBindingsStub { + public: + virtual ~PolicyBindingsStub() = 0; + + virtual future> + AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) = 0; + + virtual StatusOr CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) = 0; + + virtual StatusOr GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) = 0; + + virtual future> + AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) = 0; + + virtual StatusOr UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) = 0; + + virtual future> + AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) = 0; + + virtual StatusOr DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) = 0; + + virtual StatusOr + ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) = 0; + + virtual StatusOr + SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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 DefaultPolicyBindingsStub : public PolicyBindingsStub { + public: + DefaultPolicyBindingsStub( + std::unique_ptr grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} + + future> AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) override; + + future> AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + StatusOr UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + future> AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) override; + + StatusOr + SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) + override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::unique_ptr grpc_stub_; + std::unique_ptr + operations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_STUB_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_stub_factory.cc b/google/cloud/iam/v3/internal/policy_bindings_stub_factory.cc new file mode 100644 index 0000000000000..8a67bad0d46a4 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_stub_factory.cc @@ -0,0 +1,73 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_stub_factory.h" +#include "google/cloud/iam/v3/internal/policy_bindings_auth_decorator.h" +#include "google/cloud/iam/v3/internal/policy_bindings_logging_decorator.h" +#include "google/cloud/iam/v3/internal/policy_bindings_metadata_decorator.h" +#include "google/cloud/iam/v3/internal/policy_bindings_stub.h" +#include "google/cloud/iam/v3/internal/policy_bindings_tracing_stub.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultPolicyBindingsStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = google::iam::v3::PolicyBindings::NewStub(channel); + std::shared_ptr stub = + std::make_shared( + std::move(service_grpc_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 = MakePolicyBindingsTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_stub_factory.h b/google/cloud/iam/v3/internal/policy_bindings_stub_factory.h new file mode 100644 index 0000000000000..ca261b13e60e2 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_stub_factory.h @@ -0,0 +1,42 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_STUB_FACTORY_H + +#include "google/cloud/iam/v3/internal/policy_bindings_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultPolicyBindingsStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_STUB_FACTORY_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_tracing_connection.cc b/google/cloud/iam/v3/internal/policy_bindings_tracing_connection.cc new file mode 100644 index 0000000000000..f587893f2dee4 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_tracing_connection.cc @@ -0,0 +1,182 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +PolicyBindingsTracingConnection::PolicyBindingsTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +future> +PolicyBindingsTracingConnection::CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const& request) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::CreatePolicyBinding"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->CreatePolicyBinding(request)); +} + +StatusOr +PolicyBindingsTracingConnection::CreatePolicyBinding( + NoAwaitTag, google::iam::v3::CreatePolicyBindingRequest const& request) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::CreatePolicyBinding"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->CreatePolicyBinding(NoAwaitTag{}, request)); +} + +future> +PolicyBindingsTracingConnection::CreatePolicyBinding( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::CreatePolicyBinding"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->CreatePolicyBinding(operation)); +} + +StatusOr +PolicyBindingsTracingConnection::GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const& request) { + auto span = + internal::MakeSpan("iam_v3::PolicyBindingsConnection::GetPolicyBinding"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetPolicyBinding(request)); +} + +future> +PolicyBindingsTracingConnection::UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const& request) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::UpdatePolicyBinding"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->UpdatePolicyBinding(request)); +} + +StatusOr +PolicyBindingsTracingConnection::UpdatePolicyBinding( + NoAwaitTag, google::iam::v3::UpdatePolicyBindingRequest const& request) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::UpdatePolicyBinding"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->UpdatePolicyBinding(NoAwaitTag{}, request)); +} + +future> +PolicyBindingsTracingConnection::UpdatePolicyBinding( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::UpdatePolicyBinding"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->UpdatePolicyBinding(operation)); +} + +future> +PolicyBindingsTracingConnection::DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const& request) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::DeletePolicyBinding"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->DeletePolicyBinding(request)); +} + +StatusOr +PolicyBindingsTracingConnection::DeletePolicyBinding( + NoAwaitTag, google::iam::v3::DeletePolicyBindingRequest const& request) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::DeletePolicyBinding"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, + child_->DeletePolicyBinding(NoAwaitTag{}, request)); +} + +future> +PolicyBindingsTracingConnection::DeletePolicyBinding( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::DeletePolicyBinding"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), + child_->DeletePolicyBinding(operation)); +} + +StreamRange +PolicyBindingsTracingConnection::ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest request) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::ListPolicyBindings"); + internal::OTelScope scope(span); + auto sr = child_->ListPolicyBindings(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StreamRange +PolicyBindingsTracingConnection::SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest request) { + auto span = internal::MakeSpan( + "iam_v3::PolicyBindingsConnection::SearchTargetPolicyBindings"); + internal::OTelScope scope(span); + auto sr = child_->SearchTargetPolicyBindings(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PolicyBindingsTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpan("iam_v3::PolicyBindingsConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +std::shared_ptr +MakePolicyBindingsTracingConnection( + std::shared_ptr conn) { +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + if (internal::TracingEnabled(conn->options())) { + conn = std::make_shared(std::move(conn)); + } +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + return conn; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_tracing_connection.h b/google/cloud/iam/v3/internal/policy_bindings_tracing_connection.h new file mode 100644 index 0000000000000..8733c0aa3fbd2 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_tracing_connection.h @@ -0,0 +1,106 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_TRACING_CONNECTION_H + +#include "google/cloud/iam/v3/policy_bindings_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +class PolicyBindingsTracingConnection + : public iam_v3::PolicyBindingsConnection { + public: + ~PolicyBindingsTracingConnection() override = default; + + explicit PolicyBindingsTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + future> CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr CreatePolicyBinding( + NoAwaitTag, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + future> CreatePolicyBinding( + google::longrunning::Operation const& operation) override; + + StatusOr GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const& request) override; + + future> UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + StatusOr UpdatePolicyBinding( + NoAwaitTag, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + future> UpdatePolicyBinding( + google::longrunning::Operation const& operation) override; + + future> DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr DeletePolicyBinding( + NoAwaitTag, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + future> DeletePolicyBinding( + google::longrunning::Operation const& operation) override; + + StreamRange ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest request) override; + + StreamRange SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + private: + std::shared_ptr child_; +}; + +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +/** + * 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 +MakePolicyBindingsTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_TRACING_CONNECTION_H diff --git a/google/cloud/iam/v3/internal/policy_bindings_tracing_stub.cc b/google/cloud/iam/v3/internal/policy_bindings_tracing_stub.cc new file mode 100644 index 0000000000000..e0d6e3a47acf8 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_tracing_stub.cc @@ -0,0 +1,207 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/internal/policy_bindings_tracing_stub.h" +#include "google/cloud/internal/grpc_opentelemetry.h" +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +PolicyBindingsTracingStub::PolicyBindingsTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +future> +PolicyBindingsTracingStub::AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "CreatePolicyBinding"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncCreatePolicyBinding(cq, context, std::move(options), + request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +PolicyBindingsTracingStub::CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "CreatePolicyBinding"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->CreatePolicyBinding(context, options, request)); +} + +StatusOr +PolicyBindingsTracingStub::GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "GetPolicyBinding"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetPolicyBinding(context, options, request)); +} + +future> +PolicyBindingsTracingStub::AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "UpdatePolicyBinding"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncUpdatePolicyBinding(cq, context, std::move(options), + request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +PolicyBindingsTracingStub::UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "UpdatePolicyBinding"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->UpdatePolicyBinding(context, options, request)); +} + +future> +PolicyBindingsTracingStub::AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "DeletePolicyBinding"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncDeletePolicyBinding(cq, context, std::move(options), + request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +PolicyBindingsTracingStub::DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "DeletePolicyBinding"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->DeletePolicyBinding(context, options, request)); +} + +StatusOr +PolicyBindingsTracingStub::ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "ListPolicyBindings"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->ListPolicyBindings(context, options, request)); +} + +StatusOr +PolicyBindingsTracingStub::SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", + "SearchTargetPolicyBindings"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->SearchTargetPolicyBindings(context, options, request)); +} + +StatusOr +PolicyBindingsTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PolicyBindings", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +future> +PolicyBindingsTracingStub::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 PolicyBindingsTracingStub::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)); +} + +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +std::shared_ptr MakePolicyBindingsTracingStub( + std::shared_ptr stub) { +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + return std::make_shared(std::move(stub)); +#else + return stub; +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/policy_bindings_tracing_stub.h b/google/cloud/iam/v3/internal/policy_bindings_tracing_stub.h new file mode 100644 index 0000000000000..69d89d0bb9665 --- /dev/null +++ b/google/cloud/iam/v3/internal/policy_bindings_tracing_stub.h @@ -0,0 +1,123 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_TRACING_STUB_H + +#include "google/cloud/iam/v3/internal/policy_bindings_stub.h" +#include "google/cloud/internal/trace_propagator.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +class PolicyBindingsTracingStub : public PolicyBindingsStub { + public: + ~PolicyBindingsTracingStub() override = default; + + explicit PolicyBindingsTracingStub(std::shared_ptr child); + + future> AsyncCreatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr CreatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePolicyBindingRequest const& request) override; + + StatusOr GetPolicyBinding( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPolicyBindingRequest const& request) override; + + future> AsyncUpdatePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + StatusOr UpdatePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePolicyBindingRequest const& request) override; + + future> AsyncDeletePolicyBinding( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr DeletePolicyBinding( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePolicyBindingRequest const& request) override; + + StatusOr ListPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPolicyBindingsRequest const& request) override; + + StatusOr + SearchTargetPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchTargetPolicyBindingsRequest const& request) + override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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_; +}; + +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +/** + * Applies the tracing decorator to the given stub. + * + * The stub is only decorated if the library has been compiled with + * OpenTelemetry. + */ +std::shared_ptr MakePolicyBindingsTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_POLICY_BINDINGS_TRACING_STUB_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.cc new file mode 100644 index 0000000000000..67a5e835c3835 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.cc @@ -0,0 +1,206 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PrincipalAccessBoundaryPoliciesAuth::PrincipalAccessBoundaryPoliciesAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +future> +PrincipalAccessBoundaryPoliciesAuth::AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest 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->AsyncCreatePrincipalAccessBoundaryPolicy( + cq, *std::move(context), std::move(options), request); + }); +} + +StatusOr +PrincipalAccessBoundaryPoliciesAuth::CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreatePrincipalAccessBoundaryPolicy(context, options, request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesAuth::GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetPrincipalAccessBoundaryPolicy(context, options, request); +} + +future> +PrincipalAccessBoundaryPoliciesAuth::AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest 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->AsyncUpdatePrincipalAccessBoundaryPolicy( + cq, *std::move(context), std::move(options), request); + }); +} + +StatusOr +PrincipalAccessBoundaryPoliciesAuth::UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdatePrincipalAccessBoundaryPolicy(context, options, request); +} + +future> +PrincipalAccessBoundaryPoliciesAuth::AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest 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->AsyncDeletePrincipalAccessBoundaryPolicy( + cq, *std::move(context), std::move(options), request); + }); +} + +StatusOr +PrincipalAccessBoundaryPoliciesAuth::DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeletePrincipalAccessBoundaryPolicy(context, options, request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesAuth::ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListPrincipalAccessBoundaryPolicies(context, options, request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesAuth:: + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SearchPrincipalAccessBoundaryPolicyBindings(context, options, + request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesAuth::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); +} + +future> +PrincipalAccessBoundaryPoliciesAuth::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 PrincipalAccessBoundaryPoliciesAuth::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 iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.h new file mode 100644 index 0000000000000..5afdb6b511a8f --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.h @@ -0,0 +1,126 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_AUTH_DECORATOR_H + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/version.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PrincipalAccessBoundaryPoliciesAuth + : public PrincipalAccessBoundaryPoliciesStub { + public: + ~PrincipalAccessBoundaryPoliciesAuth() override = default; + PrincipalAccessBoundaryPoliciesAuth( + std::shared_ptr auth, + std::shared_ptr child); + + future> + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) + override; + + future> + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) override; + + StatusOr + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest const& + request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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 iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_AUTH_DECORATOR_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.cc new file mode 100644 index 0000000000000..627fb1e94af6b --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.cc @@ -0,0 +1,498 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_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 iam_v3_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< + iam_v3::PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy> +idempotency_policy(Options const& options) { + return options + .get< + iam_v3:: + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicyOption>() + ->clone(); +} + +std::unique_ptr polling_policy(Options const& options) { + return options + .get() + ->clone(); +} + +} // namespace + +PrincipalAccessBoundaryPoliciesConnectionImpl:: + PrincipalAccessBoundaryPoliciesConnectionImpl( + std::unique_ptr background, + std::shared_ptr + stub, + Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions( + std::move(options), + PrincipalAccessBoundaryPoliciesConnection::options())) {} + +future> +PrincipalAccessBoundaryPoliciesConnectionImpl:: + CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->CreatePrincipalAccessBoundaryPolicy( + request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::iam::v3::PrincipalAccessBoundaryPolicy>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + return stub->AsyncCreatePrincipalAccessBoundaryPolicy( + 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::iam::v3::PrincipalAccessBoundaryPolicy>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnectionImpl:: + CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreatePrincipalAccessBoundaryPolicy( + request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + return stub_->CreatePrincipalAccessBoundaryPolicy(context, options, + request); + }, + *current, request, __func__); +} + +future> +PrincipalAccessBoundaryPoliciesConnectionImpl:: + CreatePrincipalAccessBoundaryPolicy( + 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 " + "CreatePrincipalAccessBoundaryPolicy", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::iam::v3::PrincipalAccessBoundaryPolicy>( + 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::iam::v3::PrincipalAccessBoundaryPolicy>, + polling_policy(*current), __func__); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnectionImpl::GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetPrincipalAccessBoundaryPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& + request) { + return stub_->GetPrincipalAccessBoundaryPolicy(context, options, + request); + }, + *current, request, __func__); +} + +future> +PrincipalAccessBoundaryPoliciesConnectionImpl:: + UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->UpdatePrincipalAccessBoundaryPolicy( + request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::iam::v3::PrincipalAccessBoundaryPolicy>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + return stub->AsyncUpdatePrincipalAccessBoundaryPolicy( + 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::iam::v3::PrincipalAccessBoundaryPolicy>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnectionImpl:: + UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdatePrincipalAccessBoundaryPolicy( + request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + return stub_->UpdatePrincipalAccessBoundaryPolicy(context, options, + request); + }, + *current, request, __func__); +} + +future> +PrincipalAccessBoundaryPoliciesConnectionImpl:: + UpdatePrincipalAccessBoundaryPolicy( + 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 " + "UpdatePrincipalAccessBoundaryPolicy", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::iam::v3::PrincipalAccessBoundaryPolicy>( + 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::iam::v3::PrincipalAccessBoundaryPolicy>, + polling_policy(*current), __func__); +} + +future> +PrincipalAccessBoundaryPoliciesConnectionImpl:: + DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + auto request_copy = request; + auto const idempotent = + idempotency_policy(*current)->DeletePrincipalAccessBoundaryPolicy( + request_copy); + return google::cloud::internal::AsyncLongRunningOperation< + google::iam::v3::OperationMetadata>( + background_->cq(), current, std::move(request_copy), + [stub = stub_]( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + return stub->AsyncDeletePrincipalAccessBoundaryPolicy( + 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::iam::v3::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), idempotent, + polling_policy(*current), __func__); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnectionImpl:: + DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeletePrincipalAccessBoundaryPolicy( + request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + return stub_->DeletePrincipalAccessBoundaryPolicy(context, options, + request); + }, + *current, request, __func__); +} + +future> +PrincipalAccessBoundaryPoliciesConnectionImpl:: + DeletePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata().Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to " + "DeletePrincipalAccessBoundaryPolicy", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + + return google::cloud::internal::AsyncAwaitLongRunningOperation< + google::iam::v3::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::iam::v3::OperationMetadata>, + polling_policy(*current), __func__); +} + +StreamRange +PrincipalAccessBoundaryPoliciesConnectionImpl:: + ListPrincipalAccessBoundaryPolicies( + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = + idempotency_policy(*current)->ListPrincipalAccessBoundaryPolicies( + 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::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::iam::v3:: + ListPrincipalAccessBoundaryPoliciesRequest const& request) { + return stub->ListPrincipalAccessBoundaryPolicies(context, options, + request); + }, + options, r, function_name); + }, + [](google::iam::v3::ListPrincipalAccessBoundaryPoliciesResponse r) { + std::vector result( + r.principal_access_boundary_policies().size()); + auto& messages = *r.mutable_principal_access_boundary_policies(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StreamRange +PrincipalAccessBoundaryPoliciesConnectionImpl:: + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = + idempotency_policy(*current)->SearchPrincipalAccessBoundaryPolicyBindings( + 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::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, Options const& options, + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest const& + request) { + return stub->SearchPrincipalAccessBoundaryPolicyBindings( + context, options, request); + }, + options, r, function_name); + }, + [](google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsResponse + r) { + std::vector result( + r.policy_bindings().size()); + auto& messages = *r.mutable_policy_bindings(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnectionImpl::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__); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.h new file mode 100644 index 0000000000000..10cb8c364979d --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.h @@ -0,0 +1,127 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_IMPL_H + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_retry_traits.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_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 +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PrincipalAccessBoundaryPoliciesConnectionImpl + : public iam_v3::PrincipalAccessBoundaryPoliciesConnection { + public: + ~PrincipalAccessBoundaryPoliciesConnectionImpl() override = default; + + PrincipalAccessBoundaryPoliciesConnectionImpl( + std::unique_ptr background, + std::shared_ptr + stub, + Options options); + + Options options() override { return options_; } + + future> + CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + CreatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) override; + + StatusOr + GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) + override; + + future> + UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + UpdatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) override; + + future> + DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + DeletePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) override; + + StreamRange + ListPrincipalAccessBoundaryPolicies( + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request) + override; + + StreamRange + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + private: + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_IMPL_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.cc new file mode 100644 index 0000000000000..a58318c46f9aa --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.cc @@ -0,0 +1,242 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PrincipalAccessBoundaryPoliciesLogging::PrincipalAccessBoundaryPoliciesLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set const&) + : child_(std::move(child)), tracing_options_(std::move(tracing_options)) {} + +future> +PrincipalAccessBoundaryPoliciesLogging:: + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + return child_->AsyncCreatePrincipalAccessBoundaryPolicy( + cq, std::move(context), std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +PrincipalAccessBoundaryPoliciesLogging::CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + return child_->CreatePrincipalAccessBoundaryPolicy(context, options, + request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PrincipalAccessBoundaryPoliciesLogging::GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& + request) { + return child_->GetPrincipalAccessBoundaryPolicy(context, options, + request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +PrincipalAccessBoundaryPoliciesLogging:: + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + return child_->AsyncUpdatePrincipalAccessBoundaryPolicy( + cq, std::move(context), std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +PrincipalAccessBoundaryPoliciesLogging::UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + return child_->UpdatePrincipalAccessBoundaryPolicy(context, options, + request); + }, + context, options, request, __func__, tracing_options_); +} + +future> +PrincipalAccessBoundaryPoliciesLogging:: + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + return child_->AsyncDeletePrincipalAccessBoundaryPolicy( + cq, std::move(context), std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr +PrincipalAccessBoundaryPoliciesLogging::DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + return child_->DeletePrincipalAccessBoundaryPolicy(context, options, + request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PrincipalAccessBoundaryPoliciesLogging::ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) { + return child_->ListPrincipalAccessBoundaryPolicies(context, options, + request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PrincipalAccessBoundaryPoliciesLogging:: + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest const& + request) { + return child_->SearchPrincipalAccessBoundaryPolicyBindings( + context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PrincipalAccessBoundaryPoliciesLogging::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_); +} + +future> +PrincipalAccessBoundaryPoliciesLogging::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 PrincipalAccessBoundaryPoliciesLogging::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 iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.h new file mode 100644 index 0000000000000..60b42cb6554ba --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.h @@ -0,0 +1,126 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_LOGGING_DECORATOR_H + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PrincipalAccessBoundaryPoliciesLogging + : public PrincipalAccessBoundaryPoliciesStub { + public: + ~PrincipalAccessBoundaryPoliciesLogging() override = default; + PrincipalAccessBoundaryPoliciesLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set const& components); + + future> + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) + override; + + future> + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) override; + + StatusOr + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest const& + request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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_; +}; // PrincipalAccessBoundaryPoliciesLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_LOGGING_DECORATOR_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.cc new file mode 100644 index 0000000000000..04383197af513 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.cc @@ -0,0 +1,205 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/absl_str_cat_quiet.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/internal/url_encode.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PrincipalAccessBoundaryPoliciesMetadata:: + PrincipalAccessBoundaryPoliciesMetadata( + 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)) {} + +future> +PrincipalAccessBoundaryPoliciesMetadata:: + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + SetMetadata(*context, *options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->AsyncCreatePrincipalAccessBoundaryPolicy( + cq, std::move(context), std::move(options), request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesMetadata::CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->CreatePrincipalAccessBoundaryPolicy(context, options, request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesMetadata::GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetPrincipalAccessBoundaryPolicy(context, options, request); +} + +future> +PrincipalAccessBoundaryPoliciesMetadata:: + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + SetMetadata( + *context, *options, + absl::StrCat("principal_access_boundary_policy.name=", + internal::UrlEncode( + request.principal_access_boundary_policy().name()))); + return child_->AsyncUpdatePrincipalAccessBoundaryPolicy( + cq, std::move(context), std::move(options), request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesMetadata::UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + SetMetadata( + context, options, + absl::StrCat("principal_access_boundary_policy.name=", + internal::UrlEncode( + request.principal_access_boundary_policy().name()))); + return child_->UpdatePrincipalAccessBoundaryPolicy(context, options, request); +} + +future> +PrincipalAccessBoundaryPoliciesMetadata:: + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + SetMetadata(*context, *options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->AsyncDeletePrincipalAccessBoundaryPolicy( + cq, std::move(context), std::move(options), request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesMetadata::DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->DeletePrincipalAccessBoundaryPolicy(context, options, request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesMetadata::ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) { + SetMetadata(context, options, + absl::StrCat("parent=", internal::UrlEncode(request.parent()))); + return child_->ListPrincipalAccessBoundaryPolicies(context, options, request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesMetadata:: + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->SearchPrincipalAccessBoundaryPolicyBindings(context, options, + request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesMetadata::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); +} + +future> +PrincipalAccessBoundaryPoliciesMetadata::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 PrincipalAccessBoundaryPoliciesMetadata::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 PrincipalAccessBoundaryPoliciesMetadata::SetMetadata( + grpc::ClientContext& context, Options const& options, + std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context, options); +} + +void PrincipalAccessBoundaryPoliciesMetadata::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 iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.h new file mode 100644 index 0000000000000..f59528c0aa034 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.h @@ -0,0 +1,132 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_METADATA_DECORATOR_H + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PrincipalAccessBoundaryPoliciesMetadata + : public PrincipalAccessBoundaryPoliciesStub { + public: + ~PrincipalAccessBoundaryPoliciesMetadata() override = default; + PrincipalAccessBoundaryPoliciesMetadata( + std::shared_ptr child, + std::multimap fixed_metadata, + std::string api_client_header = ""); + + future> + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) + override; + + future> + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) override; + + StatusOr + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest const& + request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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 iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_METADATA_DECORATOR_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.cc new file mode 100644 index 0000000000000..c8626c455d1f6 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.cc @@ -0,0 +1,88 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_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 iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options PrincipalAccessBoundaryPoliciesDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), + "GOOGLE_CLOUD_CPP_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_AUTHORITY", + "iam.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options + .has()) { + options.set( + iam_v3::PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy( + std::chrono::minutes(30)) + .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< + iam_v3::PrincipalAccessBoundaryPoliciesRetryPolicyOption::Type, + iam_v3::PrincipalAccessBoundaryPoliciesBackoffPolicyOption::Type>( + options + .get() + ->clone(), + ExponentialBackoffPolicy(std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling) + .clone()) + .clone()); + } + if (!options.has< + iam_v3:: + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicyOption>()) { + options.set< + iam_v3:: + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicyOption>( + iam_v3:: + MakeDefaultPrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.h new file mode 100644 index 0000000000000..2cb8a00c6c261 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options PrincipalAccessBoundaryPoliciesDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_OPTION_DEFAULTS_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_retry_traits.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_retry_traits.h new file mode 100644 index 0000000000000..a0b9120263afc --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct PrincipalAccessBoundaryPoliciesRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_RETRY_TRAITS_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_sources.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_sources.cc new file mode 100644 index 0000000000000..3bdfcfc445b24 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_sources.cc @@ -0,0 +1,32 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.cc" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.cc" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.cc" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.cc" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.cc" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.cc" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.cc" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.cc" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.cc" +#include "google/cloud/iam/v3/principal_access_boundary_policies_client.cc" +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection.cc" +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.cc new file mode 100644 index 0000000000000..8013ddfe32f1b --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.cc @@ -0,0 +1,239 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h" +#include "google/cloud/grpc_error_delegate.h" +#include "google/cloud/status_or.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PrincipalAccessBoundaryPoliciesStub::~PrincipalAccessBoundaryPoliciesStub() = + default; + +future> +DefaultPrincipalAccessBoundaryPoliciesStub:: + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + return internal::MakeUnaryRpcImpl< + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncCreatePrincipalAccessBoundaryPolicy( + context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultPrincipalAccessBoundaryPoliciesStub::CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + google::longrunning::Operation response; + auto status = grpc_stub_->CreatePrincipalAccessBoundaryPolicy( + &context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPrincipalAccessBoundaryPoliciesStub::GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) { + google::iam::v3::PrincipalAccessBoundaryPolicy response; + auto status = grpc_stub_->GetPrincipalAccessBoundaryPolicy(&context, request, + &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultPrincipalAccessBoundaryPoliciesStub:: + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + return internal::MakeUnaryRpcImpl< + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncUpdatePrincipalAccessBoundaryPolicy( + context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultPrincipalAccessBoundaryPoliciesStub::UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + google::longrunning::Operation response; + auto status = grpc_stub_->UpdatePrincipalAccessBoundaryPolicy( + &context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +future> +DefaultPrincipalAccessBoundaryPoliciesStub:: + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + return internal::MakeUnaryRpcImpl< + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest, + google::longrunning::Operation>( + cq, + [this](grpc::ClientContext* context, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncDeletePrincipalAccessBoundaryPolicy( + context, request, cq); + }, + request, std::move(context)); +} + +StatusOr +DefaultPrincipalAccessBoundaryPoliciesStub::DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + google::longrunning::Operation response; + auto status = grpc_stub_->DeletePrincipalAccessBoundaryPolicy( + &context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPrincipalAccessBoundaryPoliciesStub::ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const&, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) { + google::iam::v3::ListPrincipalAccessBoundaryPoliciesResponse response; + auto status = grpc_stub_->ListPrincipalAccessBoundaryPolicies( + &context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPrincipalAccessBoundaryPoliciesStub:: + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const&, + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest const& request) { + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsResponse response; + auto status = grpc_stub_->SearchPrincipalAccessBoundaryPolicyBindings( + &context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPrincipalAccessBoundaryPoliciesStub::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; +} + +future> +DefaultPrincipalAccessBoundaryPoliciesStub::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 DefaultPrincipalAccessBoundaryPoliciesStub::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 iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h new file mode 100644 index 0000000000000..e80d4c14de174 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h @@ -0,0 +1,217 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_STUB_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 +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PrincipalAccessBoundaryPoliciesStub { + public: + virtual ~PrincipalAccessBoundaryPoliciesStub() = 0; + + virtual future> + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) = 0; + + virtual StatusOr + CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) = 0; + + virtual StatusOr + GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& + request) = 0; + + virtual future> + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) = 0; + + virtual StatusOr + UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) = 0; + + virtual future> + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) = 0; + + virtual StatusOr + DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) = 0; + + virtual StatusOr + ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) = 0; + + virtual StatusOr< + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsResponse> + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest const& + request) = 0; + + virtual StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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 DefaultPrincipalAccessBoundaryPoliciesStub + : public PrincipalAccessBoundaryPoliciesStub { + public: + DefaultPrincipalAccessBoundaryPoliciesStub( + std::unique_ptr< + google::iam::v3::PrincipalAccessBoundaryPolicies::StubInterface> + grpc_stub, + std::unique_ptr + operations_stub) + : grpc_stub_(std::move(grpc_stub)), + operations_stub_(std::move(operations_stub)) {} + + future> + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) + override; + + future> + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) override; + + StatusOr + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest const& + request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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::iam::v3::PrincipalAccessBoundaryPolicies::StubInterface> + grpc_stub_; + std::unique_ptr + operations_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_STUB_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.cc new file mode 100644 index 0000000000000..05a8494d50c0d --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.cc @@ -0,0 +1,75 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_auth_decorator.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_logging_decorator.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_metadata_decorator.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +CreateDefaultPrincipalAccessBoundaryPoliciesStub( + std::shared_ptr auth, + Options const& options) { + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::iam::v3::PrincipalAccessBoundaryPolicies::NewStub(channel); + std::shared_ptr stub = + std::make_shared( + std::move(service_grpc_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 = MakePrincipalAccessBoundaryPoliciesTracingStub(std::move(stub)); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.h new file mode 100644 index 0000000000000..9ba1fe6f41240 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.h @@ -0,0 +1,43 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_STUB_FACTORY_H + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +CreateDefaultPrincipalAccessBoundaryPoliciesStub( + std::shared_ptr auth, + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_STUB_FACTORY_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.cc new file mode 100644 index 0000000000000..040a2432b9562 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.cc @@ -0,0 +1,223 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +PrincipalAccessBoundaryPoliciesTracingConnection:: + PrincipalAccessBoundaryPoliciesTracingConnection( + std::shared_ptr + child) + : child_(std::move(child)) {} + +future> +PrincipalAccessBoundaryPoliciesTracingConnection:: + CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "CreatePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + return internal::EndSpan( + std::move(span), child_->CreatePrincipalAccessBoundaryPolicy(request)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingConnection:: + CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "CreatePrincipalAccessBoundaryPolicy"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag{}, request)); +} + +future> +PrincipalAccessBoundaryPoliciesTracingConnection:: + CreatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "CreatePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + return internal::EndSpan( + std::move(span), child_->CreatePrincipalAccessBoundaryPolicy(operation)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingConnection:: + GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "GetPrincipalAccessBoundaryPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, + child_->GetPrincipalAccessBoundaryPolicy(request)); +} + +future> +PrincipalAccessBoundaryPoliciesTracingConnection:: + UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "UpdatePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + return internal::EndSpan( + std::move(span), child_->UpdatePrincipalAccessBoundaryPolicy(request)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingConnection:: + UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "UpdatePrincipalAccessBoundaryPolicy"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag{}, request)); +} + +future> +PrincipalAccessBoundaryPoliciesTracingConnection:: + UpdatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "UpdatePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + return internal::EndSpan( + std::move(span), child_->UpdatePrincipalAccessBoundaryPolicy(operation)); +} + +future> +PrincipalAccessBoundaryPoliciesTracingConnection:: + DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "DeletePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + return internal::EndSpan( + std::move(span), child_->DeletePrincipalAccessBoundaryPolicy(request)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingConnection:: + DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "DeletePrincipalAccessBoundaryPolicy"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag{}, request)); +} + +future> +PrincipalAccessBoundaryPoliciesTracingConnection:: + DeletePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "DeletePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + return internal::EndSpan( + std::move(span), child_->DeletePrincipalAccessBoundaryPolicy(operation)); +} + +StreamRange +PrincipalAccessBoundaryPoliciesTracingConnection:: + ListPrincipalAccessBoundaryPolicies( + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "ListPrincipalAccessBoundaryPolicies"); + internal::OTelScope scope(span); + auto sr = child_->ListPrincipalAccessBoundaryPolicies(std::move(request)); + return internal::MakeTracedStreamRange< + google::iam::v3::PrincipalAccessBoundaryPolicy>(std::move(span), + std::move(sr)); +} + +StreamRange +PrincipalAccessBoundaryPoliciesTracingConnection:: + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::" + "SearchPrincipalAccessBoundaryPolicyBindings"); + internal::OTelScope scope(span); + auto sr = + child_->SearchPrincipalAccessBoundaryPolicyBindings(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan( + "iam_v3::PrincipalAccessBoundaryPoliciesConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +std::shared_ptr +MakePrincipalAccessBoundaryPoliciesTracingConnection( + std::shared_ptr conn) { +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + if (internal::TracingEnabled(conn->options())) { + conn = std::make_shared( + std::move(conn)); + } +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + return conn; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.h new file mode 100644 index 0000000000000..d9a17537bebeb --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.h @@ -0,0 +1,124 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_TRACING_CONNECTION_H + +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +class PrincipalAccessBoundaryPoliciesTracingConnection + : public iam_v3::PrincipalAccessBoundaryPoliciesConnection { + public: + ~PrincipalAccessBoundaryPoliciesTracingConnection() override = default; + + explicit PrincipalAccessBoundaryPoliciesTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + future> + CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + CreatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) override; + + StatusOr + GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) + override; + + future> + UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + UpdatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) override; + + future> + DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + DeletePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation) override; + + StreamRange + ListPrincipalAccessBoundaryPolicies( + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request) + override; + + StreamRange + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + private: + std::shared_ptr child_; +}; + +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +/** + * 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 +MakePrincipalAccessBoundaryPoliciesTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_TRACING_CONNECTION_H diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.cc b/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.cc new file mode 100644 index 0000000000000..5f3501a7b14c1 --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.cc @@ -0,0 +1,236 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.h" +#include "google/cloud/internal/grpc_opentelemetry.h" +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +PrincipalAccessBoundaryPoliciesTracingStub:: + PrincipalAccessBoundaryPoliciesTracingStub( + std::shared_ptr child) + : child_(std::move(child)), propagator_(internal::MakePropagator()) {} + +future> +PrincipalAccessBoundaryPoliciesTracingStub:: + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "CreatePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncCreatePrincipalAccessBoundaryPolicy( + cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingStub::CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "CreatePrincipalAccessBoundaryPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->CreatePrincipalAccessBoundaryPolicy(context, options, request)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingStub::GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "GetPrincipalAccessBoundaryPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->GetPrincipalAccessBoundaryPolicy(context, options, request)); +} + +future> +PrincipalAccessBoundaryPoliciesTracingStub:: + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "UpdatePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncUpdatePrincipalAccessBoundaryPolicy( + cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingStub::UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "UpdatePrincipalAccessBoundaryPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->UpdatePrincipalAccessBoundaryPolicy(context, options, request)); +} + +future> +PrincipalAccessBoundaryPoliciesTracingStub:: + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "DeletePrincipalAccessBoundaryPolicy"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncDeletePrincipalAccessBoundaryPolicy( + cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingStub::DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "DeletePrincipalAccessBoundaryPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->DeletePrincipalAccessBoundaryPolicy(context, options, request)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingStub::ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "ListPrincipalAccessBoundaryPolicies"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, + child_->ListPrincipalAccessBoundaryPolicies(context, options, request)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingStub:: + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.iam.v3.PrincipalAccessBoundaryPolicies", + "SearchPrincipalAccessBoundaryPolicyBindings"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SearchPrincipalAccessBoundaryPolicyBindings( + context, options, request)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesTracingStub::GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.iam.v3.PrincipalAccessBoundaryPolicies", "GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetOperation(context, options, request)); +} + +future> +PrincipalAccessBoundaryPoliciesTracingStub::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 PrincipalAccessBoundaryPoliciesTracingStub::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)); +} + +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +std::shared_ptr +MakePrincipalAccessBoundaryPoliciesTracingStub( + std::shared_ptr stub) { +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + return std::make_shared( + std::move(stub)); +#else + return stub; +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.h b/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.h new file mode 100644 index 0000000000000..24e3a5edfd9ea --- /dev/null +++ b/google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_stub.h @@ -0,0 +1,139 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_TRACING_STUB_H + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub.h" +#include "google/cloud/internal/trace_propagator.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +class PrincipalAccessBoundaryPoliciesTracingStub + : public PrincipalAccessBoundaryPoliciesStub { + public: + ~PrincipalAccessBoundaryPoliciesTracingStub() override = default; + + explicit PrincipalAccessBoundaryPoliciesTracingStub( + std::shared_ptr child); + + future> + AsyncCreatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr CreatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + GetPrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request) + override; + + future> + AsyncUpdatePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr UpdatePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request) override; + + future> + AsyncDeletePrincipalAccessBoundaryPolicy( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr DeletePrincipalAccessBoundaryPolicy( + grpc::ClientContext& context, Options options, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request) override; + + StatusOr + ListPrincipalAccessBoundaryPolicies( + grpc::ClientContext& context, Options const& options, + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest const& + request) override; + + StatusOr + SearchPrincipalAccessBoundaryPolicyBindings( + grpc::ClientContext& context, Options const& options, + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest const& + request) override; + + StatusOr GetOperation( + grpc::ClientContext& context, Options const& options, + google::longrunning::GetOperationRequest 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_; +}; + +#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + +/** + * Applies the tracing decorator to the given stub. + * + * The stub is only decorated if the library has been compiled with + * OpenTelemetry. + */ +std::shared_ptr +MakePrincipalAccessBoundaryPoliciesTracingStub( + std::shared_ptr stub); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_INTERNAL_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_TRACING_STUB_H diff --git a/google/cloud/iam/v3/mocks/mock_policy_bindings_connection.h b/google/cloud/iam/v3/mocks/mock_policy_bindings_connection.h new file mode 100644 index 0000000000000..0b412b3f04727 --- /dev/null +++ b/google/cloud/iam/v3/mocks/mock_policy_bindings_connection.h @@ -0,0 +1,182 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_MOCKS_MOCK_POLICY_BINDINGS_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_MOCKS_MOCK_POLICY_BINDINGS_CONNECTION_H + +#include "google/cloud/iam/v3/policy_bindings_connection.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `PolicyBindingsConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `PolicyBindingsClient`. To do so, + * construct an object of type `PolicyBindingsClient` 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 MockPolicyBindingsConnection : public iam_v3::PolicyBindingsConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreatePolicyBinding(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + CreatePolicyBinding, + (google::iam::v3::CreatePolicyBindingRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, CreatePolicyBinding(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, CreatePolicyBinding, + (NoAwaitTag, + google::iam::v3::CreatePolicyBindingRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreatePolicyBinding(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + CreatePolicyBinding, + (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, GetPolicyBinding, + (google::iam::v3::GetPolicyBindingRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// UpdatePolicyBinding(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + UpdatePolicyBinding, + (google::iam::v3::UpdatePolicyBindingRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, UpdatePolicyBinding(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, UpdatePolicyBinding, + (NoAwaitTag, + google::iam::v3::UpdatePolicyBindingRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// UpdatePolicyBinding(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + UpdatePolicyBinding, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeletePolicyBinding(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeletePolicyBinding, + (google::iam::v3::DeletePolicyBindingRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeletePolicyBinding(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, DeletePolicyBinding, + (NoAwaitTag, + google::iam::v3::DeletePolicyBindingRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeletePolicyBinding(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeletePolicyBinding, + (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListPolicyBindings, + (google::iam::v3::ListPolicyBindingsRequest request), (override)); + + MOCK_METHOD((StreamRange), + SearchTargetPolicyBindings, + (google::iam::v3::SearchTargetPolicyBindingsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_MOCKS_MOCK_POLICY_BINDINGS_CONNECTION_H diff --git a/google/cloud/iam/v3/mocks/mock_principal_access_boundary_policies_connection.h b/google/cloud/iam/v3/mocks/mock_principal_access_boundary_policies_connection.h new file mode 100644 index 0000000000000..46168b1b28f6c --- /dev/null +++ b/google/cloud/iam/v3/mocks/mock_principal_access_boundary_policies_connection.h @@ -0,0 +1,209 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_MOCKS_MOCK_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_MOCKS_MOCK_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_H + +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `PrincipalAccessBoundaryPoliciesConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type + * `PrincipalAccessBoundaryPoliciesClient`. To do so, construct an object of + * type `PrincipalAccessBoundaryPoliciesClient` 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 MockPrincipalAccessBoundaryPoliciesConnection + : public iam_v3::PrincipalAccessBoundaryPoliciesConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreatePrincipalAccessBoundaryPolicy(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + CreatePrincipalAccessBoundaryPolicy, + (google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, CreatePrincipalAccessBoundaryPolicy(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, + CreatePrincipalAccessBoundaryPolicy, + (NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreatePrincipalAccessBoundaryPolicy(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + CreatePrincipalAccessBoundaryPolicy, + (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD( + StatusOr, + GetPrincipalAccessBoundaryPolicy, + (google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// UpdatePrincipalAccessBoundaryPolicy(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + UpdatePrincipalAccessBoundaryPolicy, + (google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, UpdatePrincipalAccessBoundaryPolicy(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, + UpdatePrincipalAccessBoundaryPolicy, + (NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// UpdatePrincipalAccessBoundaryPolicy(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + UpdatePrincipalAccessBoundaryPolicy, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeletePrincipalAccessBoundaryPolicy(Matcher(_))) + /// @endcode + MOCK_METHOD( + future>, + DeletePrincipalAccessBoundaryPolicy, + (google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeletePrincipalAccessBoundaryPolicy(_, _)) + /// @endcode + MOCK_METHOD( + StatusOr, + DeletePrincipalAccessBoundaryPolicy, + (NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeletePrincipalAccessBoundaryPolicy(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeletePrincipalAccessBoundaryPolicy, + (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD( + (StreamRange), + ListPrincipalAccessBoundaryPolicies, + (google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request), + (override)); + + MOCK_METHOD( + (StreamRange), + SearchPrincipalAccessBoundaryPolicyBindings, + (google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + request), + (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_MOCKS_MOCK_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_H diff --git a/google/cloud/iam/v3/policy_bindings_client.cc b/google/cloud/iam/v3/policy_bindings_client.cc new file mode 100644 index 0000000000000..87620c4f4cb52 --- /dev/null +++ b/google/cloud/iam/v3/policy_bindings_client.cc @@ -0,0 +1,232 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/policy_bindings_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PolicyBindingsClient::PolicyBindingsClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +PolicyBindingsClient::~PolicyBindingsClient() = default; + +future> +PolicyBindingsClient::CreatePolicyBinding( + std::string const& parent, + google::iam::v3::PolicyBinding const& policy_binding, + std::string const& policy_binding_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::CreatePolicyBindingRequest request; + request.set_parent(parent); + *request.mutable_policy_binding() = policy_binding; + request.set_policy_binding_id(policy_binding_id); + return connection_->CreatePolicyBinding(request); +} + +StatusOr +PolicyBindingsClient::CreatePolicyBinding( + NoAwaitTag, std::string const& parent, + google::iam::v3::PolicyBinding const& policy_binding, + std::string const& policy_binding_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::CreatePolicyBindingRequest request; + request.set_parent(parent); + *request.mutable_policy_binding() = policy_binding; + request.set_policy_binding_id(policy_binding_id); + return connection_->CreatePolicyBinding(NoAwaitTag{}, request); +} + +future> +PolicyBindingsClient::CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreatePolicyBinding(request); +} + +StatusOr +PolicyBindingsClient::CreatePolicyBinding( + NoAwaitTag, google::iam::v3::CreatePolicyBindingRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreatePolicyBinding(NoAwaitTag{}, request); +} + +future> +PolicyBindingsClient::CreatePolicyBinding( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreatePolicyBinding(operation); +} + +StatusOr PolicyBindingsClient::GetPolicyBinding( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::GetPolicyBindingRequest request; + request.set_name(name); + return connection_->GetPolicyBinding(request); +} + +StatusOr PolicyBindingsClient::GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetPolicyBinding(request); +} + +future> +PolicyBindingsClient::UpdatePolicyBinding( + google::iam::v3::PolicyBinding const& policy_binding, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::UpdatePolicyBindingRequest request; + *request.mutable_policy_binding() = policy_binding; + *request.mutable_update_mask() = update_mask; + return connection_->UpdatePolicyBinding(request); +} + +StatusOr +PolicyBindingsClient::UpdatePolicyBinding( + NoAwaitTag, google::iam::v3::PolicyBinding const& policy_binding, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::UpdatePolicyBindingRequest request; + *request.mutable_policy_binding() = policy_binding; + *request.mutable_update_mask() = update_mask; + return connection_->UpdatePolicyBinding(NoAwaitTag{}, request); +} + +future> +PolicyBindingsClient::UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdatePolicyBinding(request); +} + +StatusOr +PolicyBindingsClient::UpdatePolicyBinding( + NoAwaitTag, google::iam::v3::UpdatePolicyBindingRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdatePolicyBinding(NoAwaitTag{}, request); +} + +future> +PolicyBindingsClient::UpdatePolicyBinding( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdatePolicyBinding(operation); +} + +future> +PolicyBindingsClient::DeletePolicyBinding(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::DeletePolicyBindingRequest request; + request.set_name(name); + return connection_->DeletePolicyBinding(request); +} + +StatusOr +PolicyBindingsClient::DeletePolicyBinding(NoAwaitTag, std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::DeletePolicyBindingRequest request; + request.set_name(name); + return connection_->DeletePolicyBinding(NoAwaitTag{}, request); +} + +future> +PolicyBindingsClient::DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeletePolicyBinding(request); +} + +StatusOr +PolicyBindingsClient::DeletePolicyBinding( + NoAwaitTag, google::iam::v3::DeletePolicyBindingRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeletePolicyBinding(NoAwaitTag{}, request); +} + +future> +PolicyBindingsClient::DeletePolicyBinding( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeletePolicyBinding(operation); +} + +StreamRange +PolicyBindingsClient::ListPolicyBindings(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::ListPolicyBindingsRequest request; + request.set_parent(parent); + return connection_->ListPolicyBindings(request); +} + +StreamRange +PolicyBindingsClient::ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListPolicyBindings(std::move(request)); +} + +StreamRange +PolicyBindingsClient::SearchTargetPolicyBindings(std::string const& parent, + std::string const& target, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::SearchTargetPolicyBindingsRequest request; + request.set_parent(parent); + request.set_target(target); + return connection_->SearchTargetPolicyBindings(request); +} + +StreamRange +PolicyBindingsClient::SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SearchTargetPolicyBindings(std::move(request)); +} + +StatusOr PolicyBindingsClient::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 PolicyBindingsClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/policy_bindings_client.h b/google/cloud/iam/v3/policy_bindings_client.h new file mode 100644 index 0000000000000..d3bad144e06f5 --- /dev/null +++ b/google/cloud/iam/v3/policy_bindings_client.h @@ -0,0 +1,783 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CLIENT_H + +#include "google/cloud/iam/v3/policy_bindings_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 +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// An interface for managing Identity and Access Management (IAM) policy +/// bindings. +/// +/// @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 PolicyBindingsClient { + public: + explicit PolicyBindingsClient( + std::shared_ptr connection, Options opts = {}); + ~PolicyBindingsClient(); + + ///@{ + /// @name Copy and move support + PolicyBindingsClient(PolicyBindingsClient const&) = default; + PolicyBindingsClient& operator=(PolicyBindingsClient const&) = default; + PolicyBindingsClient(PolicyBindingsClient&&) = default; + PolicyBindingsClient& operator=(PolicyBindingsClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(PolicyBindingsClient const& a, + PolicyBindingsClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(PolicyBindingsClient const& a, + PolicyBindingsClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Creates a policy binding and returns a long-running operation. + /// Callers will need the IAM permissions on both the policy and target. + /// Once the binding is created, the policy is applied to the target. + /// + /// @param parent Required. The parent resource where this policy binding will be created. + /// The binding parent is the closest Resource Manager resource (Project, + /// Folder or Organization) to the binding target. + /// @n + /// Format: + /// @n + /// * `projects/{project_id}/locations/{location}` + /// * `projects/{project_number}/locations/{location}` + /// * `folders/{folder_id}/locations/{location}` + /// * `organizations/{organization_id}/locations/{location}` + /// @param policy_binding Required. The policy binding to create. + /// @param policy_binding_id Required. The ID to use for the policy binding, which will become the final + /// component of the policy binding's resource name. + /// @n + /// This value must start with a lowercase letter followed by up to 62 + /// lowercase letters, numbers, hyphens, or dots. Pattern, + /// /[a-z][a-z0-9-\.]{2,62}/. + /// @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.iam.v3.PolicyBinding] 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.iam.v3.CreatePolicyBindingRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L169} + /// [google.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// + // clang-format on + future> CreatePolicyBinding( + std::string const& parent, + google::iam::v3::PolicyBinding const& policy_binding, + std::string const& policy_binding_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief CreatePolicyBinding + /// + /// 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 CreatePolicyBinding( + NoAwaitTag, std::string const& parent, + google::iam::v3::PolicyBinding const& policy_binding, + std::string const& policy_binding_id, Options opts = {}); + + // clang-format off + /// + /// Creates a policy binding and returns a long-running operation. + /// Callers will need the IAM permissions on both the policy and target. + /// Once the binding is created, the policy is applied to the target. + /// + /// @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.iam.v3.CreatePolicyBindingRequest]. + /// 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.iam.v3.PolicyBinding] 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.iam.v3.CreatePolicyBindingRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L169} + /// [google.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// + // clang-format on + future> CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreatePolicyBinding + /// + /// 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 CreatePolicyBinding( + NoAwaitTag, google::iam::v3::CreatePolicyBindingRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreatePolicyBinding + /// + /// 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> CreatePolicyBinding( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Gets a policy binding. + /// + /// @param name Required. The name of the policy binding to retrieve. + /// @n + /// Format: + /// @n + /// * `projects/{project_id}/locations/{location}/policyBindings/{policy_binding_id}` + /// * `projects/{project_number}/locations/{location}/policyBindings/{policy_binding_id}` + /// * `folders/{folder_id}/locations/{location}/policyBindings/{policy_binding_id}` + /// * `organizations/{organization_id}/locations/{location}/policyBindings/{policy_binding_id}` + /// @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.iam.v3.PolicyBinding]) + /// 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.iam.v3.GetPolicyBindingRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L204} + /// [google.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// + // clang-format on + StatusOr GetPolicyBinding( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets a policy binding. + /// + /// @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.iam.v3.GetPolicyBindingRequest]. + /// 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.iam.v3.PolicyBinding]) + /// 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.iam.v3.GetPolicyBindingRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L204} + /// [google.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// + // clang-format on + StatusOr GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates a policy binding and returns a long-running operation. + /// Callers will need the IAM permissions on the policy and target in the + /// binding to update, and the IAM permission to remove the existing policy + /// from the binding. Target is immutable and cannot be updated. Once the + /// binding is updated, the new policy is applied to the target. + /// + /// @param policy_binding Required. The policy binding to update. + /// @n + /// The policy binding's `name` field is used to identify the policy binding to + /// update. + /// @param update_mask Optional. The list of fields to update + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return 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.iam.v3.PolicyBinding] 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.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// [google.iam.v3.UpdatePolicyBindingRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L222} + /// + // clang-format on + future> UpdatePolicyBinding( + google::iam::v3::PolicyBinding const& policy_binding, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdatePolicyBinding + /// + /// 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 UpdatePolicyBinding( + NoAwaitTag, google::iam::v3::PolicyBinding const& policy_binding, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates a policy binding and returns a long-running operation. + /// Callers will need the IAM permissions on the policy and target in the + /// binding to update, and the IAM permission to remove the existing policy + /// from the binding. Target is immutable and cannot be updated. Once the + /// binding is updated, the new policy is applied to the target. + /// + /// @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.iam.v3.UpdatePolicyBindingRequest]. + /// 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.iam.v3.PolicyBinding] 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.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// [google.iam.v3.UpdatePolicyBindingRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L222} + /// + // clang-format on + future> UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdatePolicyBinding + /// + /// 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 UpdatePolicyBinding( + NoAwaitTag, google::iam::v3::UpdatePolicyBindingRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdatePolicyBinding + /// + /// 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> UpdatePolicyBinding( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Deletes a policy binding and returns a long-running operation. + /// Callers will need the IAM permissions on both the policy and target. + /// Once the binding is deleted, the policy no longer applies to the target. + /// + /// @param name Required. The name of the policy binding to delete. + /// @n + /// Format: + /// @n + /// * `projects/{project_id}/locations/{location}/policyBindings/{policy_binding_id}` + /// * `projects/{project_number}/locations/{location}/policyBindings/{policy_binding_id}` + /// * `folders/{folder_id}/locations/{location}/policyBindings/{policy_binding_id}` + /// * `organizations/{organization_id}/locations/{location}/policyBindings/{policy_binding_id}` + /// @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.iam.v3.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.iam.v3.DeletePolicyBindingRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L239} + /// [google.iam.v3.OperationMetadata]: @googleapis_reference_link{google/iam/v3/operation_metadata.proto#L29} + /// + // clang-format on + future> DeletePolicyBinding( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief DeletePolicyBinding + /// + /// 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 DeletePolicyBinding( + NoAwaitTag, std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a policy binding and returns a long-running operation. + /// Callers will need the IAM permissions on both the policy and target. + /// Once the binding is deleted, the policy no longer applies to the target. + /// + /// @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.iam.v3.DeletePolicyBindingRequest]. + /// 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.iam.v3.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.iam.v3.DeletePolicyBindingRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L239} + /// [google.iam.v3.OperationMetadata]: @googleapis_reference_link{google/iam/v3/operation_metadata.proto#L29} + /// + // clang-format on + future> DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeletePolicyBinding + /// + /// 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 DeletePolicyBinding( + NoAwaitTag, google::iam::v3::DeletePolicyBindingRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeletePolicyBinding + /// + /// 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> DeletePolicyBinding( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Lists policy bindings. + /// + /// @param parent Required. The parent resource, which owns the collection of policy + /// bindings. + /// @n + /// Format: + /// @n + /// * `projects/{project_id}/locations/{location}` + /// * `projects/{project_number}/locations/{location}` + /// * `folders/{folder_id}/locations/{location}` + /// * `organizations/{organization_id}/locations/{location}` + /// @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.iam.v3.PolicyBinding], 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.iam.v3.ListPolicyBindingsRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L265} + /// [google.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// + // clang-format on + StreamRange ListPolicyBindings( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists policy bindings. + /// + /// @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.iam.v3.ListPolicyBindingsRequest]. + /// 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.iam.v3.PolicyBinding], 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.iam.v3.ListPolicyBindingsRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L265} + /// [google.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// + // clang-format on + StreamRange ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest request, Options opts = {}); + + // clang-format off + /// + /// Search policy bindings by target. Returns all policy binding objects bound + /// directly to target. + /// + /// @param parent Required. The parent resource where this search will be performed. This + /// should be the nearest Resource Manager resource (project, folder, or + /// organization) to the target. + /// @n + /// Format: + /// @n + /// * `projects/{project_id}/locations/{location}` + /// * `projects/{project_number}/locations/{location}` + /// * `folders/{folder_id}/locations/{location}` + /// * `organizations/{organization_id}/locations/{location}` + /// @param target Required. The target resource, which is bound to the policy in the binding. + /// @n + /// Format: + /// @n + /// * `//iam.googleapis.com/locations/global/workforcePools/POOL_ID` + /// * `//iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID` + /// * `//iam.googleapis.com/locations/global/workspace/WORKSPACE_ID` + /// * `//cloudresourcemanager.googleapis.com/projects/{project_number}` + /// * `//cloudresourcemanager.googleapis.com/folders/{folder_id}` + /// * `//cloudresourcemanager.googleapis.com/organizations/{organization_id}` + /// @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.iam.v3.PolicyBinding], 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.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// [google.iam.v3.SearchTargetPolicyBindingsRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L323} + /// + // clang-format on + StreamRange SearchTargetPolicyBindings( + std::string const& parent, std::string const& target, Options opts = {}); + + // clang-format off + /// + /// Search policy bindings by target. Returns all policy binding objects bound + /// directly to target. + /// + /// @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.iam.v3.SearchTargetPolicyBindingsRequest]. + /// 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.iam.v3.PolicyBinding], 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.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// [google.iam.v3.SearchTargetPolicyBindingsRequest]: @googleapis_reference_link{google/iam/v3/policy_bindings_service.proto#L323} + /// + // clang-format on + StreamRange SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest 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 = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CLIENT_H diff --git a/google/cloud/iam/v3/policy_bindings_connection.cc b/google/cloud/iam/v3/policy_bindings_connection.cc new file mode 100644 index 0000000000000..7be6a77e85365 --- /dev/null +++ b/google/cloud/iam/v3/policy_bindings_connection.cc @@ -0,0 +1,156 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/policy_bindings_connection.h" +#include "google/cloud/iam/v3/internal/policy_bindings_connection_impl.h" +#include "google/cloud/iam/v3/internal/policy_bindings_option_defaults.h" +#include "google/cloud/iam/v3/internal/policy_bindings_stub_factory.h" +#include "google/cloud/iam/v3/internal/policy_bindings_tracing_connection.h" +#include "google/cloud/iam/v3/policy_bindings_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 iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PolicyBindingsConnection::~PolicyBindingsConnection() = default; + +future> +PolicyBindingsConnection::CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +PolicyBindingsConnection::CreatePolicyBinding( + NoAwaitTag, google::iam::v3::CreatePolicyBindingRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +PolicyBindingsConnection::CreatePolicyBinding( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +PolicyBindingsConnection::GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +PolicyBindingsConnection::UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +PolicyBindingsConnection::UpdatePolicyBinding( + NoAwaitTag, google::iam::v3::UpdatePolicyBindingRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +PolicyBindingsConnection::UpdatePolicyBinding( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +PolicyBindingsConnection::DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +PolicyBindingsConnection::DeletePolicyBinding( + NoAwaitTag, google::iam::v3::DeletePolicyBindingRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +PolicyBindingsConnection::DeletePolicyBinding( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +PolicyBindingsConnection::ListPolicyBindings( + google::iam::v3:: + ListPolicyBindingsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StreamRange +PolicyBindingsConnection::SearchTargetPolicyBindings( + google::iam::v3:: + SearchTargetPolicyBindingsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr PolicyBindingsConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr MakePolicyBindingsConnection( + Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = iam_v3_internal::PolicyBindingsDefaultOptions(std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = iam_v3_internal::CreateDefaultPolicyBindingsStub(std::move(auth), + options); + return iam_v3_internal::MakePolicyBindingsTracingConnection( + std::make_shared( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/policy_bindings_connection.h b/google/cloud/iam/v3/policy_bindings_connection.h new file mode 100644 index 0000000000000..6d453c83287bf --- /dev/null +++ b/google/cloud/iam/v3/policy_bindings_connection.h @@ -0,0 +1,260 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CONNECTION_H + +#include "google/cloud/iam/v3/internal/policy_bindings_retry_traits.h" +#include "google/cloud/iam/v3/policy_bindings_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 +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `PolicyBindingsConnection`. +class PolicyBindingsRetryPolicy : 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 `PolicyBindingsConnection` 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 PolicyBindingsLimitedErrorCountRetryPolicy + : public PolicyBindingsRetryPolicy { + 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 PolicyBindingsLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + PolicyBindingsLimitedErrorCountRetryPolicy( + PolicyBindingsLimitedErrorCountRetryPolicy&& rhs) noexcept + : PolicyBindingsLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + PolicyBindingsLimitedErrorCountRetryPolicy( + PolicyBindingsLimitedErrorCountRetryPolicy const& rhs) noexcept + : PolicyBindingsLimitedErrorCountRetryPolicy(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 = PolicyBindingsRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + iam_v3_internal::PolicyBindingsRetryTraits> + impl_; +}; + +/** + * A retry policy for `PolicyBindingsConnection` 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 PolicyBindingsLimitedTimeRetryPolicy : public PolicyBindingsRetryPolicy { + 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 PolicyBindingsLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + PolicyBindingsLimitedTimeRetryPolicy( + PolicyBindingsLimitedTimeRetryPolicy&& rhs) noexcept + : PolicyBindingsLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + PolicyBindingsLimitedTimeRetryPolicy( + PolicyBindingsLimitedTimeRetryPolicy const& rhs) noexcept + : PolicyBindingsLimitedTimeRetryPolicy(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 = PolicyBindingsRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + iam_v3_internal::PolicyBindingsRetryTraits> + impl_; +}; + +/** + * The `PolicyBindingsConnection` object for `PolicyBindingsClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `PolicyBindingsClient`. This allows users to inject custom behavior + * (e.g., with a Google Mock object) when writing tests that use objects of type + * `PolicyBindingsClient`. + * + * To create a concrete instance, see `MakePolicyBindingsConnection()`. + * + * For mocking, see `iam_v3_mocks::MockPolicyBindingsConnection`. + */ +class PolicyBindingsConnection { + public: + virtual ~PolicyBindingsConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual future> CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const& request); + + virtual StatusOr CreatePolicyBinding( + NoAwaitTag, google::iam::v3::CreatePolicyBindingRequest const& request); + + virtual future> CreatePolicyBinding( + google::longrunning::Operation const& operation); + + virtual StatusOr GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const& request); + + virtual future> UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const& request); + + virtual StatusOr UpdatePolicyBinding( + NoAwaitTag, google::iam::v3::UpdatePolicyBindingRequest const& request); + + virtual future> UpdatePolicyBinding( + google::longrunning::Operation const& operation); + + virtual future> + DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const& request); + + virtual StatusOr DeletePolicyBinding( + NoAwaitTag, google::iam::v3::DeletePolicyBindingRequest const& request); + + virtual future> + DeletePolicyBinding(google::longrunning::Operation const& operation); + + virtual StreamRange ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest request); + + virtual StreamRange + SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); +}; + +/** + * A factory function to construct an object of type `PolicyBindingsConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of PolicyBindingsClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `PolicyBindingsConnection`. Expected options are any of the types in + * the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::iam_v3::PolicyBindingsPolicyOptionList` + * + * @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 `PolicyBindingsConnection` created by + * this function. + */ +std::shared_ptr MakePolicyBindingsConnection( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CONNECTION_H diff --git a/google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.cc b/google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..b7a6a1eb79468 --- /dev/null +++ b/google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.cc @@ -0,0 +1,81 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +PolicyBindingsConnectionIdempotencyPolicy:: + ~PolicyBindingsConnectionIdempotencyPolicy() = default; + +std::unique_ptr +PolicyBindingsConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency PolicyBindingsConnectionIdempotencyPolicy::CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PolicyBindingsConnectionIdempotencyPolicy::GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PolicyBindingsConnectionIdempotencyPolicy::UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PolicyBindingsConnectionIdempotencyPolicy::DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PolicyBindingsConnectionIdempotencyPolicy::ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +PolicyBindingsConnectionIdempotencyPolicy::SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PolicyBindingsConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +std::unique_ptr +MakeDefaultPolicyBindingsConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.h b/google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.h new file mode 100644 index 0000000000000..8de979d27948d --- /dev/null +++ b/google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.h @@ -0,0 +1,71 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PolicyBindingsConnectionIdempotencyPolicy { + public: + virtual ~PolicyBindingsConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() + const; + + virtual google::cloud::Idempotency CreatePolicyBinding( + google::iam::v3::CreatePolicyBindingRequest const& request); + + virtual google::cloud::Idempotency GetPolicyBinding( + google::iam::v3::GetPolicyBindingRequest const& request); + + virtual google::cloud::Idempotency UpdatePolicyBinding( + google::iam::v3::UpdatePolicyBindingRequest const& request); + + virtual google::cloud::Idempotency DeletePolicyBinding( + google::iam::v3::DeletePolicyBindingRequest const& request); + + virtual google::cloud::Idempotency ListPolicyBindings( + google::iam::v3::ListPolicyBindingsRequest request); + + virtual google::cloud::Idempotency SearchTargetPolicyBindings( + google::iam::v3::SearchTargetPolicyBindingsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); +}; + +std::unique_ptr +MakeDefaultPolicyBindingsConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/iam/v3/policy_bindings_options.h b/google/cloud/iam/v3/policy_bindings_options.h new file mode 100644 index 0000000000000..f7b502faeb269 --- /dev/null +++ b/google/cloud/iam/v3/policy_bindings_options.h @@ -0,0 +1,87 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_OPTIONS_H + +#include "google/cloud/iam/v3/policy_bindings_connection.h" +#include "google/cloud/iam/v3/policy_bindings_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 iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-iam-options + */ +struct PolicyBindingsRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-iam-options + */ +struct PolicyBindingsBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-iam-options + */ +struct PolicyBindingsConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the long-running operations + * polling policy. + * + * @ingroup google-cloud-iam-options + */ +struct PolicyBindingsPollingPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to PolicyBindings. + * + * @ingroup google-cloud-iam-options + */ +using PolicyBindingsPolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_POLICY_BINDINGS_OPTIONS_H diff --git a/google/cloud/iam/v3/principal_access_boundary_policies_client.cc b/google/cloud/iam/v3/principal_access_boundary_policies_client.cc new file mode 100644 index 0000000000000..60aa6b7c310db --- /dev/null +++ b/google/cloud/iam/v3/principal_access_boundary_policies_client.cc @@ -0,0 +1,266 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/principal_access_boundary_policies_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PrincipalAccessBoundaryPoliciesClient::PrincipalAccessBoundaryPoliciesClient( + std::shared_ptr connection, + Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +PrincipalAccessBoundaryPoliciesClient:: + ~PrincipalAccessBoundaryPoliciesClient() = default; + +future> +PrincipalAccessBoundaryPoliciesClient::CreatePrincipalAccessBoundaryPolicy( + std::string const& parent, + google::iam::v3::PrincipalAccessBoundaryPolicy const& + principal_access_boundary_policy, + std::string const& principal_access_boundary_policy_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest request; + request.set_parent(parent); + *request.mutable_principal_access_boundary_policy() = + principal_access_boundary_policy; + request.set_principal_access_boundary_policy_id( + principal_access_boundary_policy_id); + return connection_->CreatePrincipalAccessBoundaryPolicy(request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, std::string const& parent, + google::iam::v3::PrincipalAccessBoundaryPolicy const& + principal_access_boundary_policy, + std::string const& principal_access_boundary_policy_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest request; + request.set_parent(parent); + *request.mutable_principal_access_boundary_policy() = + principal_access_boundary_policy; + request.set_principal_access_boundary_policy_id( + principal_access_boundary_policy_id); + return connection_->CreatePrincipalAccessBoundaryPolicy(NoAwaitTag{}, + request); +} + +future> +PrincipalAccessBoundaryPoliciesClient::CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreatePrincipalAccessBoundaryPolicy(request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreatePrincipalAccessBoundaryPolicy(NoAwaitTag{}, + request); +} + +future> +PrincipalAccessBoundaryPoliciesClient::CreatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreatePrincipalAccessBoundaryPolicy(operation); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::GetPrincipalAccessBoundaryPolicy( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest request; + request.set_name(name); + return connection_->GetPrincipalAccessBoundaryPolicy(request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetPrincipalAccessBoundaryPolicy(request); +} + +future> +PrincipalAccessBoundaryPoliciesClient::UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::PrincipalAccessBoundaryPolicy const& + principal_access_boundary_policy, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest request; + *request.mutable_principal_access_boundary_policy() = + principal_access_boundary_policy; + *request.mutable_update_mask() = update_mask; + return connection_->UpdatePrincipalAccessBoundaryPolicy(request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::PrincipalAccessBoundaryPolicy const& + principal_access_boundary_policy, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest request; + *request.mutable_principal_access_boundary_policy() = + principal_access_boundary_policy; + *request.mutable_update_mask() = update_mask; + return connection_->UpdatePrincipalAccessBoundaryPolicy(NoAwaitTag{}, + request); +} + +future> +PrincipalAccessBoundaryPoliciesClient::UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdatePrincipalAccessBoundaryPolicy(request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdatePrincipalAccessBoundaryPolicy(NoAwaitTag{}, + request); +} + +future> +PrincipalAccessBoundaryPoliciesClient::UpdatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdatePrincipalAccessBoundaryPolicy(operation); +} + +future> +PrincipalAccessBoundaryPoliciesClient::DeletePrincipalAccessBoundaryPolicy( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest request; + request.set_name(name); + return connection_->DeletePrincipalAccessBoundaryPolicy(request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest request; + request.set_name(name); + return connection_->DeletePrincipalAccessBoundaryPolicy(NoAwaitTag{}, + request); +} + +future> +PrincipalAccessBoundaryPoliciesClient::DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeletePrincipalAccessBoundaryPolicy(request); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeletePrincipalAccessBoundaryPolicy(NoAwaitTag{}, + request); +} + +future> +PrincipalAccessBoundaryPoliciesClient::DeletePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeletePrincipalAccessBoundaryPolicy(operation); +} + +StreamRange +PrincipalAccessBoundaryPoliciesClient::ListPrincipalAccessBoundaryPolicies( + std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request; + request.set_parent(parent); + return connection_->ListPrincipalAccessBoundaryPolicies(request); +} + +StreamRange +PrincipalAccessBoundaryPoliciesClient::ListPrincipalAccessBoundaryPolicies( + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListPrincipalAccessBoundaryPolicies(std::move(request)); +} + +StreamRange +PrincipalAccessBoundaryPoliciesClient:: + SearchPrincipalAccessBoundaryPolicyBindings(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest request; + request.set_name(name); + return connection_->SearchPrincipalAccessBoundaryPolicyBindings(request); +} + +StreamRange +PrincipalAccessBoundaryPoliciesClient:: + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SearchPrincipalAccessBoundaryPolicyBindings( + std::move(request)); +} + +StatusOr +PrincipalAccessBoundaryPoliciesClient::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 +PrincipalAccessBoundaryPoliciesClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/principal_access_boundary_policies_client.h b/google/cloud/iam/v3/principal_access_boundary_policies_client.h new file mode 100644 index 0000000000000..3ce33870d636f --- /dev/null +++ b/google/cloud/iam/v3/principal_access_boundary_policies_client.h @@ -0,0 +1,773 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CLIENT_H + +#include "google/cloud/iam/v3/principal_access_boundary_policies_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 +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Manages Identity and Access Management (IAM) principal access boundary +/// policies. +/// +/// @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 PrincipalAccessBoundaryPoliciesClient { + public: + explicit PrincipalAccessBoundaryPoliciesClient( + std::shared_ptr connection, + Options opts = {}); + ~PrincipalAccessBoundaryPoliciesClient(); + + ///@{ + /// @name Copy and move support + PrincipalAccessBoundaryPoliciesClient( + PrincipalAccessBoundaryPoliciesClient const&) = default; + PrincipalAccessBoundaryPoliciesClient& operator=( + PrincipalAccessBoundaryPoliciesClient const&) = default; + PrincipalAccessBoundaryPoliciesClient( + PrincipalAccessBoundaryPoliciesClient&&) = default; + PrincipalAccessBoundaryPoliciesClient& operator=( + PrincipalAccessBoundaryPoliciesClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(PrincipalAccessBoundaryPoliciesClient const& a, + PrincipalAccessBoundaryPoliciesClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(PrincipalAccessBoundaryPoliciesClient const& a, + PrincipalAccessBoundaryPoliciesClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Creates a principal access boundary policy, and returns a long running + /// operation. + /// + /// @param parent Required. The parent resource where this principal access boundary policy + /// will be created. Only organization is supported now. + /// @n + /// Format: + /// `organizations/{organization_id}/locations/{location}` + /// @param principal_access_boundary_policy Required. The principal access boundary policy to create. + /// @param principal_access_boundary_policy_id Required. The ID to use for the principal access boundary policy, which + /// will become the final component of the principal access boundary policy's + /// resource name. + /// @n + /// This value must start with a lowercase letter followed by up to 62 + /// lowercase letters, numbers, hyphens, or dots. Pattern, + /// /[a-z][a-z0-9-\.]{2,62}/. + /// @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.iam.v3.PrincipalAccessBoundaryPolicy] 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.iam.v3.CreatePrincipalAccessBoundaryPolicyRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L122} + /// [google.iam.v3.PrincipalAccessBoundaryPolicy]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policy_resources.proto#L31} + /// + // clang-format on + future> + CreatePrincipalAccessBoundaryPolicy( + std::string const& parent, + google::iam::v3::PrincipalAccessBoundaryPolicy const& + principal_access_boundary_policy, + std::string const& principal_access_boundary_policy_id, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreatePrincipalAccessBoundaryPolicy + /// + /// 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 CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, std::string const& parent, + google::iam::v3::PrincipalAccessBoundaryPolicy const& + principal_access_boundary_policy, + std::string const& principal_access_boundary_policy_id, + Options opts = {}); + + // clang-format off + /// + /// Creates a principal access boundary policy, and returns a long running + /// operation. + /// + /// @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.iam.v3.CreatePrincipalAccessBoundaryPolicyRequest]. + /// 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.iam.v3.PrincipalAccessBoundaryPolicy] 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.iam.v3.CreatePrincipalAccessBoundaryPolicyRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L122} + /// [google.iam.v3.PrincipalAccessBoundaryPolicy]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policy_resources.proto#L31} + /// + // clang-format on + future> + CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreatePrincipalAccessBoundaryPolicy + /// + /// 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 CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreatePrincipalAccessBoundaryPolicy + /// + /// 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> + CreatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Gets a principal access boundary policy. + /// + /// @param name Required. The name of the principal access boundary policy to retrieve. + /// @n + /// Format: + /// `organizations/{organization_id}/locations/{location}/principalAccessBoundaryPolicies/{principal_access_boundary_policy_id}` + /// @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.iam.v3.PrincipalAccessBoundaryPolicy]) + /// 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.iam.v3.GetPrincipalAccessBoundaryPolicyRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L155} + /// [google.iam.v3.PrincipalAccessBoundaryPolicy]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policy_resources.proto#L31} + /// + // clang-format on + StatusOr + GetPrincipalAccessBoundaryPolicy(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Gets a principal access boundary policy. + /// + /// @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.iam.v3.GetPrincipalAccessBoundaryPolicyRequest]. + /// 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.iam.v3.PrincipalAccessBoundaryPolicy]) + /// 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.iam.v3.GetPrincipalAccessBoundaryPolicyRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L155} + /// [google.iam.v3.PrincipalAccessBoundaryPolicy]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policy_resources.proto#L31} + /// + // clang-format on + StatusOr + GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Updates a principal access boundary policy. + /// + /// @param principal_access_boundary_policy Required. The principal access boundary policy to update. + /// @n + /// The principal access boundary policy's `name` field is used to identify the + /// policy to update. + /// @param update_mask Optional. The list of fields to update + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return 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.iam.v3.PrincipalAccessBoundaryPolicy] 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.iam.v3.PrincipalAccessBoundaryPolicy]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policy_resources.proto#L31} + /// [google.iam.v3.UpdatePrincipalAccessBoundaryPolicyRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L169} + /// + // clang-format on + future> + UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::PrincipalAccessBoundaryPolicy const& + principal_access_boundary_policy, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdatePrincipalAccessBoundaryPolicy + /// + /// 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 UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::PrincipalAccessBoundaryPolicy const& + principal_access_boundary_policy, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates a principal access boundary policy. + /// + /// @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.iam.v3.UpdatePrincipalAccessBoundaryPolicyRequest]. + /// 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.iam.v3.PrincipalAccessBoundaryPolicy] 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.iam.v3.PrincipalAccessBoundaryPolicy]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policy_resources.proto#L31} + /// [google.iam.v3.UpdatePrincipalAccessBoundaryPolicyRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L169} + /// + // clang-format on + future> + UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdatePrincipalAccessBoundaryPolicy + /// + /// 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 UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdatePrincipalAccessBoundaryPolicy + /// + /// 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> + UpdatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Deletes a principal access boundary policy. + /// + /// @param name Required. The name of the principal access boundary policy to delete. + /// @n + /// Format: + /// `organizations/{organization_id}/locations/{location}/principalAccessBoundaryPolicies/{principal_access_boundary_policy_id}` + /// @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.iam.v3.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.iam.v3.DeletePrincipalAccessBoundaryPolicyRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L187} + /// [google.iam.v3.OperationMetadata]: @googleapis_reference_link{google/iam/v3/operation_metadata.proto#L29} + /// + // clang-format on + future> + DeletePrincipalAccessBoundaryPolicy(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeletePrincipalAccessBoundaryPolicy + /// + /// 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 DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a principal access boundary policy. + /// + /// @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.iam.v3.DeletePrincipalAccessBoundaryPolicyRequest]. + /// 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.iam.v3.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.iam.v3.DeletePrincipalAccessBoundaryPolicyRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L187} + /// [google.iam.v3.OperationMetadata]: @googleapis_reference_link{google/iam/v3/operation_metadata.proto#L29} + /// + // clang-format on + future> + DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeletePrincipalAccessBoundaryPolicy + /// + /// 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 DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeletePrincipalAccessBoundaryPolicy + /// + /// 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> + DeletePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Lists principal access boundary policies. + /// + /// @param parent Required. The parent resource, which owns the collection of principal + /// access boundary policies. + /// @n + /// Format: + /// `organizations/{organization_id}/locations/{location}` + /// @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.iam.v3.PrincipalAccessBoundaryPolicy], 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.iam.v3.ListPrincipalAccessBoundaryPoliciesRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L213} + /// [google.iam.v3.PrincipalAccessBoundaryPolicy]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policy_resources.proto#L31} + /// + // clang-format on + StreamRange + ListPrincipalAccessBoundaryPolicies(std::string const& parent, + Options opts = {}); + + // clang-format off + /// + /// Lists principal access boundary policies. + /// + /// @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.iam.v3.ListPrincipalAccessBoundaryPoliciesRequest]. + /// 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.iam.v3.PrincipalAccessBoundaryPolicy], 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.iam.v3.ListPrincipalAccessBoundaryPoliciesRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L213} + /// [google.iam.v3.PrincipalAccessBoundaryPolicy]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policy_resources.proto#L31} + /// + // clang-format on + StreamRange + ListPrincipalAccessBoundaryPolicies( + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request, + Options opts = {}); + + // clang-format off + /// + /// Returns all policy bindings that bind a specific policy if a user has + /// searchPolicyBindings permission on that policy. + /// + /// @param name Required. The name of the principal access boundary policy. + /// Format: + /// `organizations/{organization_id}/locations/{location}/principalAccessBoundaryPolicies/{principal_access_boundary_policy_id}` + /// @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.iam.v3.PolicyBinding], 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.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// [google.iam.v3.SearchPrincipalAccessBoundaryPolicyBindingsRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L254} + /// + // clang-format on + StreamRange + SearchPrincipalAccessBoundaryPolicyBindings(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Returns all policy bindings that bind a specific policy if a user has + /// searchPolicyBindings permission on that policy. + /// + /// @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.iam.v3.SearchPrincipalAccessBoundaryPolicyBindingsRequest]. + /// 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.iam.v3.PolicyBinding], 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.iam.v3.PolicyBinding]: @googleapis_reference_link{google/iam/v3/policy_binding_resources.proto#L32} + /// [google.iam.v3.SearchPrincipalAccessBoundaryPolicyBindingsRequest]: @googleapis_reference_link{google/iam/v3/principal_access_boundary_policies_service.proto#L254} + /// + // clang-format on + StreamRange + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + 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 = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CLIENT_H diff --git a/google/cloud/iam/v3/principal_access_boundary_policies_connection.cc b/google/cloud/iam/v3/principal_access_boundary_policies_connection.cc new file mode 100644 index 0000000000000..7ad010af44ea4 --- /dev/null +++ b/google/cloud/iam/v3/principal_access_boundary_policies_connection.cc @@ -0,0 +1,163 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_connection_impl.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_option_defaults.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_stub_factory.h" +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_tracing_connection.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_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 iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +PrincipalAccessBoundaryPoliciesConnection:: + ~PrincipalAccessBoundaryPoliciesConnection() = default; + +future> +PrincipalAccessBoundaryPoliciesConnection::CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnection::CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +PrincipalAccessBoundaryPoliciesConnection::CreatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnection::GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +PrincipalAccessBoundaryPoliciesConnection::UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnection::UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +PrincipalAccessBoundaryPoliciesConnection::UpdatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +PrincipalAccessBoundaryPoliciesConnection::DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnection::DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +PrincipalAccessBoundaryPoliciesConnection::DeletePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +PrincipalAccessBoundaryPoliciesConnection::ListPrincipalAccessBoundaryPolicies( + google::iam::v3:: + ListPrincipalAccessBoundaryPoliciesRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StreamRange +PrincipalAccessBoundaryPoliciesConnection:: + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PrincipalAccessBoundaryPoliciesConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr +MakePrincipalAccessBoundaryPoliciesConnection(Options options) { + internal::CheckExpectedOptions< + CommonOptionList, GrpcOptionList, UnifiedCredentialsOptionList, + PrincipalAccessBoundaryPoliciesPolicyOptionList>(options, __func__); + options = iam_v3_internal::PrincipalAccessBoundaryPoliciesDefaultOptions( + std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto auth = internal::CreateAuthenticationStrategy(background->cq(), options); + auto stub = iam_v3_internal::CreateDefaultPrincipalAccessBoundaryPoliciesStub( + std::move(auth), options); + return iam_v3_internal::MakePrincipalAccessBoundaryPoliciesTracingConnection( + std::make_shared< + iam_v3_internal::PrincipalAccessBoundaryPoliciesConnectionImpl>( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/principal_access_boundary_policies_connection.h b/google/cloud/iam/v3/principal_access_boundary_policies_connection.h new file mode 100644 index 0000000000000..035298c08ee25 --- /dev/null +++ b/google/cloud/iam/v3/principal_access_boundary_policies_connection.h @@ -0,0 +1,301 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_H + +#include "google/cloud/iam/v3/internal/principal_access_boundary_policies_retry_traits.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_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 +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `PrincipalAccessBoundaryPoliciesConnection`. +class PrincipalAccessBoundaryPoliciesRetryPolicy + : 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 `PrincipalAccessBoundaryPoliciesConnection` 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 PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy + : public PrincipalAccessBoundaryPoliciesRetryPolicy { + 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 PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy( + int maximum_failures) + : impl_(maximum_failures) {} + + PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy( + PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy&& + rhs) noexcept + : PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy( + rhs.maximum_failures()) {} + PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy( + PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy const& + rhs) noexcept + : PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy( + 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< + PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy>( + maximum_failures()); + } + + // This is provided only for backwards compatibility. + using BaseType = PrincipalAccessBoundaryPoliciesRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + iam_v3_internal::PrincipalAccessBoundaryPoliciesRetryTraits> + impl_; +}; + +/** + * A retry policy for `PrincipalAccessBoundaryPoliciesConnection` 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 PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy + : public PrincipalAccessBoundaryPoliciesRetryPolicy { + 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 PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy( + PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy&& rhs) noexcept + : PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy( + rhs.maximum_duration()) {} + PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy( + PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy const& rhs) noexcept + : PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy( + 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< + PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy>( + maximum_duration()); + } + + // This is provided only for backwards compatibility. + using BaseType = PrincipalAccessBoundaryPoliciesRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + iam_v3_internal::PrincipalAccessBoundaryPoliciesRetryTraits> + impl_; +}; + +/** + * The `PrincipalAccessBoundaryPoliciesConnection` object for + * `PrincipalAccessBoundaryPoliciesClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `PrincipalAccessBoundaryPoliciesClient`. This allows users to inject + * custom behavior (e.g., with a Google Mock object) when writing tests that use + * objects of type `PrincipalAccessBoundaryPoliciesClient`. + * + * To create a concrete instance, see + * `MakePrincipalAccessBoundaryPoliciesConnection()`. + * + * For mocking, see + * `iam_v3_mocks::MockPrincipalAccessBoundaryPoliciesConnection`. + */ +class PrincipalAccessBoundaryPoliciesConnection { + public: + virtual ~PrincipalAccessBoundaryPoliciesConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual future> + CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual StatusOr + CreatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual future> + CreatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation); + + virtual StatusOr + GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request); + + virtual future> + UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual StatusOr + UpdatePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual future> + UpdatePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation); + + virtual future> + DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual StatusOr + DeletePrincipalAccessBoundaryPolicy( + NoAwaitTag, + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual future> + DeletePrincipalAccessBoundaryPolicy( + google::longrunning::Operation const& operation); + + virtual StreamRange + ListPrincipalAccessBoundaryPolicies( + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request); + + virtual StreamRange + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); +}; + +/** + * A factory function to construct an object of type + * `PrincipalAccessBoundaryPoliciesConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of + * PrincipalAccessBoundaryPoliciesClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `PrincipalAccessBoundaryPoliciesConnection`. Expected options are + * any of the types in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesPolicyOptionList` + * + * @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 + * `PrincipalAccessBoundaryPoliciesConnection` created by this function. + */ +std::shared_ptr +MakePrincipalAccessBoundaryPoliciesConnection(Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_H diff --git a/google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.cc b/google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..87c7fb62f846e --- /dev/null +++ b/google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.cc @@ -0,0 +1,91 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy:: + ~PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy() = default; + +std::unique_ptr +PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy::clone() const { + return std::make_unique< + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy>(*this); +} + +Idempotency PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy:: + CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy:: + GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy:: + UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy:: + DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy:: + ListPrincipalAccessBoundaryPolicies( + google::iam::v3:: + ListPrincipalAccessBoundaryPoliciesRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy:: + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3:: + SearchPrincipalAccessBoundaryPolicyBindingsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +std::unique_ptr +MakeDefaultPrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy() { + return std::make_unique< + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy>(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google diff --git a/google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.h b/google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.h new file mode 100644 index 0000000000000..729f61e806940 --- /dev/null +++ b/google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.h @@ -0,0 +1,77 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy { + public: + virtual ~PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr< + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy> + clone() const; + + virtual google::cloud::Idempotency CreatePrincipalAccessBoundaryPolicy( + google::iam::v3::CreatePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual google::cloud::Idempotency GetPrincipalAccessBoundaryPolicy( + google::iam::v3::GetPrincipalAccessBoundaryPolicyRequest const& request); + + virtual google::cloud::Idempotency UpdatePrincipalAccessBoundaryPolicy( + google::iam::v3::UpdatePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual google::cloud::Idempotency DeletePrincipalAccessBoundaryPolicy( + google::iam::v3::DeletePrincipalAccessBoundaryPolicyRequest const& + request); + + virtual google::cloud::Idempotency ListPrincipalAccessBoundaryPolicies( + google::iam::v3::ListPrincipalAccessBoundaryPoliciesRequest request); + + virtual google::cloud::Idempotency + SearchPrincipalAccessBoundaryPolicyBindings( + google::iam::v3::SearchPrincipalAccessBoundaryPolicyBindingsRequest + request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); +}; + +std::unique_ptr +MakeDefaultPrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/iam/v3/principal_access_boundary_policies_options.h b/google/cloud/iam/v3/principal_access_boundary_policies_options.h new file mode 100644 index 0000000000000..23c7fa3452d69 --- /dev/null +++ b/google/cloud/iam/v3/principal_access_boundary_policies_options.h @@ -0,0 +1,88 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_OPTIONS_H + +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_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 iam_v3 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-iam-options + */ +struct PrincipalAccessBoundaryPoliciesRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-iam-options + */ +struct PrincipalAccessBoundaryPoliciesBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-iam-options + */ +struct PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr< + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy>; +}; + +/** + * Use with `google::cloud::Options` to configure the long-running operations + * polling policy. + * + * @ingroup google-cloud-iam-options + */ +struct PrincipalAccessBoundaryPoliciesPollingPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to PrincipalAccessBoundaryPolicies. + * + * @ingroup google-cloud-iam-options + */ +using PrincipalAccessBoundaryPoliciesPolicyOptionList = OptionList< + PrincipalAccessBoundaryPoliciesRetryPolicyOption, + PrincipalAccessBoundaryPoliciesBackoffPolicyOption, + PrincipalAccessBoundaryPoliciesPollingPolicyOption, + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicyOption>; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace iam_v3 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_V3_PRINCIPAL_ACCESS_BOUNDARY_POLICIES_OPTIONS_H diff --git a/google/cloud/iam/v3/samples/policy_bindings_client_samples.cc b/google/cloud/iam/v3/samples/policy_bindings_client_samples.cc new file mode 100644 index 0000000000000..3ae1eeeb699d7 --- /dev/null +++ b/google/cloud/iam/v3/samples/policy_bindings_client_samples.cc @@ -0,0 +1,200 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/policy_bindings_service.proto + +#include "google/cloud/iam/v3/policy_bindings_client.h" +#include "google/cloud/iam/v3/policy_bindings_connection_idempotency_policy.h" +#include "google/cloud/iam/v3/policy_bindings_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 +#include +#include +#include + +// clang-format off +// main-dox-marker: iam_v3::PolicyBindingsClient +// 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 client = google::cloud::iam_v3::PolicyBindingsClient( + google::cloud::iam_v3::MakePolicyBindingsConnection(options)); + //! [set-client-endpoint] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::iam_v3::PolicyBindingsConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr< + google::cloud::iam_v3::PolicyBindingsConnectionIdempotencyPolicy> + 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::iam_v3::PolicyBindingsLimitedErrorCountRetryPolicy( + 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::iam_v3::MakePolicyBindingsConnection(options); + + // c1 and c2 share the same retry policies + auto c1 = google::cloud::iam_v3::PolicyBindingsClient(connection); + auto c2 = google::cloud::iam_v3::PolicyBindingsClient(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::iam_v3::PolicyBindingsClient( + connection, + google::cloud::Options{} + .set( + google::cloud::iam_v3::PolicyBindingsLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::iam_v3::PolicyBindingsLimitedErrorCountRetryPolicy(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::iam_v3::PolicyBindingsRetryPolicyOption::Type, + google::cloud::iam_v3::PolicyBindingsBackoffPolicyOption:: + Type>( + google::cloud::iam_v3::PolicyBindingsLimitedTimeRetryPolicy( + /*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::iam_v3::MakePolicyBindingsConnection(options); + + // c1 and c2 share the same polling policies. + auto c1 = google::cloud::iam_v3::PolicyBindingsClient(connection); + auto c2 = google::cloud::iam_v3::PolicyBindingsClient(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::iam_v3::PolicyBindingsClient( + google::cloud::iam_v3::MakePolicyBindingsConnection(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}); +} + +} // 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}, + {"auto", AutoRun}, + }); + return example.Run(argc, argv); +} diff --git a/google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc b/google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc new file mode 100644 index 0000000000000..066dcf1822a08 --- /dev/null +++ b/google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc @@ -0,0 +1,218 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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/iam/v3/principal_access_boundary_policies_service.proto + +#include "google/cloud/iam/v3/principal_access_boundary_policies_client.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_connection_idempotency_policy.h" +#include "google/cloud/iam/v3/principal_access_boundary_policies_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 +#include +#include +#include + +// clang-format off +// main-dox-marker: iam_v3::PrincipalAccessBoundaryPoliciesClient +// 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 client = google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesClient( + google::cloud::iam_v3::MakePrincipalAccessBoundaryPoliciesConnection( + options)); + //! [set-client-endpoint] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::iam_v3:: + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr< + google::cloud::iam_v3:: + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicy> + 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< + google::cloud::iam_v3:: + PrincipalAccessBoundaryPoliciesConnectionIdempotencyPolicyOption>( + CustomIdempotencyPolicy().clone()) + .set( + google::cloud::iam_v3:: + PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy(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::iam_v3::MakePrincipalAccessBoundaryPoliciesConnection( + options); + + // c1 and c2 share the same retry policies + auto c1 = + google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesClient(connection); + auto c2 = + google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesClient(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::iam_v3::PrincipalAccessBoundaryPoliciesClient( + connection, + google::cloud::Options{} + .set( + google::cloud::iam_v3:: + PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesLimitedErrorCountRetryPolicy(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::iam_v3:: + PrincipalAccessBoundaryPoliciesRetryPolicyOption::Type, + google::cloud::iam_v3:: + PrincipalAccessBoundaryPoliciesBackoffPolicyOption::Type>( + google::cloud::iam_v3:: + PrincipalAccessBoundaryPoliciesLimitedTimeRetryPolicy( + /*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::iam_v3::MakePrincipalAccessBoundaryPoliciesConnection( + options); + + // c1 and c2 share the same polling policies. + auto c1 = + google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesClient(connection); + auto c2 = + google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesClient(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::iam_v3::PrincipalAccessBoundaryPoliciesClient( + google::cloud::iam_v3::MakePrincipalAccessBoundaryPoliciesConnection( + 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}); +} + +} // 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}, + {"auto", AutoRun}, + }); + return example.Run(argc, argv); +}