diff --git a/CHANGELOG.md b/CHANGELOG.md index e5024d0637a51..5524f593d6f03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ for details on updating existing applications using v1.x.y or v2.x.y. ### [Cloud Quotas API](/google/cloud/cloudquotas/README.md) - The library has been expanded to include the QuotaAdjusterSettingsManager service. +### [Cloud Sql Admin API](/google/cloud/sql/README.md) + - The library has been expanded to include the Backups and FeatureEligibility services. + ## v3.7.0 - 2026-07 ### Removed Libraries diff --git a/ci/abi-dumps/google_cloud_cpp_sql.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_sql.expected.abi.dump.gz index ddac29984c606..a0bd265c463e5 100644 Binary files a/ci/abi-dumps/google_cloud_cpp_sql.expected.abi.dump.gz and b/ci/abi-dumps/google_cloud_cpp_sql.expected.abi.dump.gz differ diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index c199787ec21f5..78565dd8f2491 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -3780,6 +3780,16 @@ service { preserve_proto_field_names_in_json: true } +service { + service_proto_path: "google/cloud/sql/v1/cloud_sql_backups.proto" + product_path: "google/cloud/sql/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] + generate_rest_transport: true + generate_grpc_transport: false + preserve_proto_field_names_in_json: true +} + service { service_proto_path: "google/cloud/sql/v1/cloud_sql_connect.proto" product_path: "google/cloud/sql/v1" @@ -3810,6 +3820,16 @@ service { preserve_proto_field_names_in_json: true } +service { + service_proto_path: "google/cloud/sql/v1/cloud_sql_feature_eligibility.proto" + product_path: "google/cloud/sql/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] + generate_rest_transport: true + generate_grpc_transport: false + preserve_proto_field_names_in_json: true +} + service { service_proto_path: "google/cloud/sql/v1/cloud_sql_flags.proto" product_path: "google/cloud/sql/v1" diff --git a/google/cloud/sql/doc/environment-variables.dox b/google/cloud/sql/doc/environment-variables.dox index 6ae0c5ed1b2a7..3cb78ec9ec9ff 100644 --- a/google/cloud/sql/doc/environment-variables.dox +++ b/google/cloud/sql/doc/environment-variables.dox @@ -13,6 +13,10 @@ environment variables are convenient when troubleshooting problems. `EndpointOption` (which defaults to "sqladmin.googleapis.com") used by `MakeSqlAvailableDatabaseVersionsServiceConnection()`. +- `GOOGLE_CLOUD_CPP_SQL_BACKUPS_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "sqladmin.googleapis.com") + used by `MakeSqlBackupsServiceConnection()`. + - `GOOGLE_CLOUD_CPP_SQL_BACKUP_RUNS_SERVICE_ENDPOINT=...` overrides the `EndpointOption` (which defaults to "sqladmin.googleapis.com") used by `MakeSqlBackupRunsServiceConnection()`. @@ -29,6 +33,10 @@ environment variables are convenient when troubleshooting problems. `EndpointOption` (which defaults to "sqladmin.googleapis.com") used by `MakeSqlEventsServiceConnection()`. +- `GOOGLE_CLOUD_CPP_SQL_FEATURE_ELIGIBILITY_SERVICE_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "sqladmin.googleapis.com") + used by `MakeSqlFeatureEligibilityServiceConnection()`. + - `GOOGLE_CLOUD_CPP_SQL_FLAGS_SERVICE_ENDPOINT=...` overrides the `EndpointOption` (which defaults to "sqladmin.googleapis.com") used by `MakeSqlFlagsServiceConnection()`. diff --git a/google/cloud/sql/doc/main.dox b/google/cloud/sql/doc/main.dox index e515d1a8e579d..e6c0710b9714d 100644 --- a/google/cloud/sql/doc/main.dox +++ b/google/cloud/sql/doc/main.dox @@ -33,9 +33,11 @@ application. - [\c sql_v1::SqlAvailableDatabaseVersionsServiceClient](@ref google::cloud::sql_v1::SqlAvailableDatabaseVersionsServiceClient) - [\c sql_v1::SqlBackupRunsServiceClient](@ref google::cloud::sql_v1::SqlBackupRunsServiceClient) +- [\c sql_v1::SqlBackupsServiceClient](@ref google::cloud::sql_v1::SqlBackupsServiceClient) - [\c sql_v1::SqlConnectServiceClient](@ref google::cloud::sql_v1::SqlConnectServiceClient) - [\c sql_v1::SqlDatabasesServiceClient](@ref google::cloud::sql_v1::SqlDatabasesServiceClient) - [\c sql_v1::SqlEventsServiceClient](@ref google::cloud::sql_v1::SqlEventsServiceClient) +- [\c sql_v1::SqlFeatureEligibilityServiceClient](@ref google::cloud::sql_v1::SqlFeatureEligibilityServiceClient) - [\c sql_v1::SqlFlagsServiceClient](@ref google::cloud::sql_v1::SqlFlagsServiceClient) - [\c sql_v1::SqlIamPoliciesServiceClient](@ref google::cloud::sql_v1::SqlIamPoliciesServiceClient) - [\c sql_v1::SqlInstanceNamesServiceClient](@ref google::cloud::sql_v1::SqlInstanceNamesServiceClient) diff --git a/google/cloud/sql/doc/override-authentication.dox b/google/cloud/sql/doc/override-authentication.dox index 3a277d2fef396..728897c8c6c8a 100644 --- a/google/cloud/sql/doc/override-authentication.dox +++ b/google/cloud/sql/doc/override-authentication.dox @@ -15,9 +15,11 @@ Follow these links to find examples for other \c *Client classes: - [\c sql_v1::SqlAvailableDatabaseVersionsServiceClient](@ref sql_v1::SqlAvailableDatabaseVersionsServiceClient-service-account-snippet) - [\c sql_v1::SqlBackupRunsServiceClient](@ref sql_v1::SqlBackupRunsServiceClient-service-account-snippet) +- [\c sql_v1::SqlBackupsServiceClient](@ref sql_v1::SqlBackupsServiceClient-service-account-snippet) - [\c sql_v1::SqlConnectServiceClient](@ref sql_v1::SqlConnectServiceClient-service-account-snippet) - [\c sql_v1::SqlDatabasesServiceClient](@ref sql_v1::SqlDatabasesServiceClient-service-account-snippet) - [\c sql_v1::SqlEventsServiceClient](@ref sql_v1::SqlEventsServiceClient-service-account-snippet) +- [\c sql_v1::SqlFeatureEligibilityServiceClient](@ref sql_v1::SqlFeatureEligibilityServiceClient-service-account-snippet) - [\c sql_v1::SqlFlagsServiceClient](@ref sql_v1::SqlFlagsServiceClient-service-account-snippet) - [\c sql_v1::SqlIamPoliciesServiceClient](@ref sql_v1::SqlIamPoliciesServiceClient-service-account-snippet) - [\c sql_v1::SqlInstanceNamesServiceClient](@ref sql_v1::SqlInstanceNamesServiceClient-service-account-snippet) @@ -56,6 +58,12 @@ guide for more details. */ +/*! @page sql_v1::SqlBackupsServiceClient-service-account-snippet Override sql_v1::SqlBackupsServiceClient Authentication Defaults + +@snippet google/cloud/sql/v1/samples/sql_backups_client_samples.cc with-service-account + +*/ + /*! @page sql_v1::SqlConnectServiceClient-service-account-snippet Override sql_v1::SqlConnectServiceClient Authentication Defaults @snippet google/cloud/sql/v1/samples/sql_connect_client_samples.cc with-service-account @@ -74,6 +82,12 @@ guide for more details. */ +/*! @page sql_v1::SqlFeatureEligibilityServiceClient-service-account-snippet Override sql_v1::SqlFeatureEligibilityServiceClient Authentication Defaults + +@snippet google/cloud/sql/v1/samples/sql_feature_eligibility_client_samples.cc with-service-account + +*/ + /*! @page sql_v1::SqlFlagsServiceClient-service-account-snippet Override sql_v1::SqlFlagsServiceClient Authentication Defaults @snippet google/cloud/sql/v1/samples/sql_flags_client_samples.cc with-service-account diff --git a/google/cloud/sql/doc/override-endpoint.dox b/google/cloud/sql/doc/override-endpoint.dox index a9f95f34e3208..b746a591a8695 100644 --- a/google/cloud/sql/doc/override-endpoint.dox +++ b/google/cloud/sql/doc/override-endpoint.dox @@ -15,9 +15,11 @@ Follow these links to find examples for other \c *Client classes: - [\c sql_v1::SqlAvailableDatabaseVersionsServiceClient](@ref sql_v1::SqlAvailableDatabaseVersionsServiceClient-endpoint-snippet) - [\c sql_v1::SqlBackupRunsServiceClient](@ref sql_v1::SqlBackupRunsServiceClient-endpoint-snippet) +- [\c sql_v1::SqlBackupsServiceClient](@ref sql_v1::SqlBackupsServiceClient-endpoint-snippet) - [\c sql_v1::SqlConnectServiceClient](@ref sql_v1::SqlConnectServiceClient-endpoint-snippet) - [\c sql_v1::SqlDatabasesServiceClient](@ref sql_v1::SqlDatabasesServiceClient-endpoint-snippet) - [\c sql_v1::SqlEventsServiceClient](@ref sql_v1::SqlEventsServiceClient-endpoint-snippet) +- [\c sql_v1::SqlFeatureEligibilityServiceClient](@ref sql_v1::SqlFeatureEligibilityServiceClient-endpoint-snippet) - [\c sql_v1::SqlFlagsServiceClient](@ref sql_v1::SqlFlagsServiceClient-endpoint-snippet) - [\c sql_v1::SqlIamPoliciesServiceClient](@ref sql_v1::SqlIamPoliciesServiceClient-endpoint-snippet) - [\c sql_v1::SqlInstanceNamesServiceClient](@ref sql_v1::SqlInstanceNamesServiceClient-endpoint-snippet) @@ -46,6 +48,12 @@ Follow these links to find examples for other \c *Client classes: */ +/*! @page sql_v1::SqlBackupsServiceClient-endpoint-snippet Override sql_v1::SqlBackupsServiceClient Endpoint Configuration + +@snippet google/cloud/sql/v1/samples/sql_backups_client_samples.cc set-client-endpoint + +*/ + /*! @page sql_v1::SqlConnectServiceClient-endpoint-snippet Override sql_v1::SqlConnectServiceClient Endpoint Configuration @snippet google/cloud/sql/v1/samples/sql_connect_client_samples.cc set-client-endpoint @@ -64,6 +72,12 @@ Follow these links to find examples for other \c *Client classes: */ +/*! @page sql_v1::SqlFeatureEligibilityServiceClient-endpoint-snippet Override sql_v1::SqlFeatureEligibilityServiceClient Endpoint Configuration + +@snippet google/cloud/sql/v1/samples/sql_feature_eligibility_client_samples.cc set-client-endpoint + +*/ + /*! @page sql_v1::SqlFlagsServiceClient-endpoint-snippet Override sql_v1::SqlFlagsServiceClient Endpoint Configuration @snippet google/cloud/sql/v1/samples/sql_flags_client_samples.cc set-client-endpoint diff --git a/google/cloud/sql/doc/override-retry-policies.dox b/google/cloud/sql/doc/override-retry-policies.dox index ebc500df9ac9c..68e30a326bbe8 100644 --- a/google/cloud/sql/doc/override-retry-policies.dox +++ b/google/cloud/sql/doc/override-retry-policies.dox @@ -80,9 +80,11 @@ Follow these links to find examples for other \c *Client classes: - [\c sql_v1::SqlAvailableDatabaseVersionsServiceClient](@ref sql_v1::SqlAvailableDatabaseVersionsServiceClient-retry-snippet) - [\c sql_v1::SqlBackupRunsServiceClient](@ref sql_v1::SqlBackupRunsServiceClient-retry-snippet) +- [\c sql_v1::SqlBackupsServiceClient](@ref sql_v1::SqlBackupsServiceClient-retry-snippet) - [\c sql_v1::SqlConnectServiceClient](@ref sql_v1::SqlConnectServiceClient-retry-snippet) - [\c sql_v1::SqlDatabasesServiceClient](@ref sql_v1::SqlDatabasesServiceClient-retry-snippet) - [\c sql_v1::SqlEventsServiceClient](@ref sql_v1::SqlEventsServiceClient-retry-snippet) +- [\c sql_v1::SqlFeatureEligibilityServiceClient](@ref sql_v1::SqlFeatureEligibilityServiceClient-retry-snippet) - [\c sql_v1::SqlFlagsServiceClient](@ref sql_v1::SqlFlagsServiceClient-retry-snippet) - [\c sql_v1::SqlIamPoliciesServiceClient](@ref sql_v1::SqlIamPoliciesServiceClient-retry-snippet) - [\c sql_v1::SqlInstanceNamesServiceClient](@ref sql_v1::SqlInstanceNamesServiceClient-retry-snippet) @@ -131,6 +133,18 @@ Assuming you have created a custom idempotency policy. Such as: */ +/*! @page sql_v1::SqlBackupsServiceClient-retry-snippet Override sql_v1::SqlBackupsServiceClient Retry Policies + +This shows how to override the retry policies for sql_v1::SqlBackupsServiceClient: + +@snippet google/cloud/sql/v1/samples/sql_backups_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/sql/v1/samples/sql_backups_client_samples.cc custom-idempotency-policy + +*/ + /*! @page sql_v1::SqlConnectServiceClient-retry-snippet Override sql_v1::SqlConnectServiceClient Retry Policies This shows how to override the retry policies for sql_v1::SqlConnectServiceClient: @@ -167,6 +181,18 @@ Assuming you have created a custom idempotency policy. Such as: */ +/*! @page sql_v1::SqlFeatureEligibilityServiceClient-retry-snippet Override sql_v1::SqlFeatureEligibilityServiceClient Retry Policies + +This shows how to override the retry policies for sql_v1::SqlFeatureEligibilityServiceClient: + +@snippet google/cloud/sql/v1/samples/sql_feature_eligibility_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/sql/v1/samples/sql_feature_eligibility_client_samples.cc custom-idempotency-policy + +*/ + /*! @page sql_v1::SqlFlagsServiceClient-retry-snippet Override sql_v1::SqlFlagsServiceClient Retry Policies This shows how to override the retry policies for sql_v1::SqlFlagsServiceClient: diff --git a/google/cloud/sql/doc/override-universe-domain.dox b/google/cloud/sql/doc/override-universe-domain.dox index 4c5fddfa0da89..b3ecfd53d8ec8 100644 --- a/google/cloud/sql/doc/override-universe-domain.dox +++ b/google/cloud/sql/doc/override-universe-domain.dox @@ -14,9 +14,11 @@ Follow these links to find examples for other \c *Client classes: - [\c sql_v1::SqlAvailableDatabaseVersionsServiceClient](@ref sql_v1::SqlAvailableDatabaseVersionsServiceClient-universe-domain-snippet) - [\c sql_v1::SqlBackupRunsServiceClient](@ref sql_v1::SqlBackupRunsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlBackupsServiceClient](@ref sql_v1::SqlBackupsServiceClient-universe-domain-snippet) - [\c sql_v1::SqlConnectServiceClient](@ref sql_v1::SqlConnectServiceClient-universe-domain-snippet) - [\c sql_v1::SqlDatabasesServiceClient](@ref sql_v1::SqlDatabasesServiceClient-universe-domain-snippet) - [\c sql_v1::SqlEventsServiceClient](@ref sql_v1::SqlEventsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlFeatureEligibilityServiceClient](@ref sql_v1::SqlFeatureEligibilityServiceClient-universe-domain-snippet) - [\c sql_v1::SqlFlagsServiceClient](@ref sql_v1::SqlFlagsServiceClient-universe-domain-snippet) - [\c sql_v1::SqlIamPoliciesServiceClient](@ref sql_v1::SqlIamPoliciesServiceClient-universe-domain-snippet) - [\c sql_v1::SqlInstanceNamesServiceClient](@ref sql_v1::SqlInstanceNamesServiceClient-universe-domain-snippet) @@ -45,6 +47,12 @@ Follow these links to find examples for other \c *Client classes: */ +/*! @page sql_v1::SqlBackupsServiceClient-universe-domain-snippet Override sql_v1::SqlBackupsServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_backups_client_samples.cc set-client-universe-domain + +*/ + /*! @page sql_v1::SqlConnectServiceClient-universe-domain-snippet Override sql_v1::SqlConnectServiceClient Universe Domain @snippet google/cloud/sql/v1/samples/sql_connect_client_samples.cc set-client-universe-domain @@ -63,6 +71,12 @@ Follow these links to find examples for other \c *Client classes: */ +/*! @page sql_v1::SqlFeatureEligibilityServiceClient-universe-domain-snippet Override sql_v1::SqlFeatureEligibilityServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_feature_eligibility_client_samples.cc set-client-universe-domain + +*/ + /*! @page sql_v1::SqlFlagsServiceClient-universe-domain-snippet Override sql_v1::SqlFlagsServiceClient Universe Domain @snippet google/cloud/sql/v1/samples/sql_flags_client_samples.cc set-client-universe-domain diff --git a/google/cloud/sql/v1/internal/sql_backups_option_defaults.cc b/google/cloud/sql/v1/internal/sql_backups_option_defaults.cc new file mode 100644 index 0000000000000..3d629e6f100c1 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_option_defaults.cc @@ -0,0 +1,67 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/internal/sql_backups_option_defaults.h" +#include "google/cloud/sql/v1/sql_backups_connection.h" +#include "google/cloud/sql/v1/sql_backups_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 sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options SqlBackupsServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_SQL_BACKUPS_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_SQL_BACKUPS_SERVICE_AUTHORITY", + "sqladmin.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + sql_v1::SqlBackupsServiceLimitedTimeRetryPolicy( + std::chrono::minutes(10)) + .clone()); + } + if (!options.has()) { + options.set( + ExponentialBackoffPolicy( + std::chrono::seconds(0), std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling, kBackoffScaling) + .clone()); + } + if (!options + .has()) { + options.set( + sql_v1::MakeDefaultSqlBackupsServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_backups_option_defaults.h b/google/cloud/sql/v1/internal/sql_backups_option_defaults.h new file mode 100644 index 0000000000000..41000f27eedea --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options SqlBackupsServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_OPTION_DEFAULTS_H diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.cc b/google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.cc new file mode 100644 index 0000000000000..1426d1288392f --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.cc @@ -0,0 +1,135 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.h" +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/rest_retry_loop.h" +#include "google/cloud/rest_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlBackupsServiceRestConnectionImpl::SqlBackupsServiceRestConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions( + std::move(options), SqlBackupsServiceConnection::options())) {} + +StatusOr +SqlBackupsServiceRestConnectionImpl::CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateBackup(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) { + return stub_->CreateBackup(rest_context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SqlBackupsServiceRestConnectionImpl::GetBackup( + google::cloud::sql::v1::GetBackupRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetBackup(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) { + return stub_->GetBackup(rest_context, options, request); + }, + *current, request, __func__); +} + +StreamRange +SqlBackupsServiceRestConnectionImpl::ListBackups( + google::cloud::sql::v1::ListBackupsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListBackups(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& r) { + return google::cloud::rest_internal::RestRetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) { + return stub->ListBackups(rest_context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::sql::v1::ListBackupsResponse r) { + std::vector result(r.backups().size()); + auto& messages = *r.mutable_backups(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SqlBackupsServiceRestConnectionImpl::UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateBackup(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) { + return stub_->UpdateBackup(rest_context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SqlBackupsServiceRestConnectionImpl::DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteBackup(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) { + return stub_->DeleteBackup(rest_context, options, request); + }, + *current, request, __func__); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.h b/google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.h new file mode 100644 index 0000000000000..afd6a4efd8692 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.h @@ -0,0 +1,94 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_CONNECTION_IMPL_H + +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub.h" +#include "google/cloud/sql/v1/internal/sql_backups_retry_traits.h" +#include "google/cloud/sql/v1/sql_backups_connection.h" +#include "google/cloud/sql/v1/sql_backups_connection_idempotency_policy.h" +#include "google/cloud/sql/v1/sql_backups_options.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlBackupsServiceRestConnectionImpl + : public sql_v1::SqlBackupsServiceConnection { + public: + ~SqlBackupsServiceRestConnectionImpl() override = default; + + SqlBackupsServiceRestConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options); + + Options options() override { return options_; } + + StatusOr CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const& request) override; + + StatusOr GetBackup( + google::cloud::sql::v1::GetBackupRequest const& request) override; + + StreamRange ListBackups( + google::cloud::sql::v1::ListBackupsRequest request) override; + + StatusOr UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const& request) override; + + StatusOr DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const& request) override; + + private: + static std::unique_ptr retry_policy( + Options const& options) { + return options.get()->clone(); + } + + static std::unique_ptr backoff_policy(Options const& options) { + return options.get()->clone(); + } + + static std::unique_ptr + idempotency_policy(Options const& options) { + return options + .get() + ->clone(); + } + + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_CONNECTION_IMPL_H diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.cc b/google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.cc new file mode 100644 index 0000000000000..1445805439658 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.cc @@ -0,0 +1,100 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlBackupsServiceRestLogging::SqlBackupsServiceRestLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set components) + : child_(std::move(child)), + tracing_options_(std::move(tracing_options)), + components_(std::move(components)) {} + +StatusOr +SqlBackupsServiceRestLogging::CreateBackup( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) { + return child_->CreateBackup(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr +SqlBackupsServiceRestLogging::GetBackup( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) { + return child_->GetBackup(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr +SqlBackupsServiceRestLogging::ListBackups( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) { + return child_->ListBackups(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr +SqlBackupsServiceRestLogging::UpdateBackup( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) { + return child_->UpdateBackup(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr +SqlBackupsServiceRestLogging::DeleteBackup( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) { + return child_->DeleteBackup(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.h b/google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.h new file mode 100644 index 0000000000000..1c49d3afd1cfd --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.h @@ -0,0 +1,80 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_LOGGING_DECORATOR_H + +#include "google/cloud/sql/v1/cloud_sql_backups.pb.h" +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub.h" +#include "google/cloud/future.h" +#include "google/cloud/internal/rest_context.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlBackupsServiceRestLogging : public SqlBackupsServiceRestStub { + public: + ~SqlBackupsServiceRestLogging() override = default; + SqlBackupsServiceRestLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set components); + + StatusOr CreateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) override; + + StatusOr GetBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) override; + + StatusOr ListBackups( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) override; + + StatusOr UpdateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) override; + + StatusOr DeleteBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) override; + + private: + std::shared_ptr child_; + TracingOptions tracing_options_; + std::set components_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_LOGGING_DECORATOR_H diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.cc b/google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.cc new file mode 100644 index 0000000000000..8cce571920da4 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.cc @@ -0,0 +1,92 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/internal/rest_set_metadata.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlBackupsServiceRestMetadata::SqlBackupsServiceRestMetadata( + std::shared_ptr child, + std::string api_client_header) + : child_(std::move(child)), + api_client_header_( + api_client_header.empty() + ? google::cloud::internal::GeneratedLibClientHeader() + : std::move(api_client_header)) {} + +StatusOr +SqlBackupsServiceRestMetadata::CreateBackup( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) { + SetMetadata(rest_context, options); + return child_->CreateBackup(rest_context, options, request); +} + +StatusOr +SqlBackupsServiceRestMetadata::GetBackup( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) { + SetMetadata(rest_context, options); + return child_->GetBackup(rest_context, options, request); +} + +StatusOr +SqlBackupsServiceRestMetadata::ListBackups( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) { + SetMetadata(rest_context, options); + return child_->ListBackups(rest_context, options, request); +} + +StatusOr +SqlBackupsServiceRestMetadata::UpdateBackup( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) { + SetMetadata(rest_context, options); + return child_->UpdateBackup(rest_context, options, request); +} + +StatusOr +SqlBackupsServiceRestMetadata::DeleteBackup( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) { + SetMetadata(rest_context, options); + return child_->DeleteBackup(rest_context, options, request); +} + +void SqlBackupsServiceRestMetadata::SetMetadata( + rest_internal::RestContext& rest_context, Options const& options, + std::vector const& params) { + google::cloud::rest_internal::SetMetadata(rest_context, options, params, + api_client_header_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.h b/google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.h new file mode 100644 index 0000000000000..0966babe6750d --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.h @@ -0,0 +1,81 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_METADATA_DECORATOR_H + +#include "google/cloud/sql/v1/cloud_sql_backups.pb.h" +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub.h" +#include "google/cloud/future.h" +#include "google/cloud/rest_options.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlBackupsServiceRestMetadata : public SqlBackupsServiceRestStub { + public: + ~SqlBackupsServiceRestMetadata() override = default; + explicit SqlBackupsServiceRestMetadata( + std::shared_ptr child, + std::string api_client_header = ""); + + StatusOr CreateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) override; + + StatusOr GetBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) override; + + StatusOr ListBackups( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) override; + + StatusOr UpdateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) override; + + StatusOr DeleteBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) override; + + private: + void SetMetadata(rest_internal::RestContext& rest_context, + Options const& options, + std::vector const& params = {}); + + std::shared_ptr child_; + std::string api_client_header_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_METADATA_DECORATOR_H diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_stub.cc b/google/cloud/sql/v1/internal/sql_backups_rest_stub.cc new file mode 100644 index 0000000000000..ed252a7f436a2 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_stub.cc @@ -0,0 +1,116 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub.h" +#include "google/cloud/sql/v1/cloud_sql_backups.pb.h" +#include "google/cloud/common_options.h" +#include "google/cloud/internal/rest_stub_helpers.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DefaultSqlBackupsServiceRestStub::DefaultSqlBackupsServiceRestStub( + Options options) + : service_(rest_internal::MakePooledRestClient( + options.get(), options)), + options_(std::move(options)) {} + +DefaultSqlBackupsServiceRestStub::DefaultSqlBackupsServiceRestStub( + std::shared_ptr service, Options options) + : service_(std::move(service)), options_(std::move(options)) {} + +StatusOr +DefaultSqlBackupsServiceRestStub::CreateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) { + std::vector> query_params; + return rest_internal::Post( + *service_, rest_context, request.backup(), true, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.parent(), "/", "backups"), + std::move(query_params)); +} + +StatusOr +DefaultSqlBackupsServiceRestStub::GetBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) { + std::vector> query_params; + return rest_internal::Get( + *service_, rest_context, request, true, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +StatusOr +DefaultSqlBackupsServiceRestStub::ListBackups( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) { + std::vector> query_params; + query_params.push_back({"page_size", std::to_string(request.page_size())}); + query_params.push_back({"page_token", request.page_token()}); + query_params.push_back({"filter", request.filter()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Get( + *service_, rest_context, request, true, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.parent(), "/", "backups"), + std::move(query_params)); +} + +StatusOr +DefaultSqlBackupsServiceRestStub::UpdateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) { + std::vector> query_params; + return rest_internal::Patch( + *service_, rest_context, request.backup(), true, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.backup().name()), + std::move(query_params)); +} + +StatusOr +DefaultSqlBackupsServiceRestStub::DeleteBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) { + std::vector> query_params; + return rest_internal::Delete( + *service_, rest_context, request, true, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_stub.h b/google/cloud/sql/v1/internal/sql_backups_rest_stub.h new file mode 100644 index 0000000000000..edf4e5a6bf1e1 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_stub.h @@ -0,0 +1,108 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_STUB_H + +#include "google/cloud/sql/v1/cloud_sql_backups.pb.h" +#include "google/cloud/completion_queue.h" +#include "google/cloud/internal/rest_client.h" +#include "google/cloud/internal/rest_context.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlBackupsServiceRestStub { + public: + virtual ~SqlBackupsServiceRestStub() = default; + + virtual StatusOr CreateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) = 0; + + virtual StatusOr GetBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) = 0; + + virtual StatusOr ListBackups( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) = 0; + + virtual StatusOr UpdateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) = 0; + + virtual StatusOr DeleteBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) = 0; +}; + +class DefaultSqlBackupsServiceRestStub : public SqlBackupsServiceRestStub { + public: + ~DefaultSqlBackupsServiceRestStub() override = default; + + explicit DefaultSqlBackupsServiceRestStub(Options options); + DefaultSqlBackupsServiceRestStub( + std::shared_ptr service, Options options); + + StatusOr CreateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::CreateBackupRequest const& request) override; + + StatusOr GetBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::GetBackupRequest const& request) override; + + StatusOr ListBackups( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::ListBackupsRequest const& request) override; + + StatusOr UpdateBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::UpdateBackupRequest const& request) override; + + StatusOr DeleteBackup( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::sql::v1::DeleteBackupRequest const& request) override; + + private: + std::shared_ptr service_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_STUB_H diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.cc b/google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.cc new file mode 100644 index 0000000000000..9cfc154357e68 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.cc @@ -0,0 +1,56 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.h" +#include "google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.h" +#include "google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.h" +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub.h" +#include "google/cloud/common_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/populate_rest_options.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include "google/cloud/rest_options.h" +#include "absl/strings/match.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +CreateDefaultSqlBackupsServiceRestStub(Options const& options) { + auto opts = internal::PopulateRestOptions(options); + std::shared_ptr stub = + std::make_shared(std::move(opts)); + stub = std::make_shared(std::move(stub)); + if (internal::Contains(options.get(), "rpc")) { + GCP_LOG(INFO) << "Enabled logging for REST rpc calls"; + stub = std::make_shared( + std::move(stub), options.get(), + options.get()); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.h b/google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.h new file mode 100644 index 0000000000000..6b0f5a7fa21a6 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.h @@ -0,0 +1,40 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_STUB_FACTORY_H + +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +CreateDefaultSqlBackupsServiceRestStub(Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_REST_STUB_FACTORY_H diff --git a/google/cloud/sql/v1/internal/sql_backups_retry_traits.h b/google/cloud/sql/v1/internal/sql_backups_retry_traits.h new file mode 100644 index 0000000000000..8c0fd130ed71a --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct SqlBackupsServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_RETRY_TRAITS_H diff --git a/google/cloud/sql/v1/internal/sql_backups_sources.cc b/google/cloud/sql/v1/internal/sql_backups_sources.cc new file mode 100644 index 0000000000000..39613cfdebfa7 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_sources.cc @@ -0,0 +1,31 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/sql/v1/internal/sql_backups_option_defaults.cc" +#include "google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.cc" +#include "google/cloud/sql/v1/internal/sql_backups_rest_logging_decorator.cc" +#include "google/cloud/sql/v1/internal/sql_backups_rest_metadata_decorator.cc" +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub.cc" +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.cc" +#include "google/cloud/sql/v1/internal/sql_backups_tracing_connection.cc" +#include "google/cloud/sql/v1/sql_backups_client.cc" +#include "google/cloud/sql/v1/sql_backups_connection.cc" +#include "google/cloud/sql/v1/sql_backups_connection_idempotency_policy.cc" +#include "google/cloud/sql/v1/sql_backups_rest_connection.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/sql/v1/internal/sql_backups_tracing_connection.cc b/google/cloud/sql/v1/internal/sql_backups_tracing_connection.cc new file mode 100644 index 0000000000000..837777b3757d3 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_tracing_connection.cc @@ -0,0 +1,94 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/internal/sql_backups_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlBackupsServiceTracingConnection::SqlBackupsServiceTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StatusOr +SqlBackupsServiceTracingConnection::CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const& request) { + auto span = + internal::MakeSpan("sql_v1::SqlBackupsServiceConnection::CreateBackup"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CreateBackup(request)); +} + +StatusOr +SqlBackupsServiceTracingConnection::GetBackup( + google::cloud::sql::v1::GetBackupRequest const& request) { + auto span = + internal::MakeSpan("sql_v1::SqlBackupsServiceConnection::GetBackup"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetBackup(request)); +} + +StreamRange +SqlBackupsServiceTracingConnection::ListBackups( + google::cloud::sql::v1::ListBackupsRequest request) { + auto span = + internal::MakeSpan("sql_v1::SqlBackupsServiceConnection::ListBackups"); + internal::OTelScope scope(span); + auto sr = child_->ListBackups(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SqlBackupsServiceTracingConnection::UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const& request) { + auto span = + internal::MakeSpan("sql_v1::SqlBackupsServiceConnection::UpdateBackup"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->UpdateBackup(request)); +} + +StatusOr +SqlBackupsServiceTracingConnection::DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const& request) { + auto span = + internal::MakeSpan("sql_v1::SqlBackupsServiceConnection::DeleteBackup"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteBackup(request)); +} + +std::shared_ptr +MakeSqlBackupsServiceTracingConnection( + std::shared_ptr conn) { + if (internal::TracingEnabled(conn->options())) { + conn = + std::make_shared(std::move(conn)); + } + return conn; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_backups_tracing_connection.h b/google/cloud/sql/v1/internal/sql_backups_tracing_connection.h new file mode 100644 index 0000000000000..3e768222feb98 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_backups_tracing_connection.h @@ -0,0 +1,75 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_TRACING_CONNECTION_H + +#include "google/cloud/sql/v1/sql_backups_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlBackupsServiceTracingConnection + : public sql_v1::SqlBackupsServiceConnection { + public: + ~SqlBackupsServiceTracingConnection() override = default; + + explicit SqlBackupsServiceTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StatusOr CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const& request) override; + + StatusOr GetBackup( + google::cloud::sql::v1::GetBackupRequest const& request) override; + + StreamRange ListBackups( + google::cloud::sql::v1::ListBackupsRequest request) override; + + StatusOr UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const& request) override; + + StatusOr DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const& request) override; + + private: + std::shared_ptr child_; +}; + +/** + * Conditionally applies the tracing decorator to the given connection. + * + * The connection is only decorated if tracing is enabled (as determined by the + * connection's options). + */ +std::shared_ptr +MakeSqlBackupsServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_BACKUPS_TRACING_CONNECTION_H diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.cc b/google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.cc new file mode 100644 index 0000000000000..55280c4813009 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.cc @@ -0,0 +1,71 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_connection.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_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 sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options SqlFeatureEligibilityServiceDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), + "GOOGLE_CLOUD_CPP_SQL_FEATURE_ELIGIBILITY_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_SQL_FEATURE_ELIGIBILITY_SERVICE_AUTHORITY", + "sqladmin.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + sql_v1::SqlFeatureEligibilityServiceLimitedTimeRetryPolicy( + std::chrono::minutes(10)) + .clone()); + } + if (!options.has()) { + options.set( + ExponentialBackoffPolicy( + std::chrono::seconds(0), std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling, kBackoffScaling) + .clone()); + } + if (!options.has< + sql_v1:: + SqlFeatureEligibilityServiceConnectionIdempotencyPolicyOption>()) { + options.set< + sql_v1::SqlFeatureEligibilityServiceConnectionIdempotencyPolicyOption>( + sql_v1:: + MakeDefaultSqlFeatureEligibilityServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.h b/google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.h new file mode 100644 index 0000000000000..b3d9789a54df9 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options SqlFeatureEligibilityServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_OPTION_DEFAULTS_H diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.cc b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.cc new file mode 100644 index 0000000000000..e4dd479f13245 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.cc @@ -0,0 +1,48 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/rest_retry_loop.h" +#include "google/cloud/rest_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlFeatureEligibilityServiceRestConnectionImpl:: + SqlFeatureEligibilityServiceRestConnectionImpl( + std::unique_ptr background, + std::shared_ptr + stub, + Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions( + std::move(options), + SqlFeatureEligibilityServiceConnection::options())) {} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.h b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.h new file mode 100644 index 0000000000000..a4a55b64d88b2 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.h @@ -0,0 +1,85 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_CONNECTION_IMPL_H + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_retry_traits.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_connection.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_options.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlFeatureEligibilityServiceRestConnectionImpl + : public sql_v1::SqlFeatureEligibilityServiceConnection { + public: + ~SqlFeatureEligibilityServiceRestConnectionImpl() override = default; + + SqlFeatureEligibilityServiceRestConnectionImpl( + std::unique_ptr background, + std::shared_ptr + stub, + Options options); + + Options options() override { return options_; } + + private: + static std::unique_ptr + retry_policy(Options const& options) { + return options.get() + ->clone(); + } + + static std::unique_ptr backoff_policy(Options const& options) { + return options + .get() + ->clone(); + } + + static std::unique_ptr< + sql_v1::SqlFeatureEligibilityServiceConnectionIdempotencyPolicy> + idempotency_policy(Options const& options) { + return options + .get< + sql_v1:: + SqlFeatureEligibilityServiceConnectionIdempotencyPolicyOption>() + ->clone(); + } + + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_CONNECTION_IMPL_H diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.cc b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.cc new file mode 100644 index 0000000000000..97d2abdc6a398 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.cc @@ -0,0 +1,41 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlFeatureEligibilityServiceRestLogging:: + SqlFeatureEligibilityServiceRestLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set components) + : child_(std::move(child)), + tracing_options_(std::move(tracing_options)), + components_(std::move(components)) {} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.h b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.h new file mode 100644 index 0000000000000..12cdd0a2b332d --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.h @@ -0,0 +1,56 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_LOGGING_DECORATOR_H + +#include "google/cloud/sql/v1/cloud_sql_feature_eligibility.pb.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h" +#include "google/cloud/future.h" +#include "google/cloud/internal/rest_context.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlFeatureEligibilityServiceRestLogging + : public SqlFeatureEligibilityServiceRestStub { + public: + ~SqlFeatureEligibilityServiceRestLogging() override = default; + SqlFeatureEligibilityServiceRestLogging( + std::shared_ptr child, + TracingOptions tracing_options, std::set components); + + private: + std::shared_ptr child_; + TracingOptions tracing_options_; + std::set components_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_LOGGING_DECORATOR_H diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.cc b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.cc new file mode 100644 index 0000000000000..5e689efd42e32 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.cc @@ -0,0 +1,53 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/internal/rest_set_metadata.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlFeatureEligibilityServiceRestMetadata:: + SqlFeatureEligibilityServiceRestMetadata( + std::shared_ptr child, + std::string api_client_header) + : child_(std::move(child)), + api_client_header_( + api_client_header.empty() + ? google::cloud::internal::GeneratedLibClientHeader() + : std::move(api_client_header)) {} + +void SqlFeatureEligibilityServiceRestMetadata::SetMetadata( + rest_internal::RestContext& rest_context, Options const& options, + std::vector const& params) { + google::cloud::rest_internal::SetMetadata(rest_context, options, params, + api_client_header_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.h b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.h new file mode 100644 index 0000000000000..f1bc09cf9ee4c --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.h @@ -0,0 +1,57 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_METADATA_DECORATOR_H + +#include "google/cloud/sql/v1/cloud_sql_feature_eligibility.pb.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h" +#include "google/cloud/future.h" +#include "google/cloud/rest_options.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlFeatureEligibilityServiceRestMetadata + : public SqlFeatureEligibilityServiceRestStub { + public: + ~SqlFeatureEligibilityServiceRestMetadata() override = default; + explicit SqlFeatureEligibilityServiceRestMetadata( + std::shared_ptr child, + std::string api_client_header = ""); + + private: + void SetMetadata(rest_internal::RestContext& rest_context, + Options const& options, + std::vector const& params = {}); + + std::shared_ptr child_; + std::string api_client_header_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_METADATA_DECORATOR_H diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.cc b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.cc new file mode 100644 index 0000000000000..99505f2228bb5 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.cc @@ -0,0 +1,47 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h" +#include "google/cloud/sql/v1/cloud_sql_feature_eligibility.pb.h" +#include "google/cloud/common_options.h" +#include "google/cloud/internal/rest_stub_helpers.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DefaultSqlFeatureEligibilityServiceRestStub:: + DefaultSqlFeatureEligibilityServiceRestStub(Options options) + : service_(rest_internal::MakePooledRestClient( + options.get(), options)), + options_(std::move(options)) {} + +DefaultSqlFeatureEligibilityServiceRestStub:: + DefaultSqlFeatureEligibilityServiceRestStub( + std::shared_ptr service, Options options) + : service_(std::move(service)), options_(std::move(options)) {} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h new file mode 100644 index 0000000000000..91014c2e49c10 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h @@ -0,0 +1,59 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_STUB_H + +#include "google/cloud/sql/v1/cloud_sql_feature_eligibility.pb.h" +#include "google/cloud/completion_queue.h" +#include "google/cloud/internal/rest_client.h" +#include "google/cloud/internal/rest_context.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlFeatureEligibilityServiceRestStub { + public: + virtual ~SqlFeatureEligibilityServiceRestStub() = default; +}; + +class DefaultSqlFeatureEligibilityServiceRestStub + : public SqlFeatureEligibilityServiceRestStub { + public: + ~DefaultSqlFeatureEligibilityServiceRestStub() override = default; + + explicit DefaultSqlFeatureEligibilityServiceRestStub(Options options); + DefaultSqlFeatureEligibilityServiceRestStub( + std::shared_ptr service, Options options); + + private: + std::shared_ptr service_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_STUB_H diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.cc b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.cc new file mode 100644 index 0000000000000..59cefae19d46e --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.cc @@ -0,0 +1,58 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h" +#include "google/cloud/common_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/populate_rest_options.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include "google/cloud/rest_options.h" +#include "absl/strings/match.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +CreateDefaultSqlFeatureEligibilityServiceRestStub(Options const& options) { + auto opts = internal::PopulateRestOptions(options); + std::shared_ptr stub = + std::make_shared( + std::move(opts)); + stub = std::make_shared( + std::move(stub)); + if (internal::Contains(options.get(), "rpc")) { + GCP_LOG(INFO) << "Enabled logging for REST rpc calls"; + stub = std::make_shared( + std::move(stub), options.get(), + options.get()); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.h b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.h new file mode 100644 index 0000000000000..79295d1402142 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.h @@ -0,0 +1,40 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_STUB_FACTORY_H + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +CreateDefaultSqlFeatureEligibilityServiceRestStub(Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_REST_STUB_FACTORY_H diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_retry_traits.h b/google/cloud/sql/v1/internal/sql_feature_eligibility_retry_traits.h new file mode 100644 index 0000000000000..c658d1796f4c6 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct SqlFeatureEligibilityServiceRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_RETRY_TRAITS_H diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_sources.cc b/google/cloud/sql/v1/internal/sql_feature_eligibility_sources.cc new file mode 100644 index 0000000000000..823b073a04e5d --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_sources.cc @@ -0,0 +1,31 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.cc" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.cc" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_logging_decorator.cc" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_metadata_decorator.cc" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub.cc" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.cc" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.cc" +#include "google/cloud/sql/v1/sql_feature_eligibility_client.cc" +#include "google/cloud/sql/v1/sql_feature_eligibility_connection.cc" +#include "google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.cc" +#include "google/cloud/sql/v1/sql_feature_eligibility_rest_connection.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.cc b/google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.cc new file mode 100644 index 0000000000000..188f6cdb130c3 --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.cc @@ -0,0 +1,47 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlFeatureEligibilityServiceTracingConnection:: + SqlFeatureEligibilityServiceTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +std::shared_ptr +MakeSqlFeatureEligibilityServiceTracingConnection( + std::shared_ptr conn) { + if (internal::TracingEnabled(conn->options())) { + conn = std::make_shared( + std::move(conn)); + } + return conn; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.h b/google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.h new file mode 100644 index 0000000000000..67b8d9f89aa3a --- /dev/null +++ b/google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.h @@ -0,0 +1,60 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_TRACING_CONNECTION_H + +#include "google/cloud/sql/v1/sql_feature_eligibility_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlFeatureEligibilityServiceTracingConnection + : public sql_v1::SqlFeatureEligibilityServiceConnection { + public: + ~SqlFeatureEligibilityServiceTracingConnection() override = default; + + explicit SqlFeatureEligibilityServiceTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + private: + std::shared_ptr child_; +}; + +/** + * Conditionally applies the tracing decorator to the given connection. + * + * The connection is only decorated if tracing is enabled (as determined by the + * connection's options). + */ +std::shared_ptr +MakeSqlFeatureEligibilityServiceTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_INTERNAL_SQL_FEATURE_ELIGIBILITY_TRACING_CONNECTION_H diff --git a/google/cloud/sql/v1/mocks/mock_sql_backups_connection.h b/google/cloud/sql/v1/mocks/mock_sql_backups_connection.h new file mode 100644 index 0000000000000..94aba5eba400f --- /dev/null +++ b/google/cloud/sql/v1/mocks/mock_sql_backups_connection.h @@ -0,0 +1,75 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_MOCKS_MOCK_SQL_BACKUPS_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_MOCKS_MOCK_SQL_BACKUPS_CONNECTION_H + +#include "google/cloud/sql/v1/sql_backups_connection.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `SqlBackupsServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `SqlBackupsServiceClient`. To do so, + * construct an object of type `SqlBackupsServiceClient` 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 MockSqlBackupsServiceConnection + : public sql_v1::SqlBackupsServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD(StatusOr, CreateBackup, + (google::cloud::sql::v1::CreateBackupRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetBackup, + (google::cloud::sql::v1::GetBackupRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListBackups, + (google::cloud::sql::v1::ListBackupsRequest request), (override)); + + MOCK_METHOD(StatusOr, UpdateBackup, + (google::cloud::sql::v1::UpdateBackupRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, DeleteBackup, + (google::cloud::sql::v1::DeleteBackupRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_MOCKS_MOCK_SQL_BACKUPS_CONNECTION_H diff --git a/google/cloud/sql/v1/mocks/mock_sql_feature_eligibility_connection.h b/google/cloud/sql/v1/mocks/mock_sql_feature_eligibility_connection.h new file mode 100644 index 0000000000000..fd08a90f901f7 --- /dev/null +++ b/google/cloud/sql/v1/mocks/mock_sql_feature_eligibility_connection.h @@ -0,0 +1,56 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_MOCKS_MOCK_SQL_FEATURE_ELIGIBILITY_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_MOCKS_MOCK_SQL_FEATURE_ELIGIBILITY_CONNECTION_H + +#include "google/cloud/sql/v1/sql_feature_eligibility_connection.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `SqlFeatureEligibilityServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type + * `SqlFeatureEligibilityServiceClient`. To do so, construct an object of type + * `SqlFeatureEligibilityServiceClient` 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 MockSqlFeatureEligibilityServiceConnection + : public sql_v1::SqlFeatureEligibilityServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_MOCKS_MOCK_SQL_FEATURE_ELIGIBILITY_CONNECTION_H diff --git a/google/cloud/sql/v1/samples/sql_backups_client_samples.cc b/google/cloud/sql/v1/samples/sql_backups_client_samples.cc new file mode 100644 index 0000000000000..6a4bd16518ee2 --- /dev/null +++ b/google/cloud/sql/v1/samples/sql_backups_client_samples.cc @@ -0,0 +1,181 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/sql_backups_client.h" +#include "google/cloud/sql/v1/sql_backups_connection_idempotency_policy.h" +#include "google/cloud/sql/v1/sql_backups_options.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/getenv.h" +#include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" +#include +#include +#include +#include + +// clang-format off +// main-dox-marker: sql_v1::SqlBackupsServiceClient +// clang-format on +namespace { + +void SetClientEndpoint(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-endpoint"}; + } + //! [set-client-endpoint] + // This configuration is common with Private Google Access: + // https://cloud.google.com/vpc/docs/private-google-access + auto options = google::cloud::Options{}.set( + "private.googleapis.com"); + auto vpc_client = google::cloud::sql_v1::SqlBackupsServiceClient( + google::cloud::sql_v1::MakeSqlBackupsServiceConnectionRest(options)); + //! [set-client-endpoint] +} + +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlBackupsServiceClient( + google::cloud::sql_v1::MakeSqlBackupsServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::sql_v1:: + SqlBackupsServiceConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr< + google::cloud::sql_v1::SqlBackupsServiceConnectionIdempotencyPolicy> + 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::sql_v1:: + SqlBackupsServiceLimitedErrorCountRetryPolicy(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::sql_v1::MakeSqlBackupsServiceConnectionRest(options); + + // c1 and c2 share the same retry policies + auto c1 = google::cloud::sql_v1::SqlBackupsServiceClient(connection); + auto c2 = google::cloud::sql_v1::SqlBackupsServiceClient(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::sql_v1::SqlBackupsServiceClient( + connection, + google::cloud::Options{} + .set( + google::cloud::sql_v1::SqlBackupsServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::sql_v1::SqlBackupsServiceLimitedErrorCountRetryPolicy(10).clone())); + //! [set-retry-policy] +} + +void WithServiceAccount(std::vector const& argv) { + if (argv.size() != 1 || argv[0] == "--help") { + throw google::cloud::testing_util::Usage{"with-service-account "}; + } + //! [with-service-account] + [](std::string const& keyfile) { + auto is = std::ifstream(keyfile); + is.exceptions(std::ios::badbit); // Minimal error handling in examples + auto contents = std::string(std::istreambuf_iterator(is.rdbuf()), {}); + auto options = + google::cloud::Options{}.set( + google::cloud::MakeServiceAccountCredentials(contents)); + return google::cloud::sql_v1::SqlBackupsServiceClient( + google::cloud::sql_v1::MakeSqlBackupsServiceConnectionRest(options)); + } + //! [with-service-account] + (argv.at(0)); +} + +void AutoRun(std::vector const& argv) { + namespace examples = ::google::cloud::testing_util; + using ::google::cloud::internal::GetEnv; + if (!argv.empty()) throw examples::Usage{"auto"}; + examples::CheckEnvironmentVariablesAreSet( + {"GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE"}); + auto const keyfile = + GetEnv("GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE").value(); + + std::cout << "\nRunning SetClientEndpoint() example" << std::endl; + SetClientEndpoint({}); + + std::cout << "\nRunning SetRetryPolicy() example" << std::endl; + SetRetryPolicy({}); + + std::cout << "\nRunning WithServiceAccount() example" << std::endl; + WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); +} + +} // namespace + +int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) + google::cloud::testing_util::Example example({ + {"set-client-endpoint", SetClientEndpoint}, + {"set-retry-policy", SetRetryPolicy}, + {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, + {"auto", AutoRun}, + }); + return example.Run(argc, argv); +} diff --git a/google/cloud/sql/v1/samples/sql_feature_eligibility_client_samples.cc b/google/cloud/sql/v1/samples/sql_feature_eligibility_client_samples.cc new file mode 100644 index 0000000000000..b6e63baa2d360 --- /dev/null +++ b/google/cloud/sql/v1/samples/sql_feature_eligibility_client_samples.cc @@ -0,0 +1,192 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/sql_feature_eligibility_client.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_options.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/getenv.h" +#include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" +#include +#include +#include +#include + +// clang-format off +// main-dox-marker: sql_v1::SqlFeatureEligibilityServiceClient +// clang-format on +namespace { + +void SetClientEndpoint(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-endpoint"}; + } + //! [set-client-endpoint] + // This configuration is common with Private Google Access: + // https://cloud.google.com/vpc/docs/private-google-access + auto options = google::cloud::Options{}.set( + "private.googleapis.com"); + auto vpc_client = google::cloud::sql_v1::SqlFeatureEligibilityServiceClient( + google::cloud::sql_v1::MakeSqlFeatureEligibilityServiceConnectionRest( + options)); + //! [set-client-endpoint] +} + +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlFeatureEligibilityServiceClient( + google::cloud::sql_v1::MakeSqlFeatureEligibilityServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::sql_v1:: + SqlFeatureEligibilityServiceConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr + clone() const override { + return std::make_unique(*this); + } + // Override inherited functions to define as needed. +}; +//! [custom-idempotency-policy] + +void SetRetryPolicy(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-retry-policy"}; + } + //! [set-retry-policy] + auto options = + google::cloud::Options{} + .set< + google::cloud::sql_v1:: + SqlFeatureEligibilityServiceConnectionIdempotencyPolicyOption>( + CustomIdempotencyPolicy().clone()) + .set( + google::cloud::sql_v1:: + SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy(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::sql_v1::MakeSqlFeatureEligibilityServiceConnectionRest( + options); + + // c1 and c2 share the same retry policies + auto c1 = + google::cloud::sql_v1::SqlFeatureEligibilityServiceClient(connection); + auto c2 = + google::cloud::sql_v1::SqlFeatureEligibilityServiceClient(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::sql_v1::SqlFeatureEligibilityServiceClient( + connection, + google::cloud::Options{} + .set( + google::cloud::sql_v1:: + SqlFeatureEligibilityServiceLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::sql_v1::SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy(10).clone())); + //! [set-retry-policy] +} + +void WithServiceAccount(std::vector const& argv) { + if (argv.size() != 1 || argv[0] == "--help") { + throw google::cloud::testing_util::Usage{"with-service-account "}; + } + //! [with-service-account] + [](std::string const& keyfile) { + auto is = std::ifstream(keyfile); + is.exceptions(std::ios::badbit); // Minimal error handling in examples + auto contents = std::string(std::istreambuf_iterator(is.rdbuf()), {}); + auto options = + google::cloud::Options{}.set( + google::cloud::MakeServiceAccountCredentials(contents)); + return google::cloud::sql_v1::SqlFeatureEligibilityServiceClient( + google::cloud::sql_v1::MakeSqlFeatureEligibilityServiceConnectionRest( + options)); + } + //! [with-service-account] + (argv.at(0)); +} + +void AutoRun(std::vector const& argv) { + namespace examples = ::google::cloud::testing_util; + using ::google::cloud::internal::GetEnv; + if (!argv.empty()) throw examples::Usage{"auto"}; + examples::CheckEnvironmentVariablesAreSet( + {"GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE"}); + auto const keyfile = + GetEnv("GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE").value(); + + std::cout << "\nRunning SetClientEndpoint() example" << std::endl; + SetClientEndpoint({}); + + std::cout << "\nRunning SetRetryPolicy() example" << std::endl; + SetRetryPolicy({}); + + std::cout << "\nRunning WithServiceAccount() example" << std::endl; + WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); +} + +} // namespace + +int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) + google::cloud::testing_util::Example example({ + {"set-client-endpoint", SetClientEndpoint}, + {"set-retry-policy", SetRetryPolicy}, + {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, + {"auto", AutoRun}, + }); + return example.Run(argc, argv); +} diff --git a/google/cloud/sql/v1/sql_backups_client.cc b/google/cloud/sql/v1/sql_backups_client.cc new file mode 100644 index 0000000000000..9c9bf125064c6 --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_client.cc @@ -0,0 +1,118 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/sql_backups_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlBackupsServiceClient::SqlBackupsServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +SqlBackupsServiceClient::~SqlBackupsServiceClient() = default; + +StatusOr +SqlBackupsServiceClient::CreateBackup( + std::string const& parent, google::cloud::sql::v1::Backup const& backup, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::sql::v1::CreateBackupRequest request; + request.set_parent(parent); + *request.mutable_backup() = backup; + return connection_->CreateBackup(request); +} + +StatusOr +SqlBackupsServiceClient::CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateBackup(request); +} + +StatusOr SqlBackupsServiceClient::GetBackup( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::sql::v1::GetBackupRequest request; + request.set_name(name); + return connection_->GetBackup(request); +} + +StatusOr SqlBackupsServiceClient::GetBackup( + google::cloud::sql::v1::GetBackupRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetBackup(request); +} + +StreamRange +SqlBackupsServiceClient::ListBackups(std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::sql::v1::ListBackupsRequest request; + request.set_parent(parent); + return connection_->ListBackups(request); +} + +StreamRange +SqlBackupsServiceClient::ListBackups( + google::cloud::sql::v1::ListBackupsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListBackups(std::move(request)); +} + +StatusOr +SqlBackupsServiceClient::UpdateBackup( + google::cloud::sql::v1::Backup const& backup, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::sql::v1::UpdateBackupRequest request; + *request.mutable_backup() = backup; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateBackup(request); +} + +StatusOr +SqlBackupsServiceClient::UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateBackup(request); +} + +StatusOr +SqlBackupsServiceClient::DeleteBackup(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::sql::v1::DeleteBackupRequest request; + request.set_name(name); + return connection_->DeleteBackup(request); +} + +StatusOr +SqlBackupsServiceClient::DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteBackup(request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/sql_backups_client.h b/google/cloud/sql/v1/sql_backups_client.h new file mode 100644 index 0000000000000..bf24f416f6b27 --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_client.h @@ -0,0 +1,411 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CLIENT_H + +#include "google/cloud/sql/v1/sql_backups_rest_connection.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// SqlBackupsServiceClient +/// +/// @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 SqlBackupsServiceClient { + public: + explicit SqlBackupsServiceClient( + std::shared_ptr connection, + Options opts = {}); + ~SqlBackupsServiceClient(); + + ///@{ + /// @name Copy and move support + SqlBackupsServiceClient(SqlBackupsServiceClient const&) = default; + SqlBackupsServiceClient& operator=(SqlBackupsServiceClient const&) = default; + SqlBackupsServiceClient(SqlBackupsServiceClient&&) = default; + SqlBackupsServiceClient& operator=(SqlBackupsServiceClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(SqlBackupsServiceClient const& a, + SqlBackupsServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(SqlBackupsServiceClient const& a, + SqlBackupsServiceClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Creates a backup for a Cloud SQL instance. This API can be used only to + /// create on-demand backups. + /// + /// @param parent Required. The parent resource where this backup is created. + /// Format: projects/{project} + /// @param backup Required. The Backup to create. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.sql.v1.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.cloud.sql.v1.CreateBackupRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L88} + /// [google.cloud.sql.v1.Operation]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_resources.proto#L1226} + /// + // clang-format on + StatusOr CreateBackup( + std::string const& parent, google::cloud::sql::v1::Backup const& backup, + Options opts = {}); + + // clang-format off + /// + /// Creates a backup for a Cloud SQL instance. This API can be used only to + /// create on-demand backups. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.sql.v1.CreateBackupRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.sql.v1.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.cloud.sql.v1.CreateBackupRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L88} + /// [google.cloud.sql.v1.Operation]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_resources.proto#L1226} + /// + // clang-format on + StatusOr CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Retrieves a resource containing information about a backup. + /// + /// @param name Required. The name of the backup to retrieve. + /// Format: projects/{project}/backups/{backup} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.sql.v1.Backup]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.sql.v1.Backup]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L181} + /// [google.cloud.sql.v1.GetBackupRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L103} + /// + // clang-format on + StatusOr GetBackup(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Retrieves a resource containing information about a backup. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.sql.v1.GetBackupRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.sql.v1.Backup]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.sql.v1.Backup]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L181} + /// [google.cloud.sql.v1.GetBackupRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L103} + /// + // clang-format on + StatusOr GetBackup( + google::cloud::sql::v1::GetBackupRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists all backups associated with the project. + /// + /// @param parent Required. The parent that owns this collection of backups. + /// Format: projects/{project} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.sql.v1.Backup], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.sql.v1.Backup]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L181} + /// [google.cloud.sql.v1.ListBackupsRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L113} + /// + // clang-format on + StreamRange ListBackups( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists all backups associated with the project. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.sql.v1.ListBackupsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.sql.v1.Backup], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.sql.v1.Backup]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L181} + /// [google.cloud.sql.v1.ListBackupsRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L113} + /// + // clang-format on + StreamRange ListBackups( + google::cloud::sql::v1::ListBackupsRequest request, Options opts = {}); + + // clang-format off + /// + /// Updates the retention period and description of the backup. You can use + /// this API to update final backups only. + /// + /// @param backup Required. The backup to update. + /// The backup’s `name` field is used to identify the backup to update. + /// Format: projects/{project}/backups/{backup} + /// @param update_mask The list of fields that you can update. You can update only the description + /// and retention period of the final backup. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.sql.v1.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.cloud.sql.v1.Operation]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_resources.proto#L1226} + /// [google.cloud.sql.v1.UpdateBackupRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L159} + /// + // clang-format on + StatusOr UpdateBackup( + google::cloud::sql::v1::Backup const& backup, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the retention period and description of the backup. You can use + /// this API to update final backups only. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.sql.v1.UpdateBackupRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.sql.v1.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.cloud.sql.v1.Operation]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_resources.proto#L1226} + /// [google.cloud.sql.v1.UpdateBackupRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L159} + /// + // clang-format on + StatusOr UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes the backup. + /// + /// @param name Required. The name of the backup to delete. + /// Format: projects/{project}/backups/{backup} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.sql.v1.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.cloud.sql.v1.DeleteBackupRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L171} + /// [google.cloud.sql.v1.Operation]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_resources.proto#L1226} + /// + // clang-format on + StatusOr DeleteBackup( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes the backup. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.sql.v1.DeleteBackupRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.sql.v1.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.cloud.sql.v1.DeleteBackupRequest]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_backups.proto#L171} + /// [google.cloud.sql.v1.Operation]: @googleapis_reference_link{google/cloud/sql/v1/cloud_sql_resources.proto#L1226} + /// + // clang-format on + StatusOr DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const& request, + Options opts = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CLIENT_H diff --git a/google/cloud/sql/v1/sql_backups_connection.cc b/google/cloud/sql/v1/sql_backups_connection.cc new file mode 100644 index 0000000000000..c7cfc80f6b545 --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_connection.cc @@ -0,0 +1,73 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/sql_backups_connection.h" +#include "google/cloud/sql/v1/internal/sql_backups_option_defaults.h" +#include "google/cloud/sql/v1/internal/sql_backups_tracing_connection.h" +#include "google/cloud/sql/v1/sql_backups_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 sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlBackupsServiceConnection::~SqlBackupsServiceConnection() = default; + +StatusOr +SqlBackupsServiceConnection::CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr SqlBackupsServiceConnection::GetBackup( + google::cloud::sql::v1::GetBackupRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +SqlBackupsServiceConnection::ListBackups( + google::cloud::sql::v1:: + ListBackupsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SqlBackupsServiceConnection::UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SqlBackupsServiceConnection::DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/sql_backups_connection.h b/google/cloud/sql/v1/sql_backups_connection.h new file mode 100644 index 0000000000000..e3efc4cbfaa6a --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_connection.h @@ -0,0 +1,207 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CONNECTION_H + +#include "google/cloud/sql/v1/cloud_sql_backups.pb.h" +#include "google/cloud/sql/v1/internal/sql_backups_retry_traits.h" +#include "google/cloud/sql/v1/sql_backups_connection_idempotency_policy.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/internal/retry_policy_impl.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `SqlBackupsServiceConnection`. +class SqlBackupsServiceRetryPolicy : 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 `SqlBackupsServiceConnection` 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 SqlBackupsServiceLimitedErrorCountRetryPolicy + : public SqlBackupsServiceRetryPolicy { + 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 SqlBackupsServiceLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + SqlBackupsServiceLimitedErrorCountRetryPolicy( + SqlBackupsServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : SqlBackupsServiceLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + SqlBackupsServiceLimitedErrorCountRetryPolicy( + SqlBackupsServiceLimitedErrorCountRetryPolicy const& rhs) noexcept + : SqlBackupsServiceLimitedErrorCountRetryPolicy(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 = SqlBackupsServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + sql_v1_internal::SqlBackupsServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `SqlBackupsServiceConnection` 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 SqlBackupsServiceLimitedTimeRetryPolicy + : public SqlBackupsServiceRetryPolicy { + 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 SqlBackupsServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + SqlBackupsServiceLimitedTimeRetryPolicy( + SqlBackupsServiceLimitedTimeRetryPolicy&& rhs) noexcept + : SqlBackupsServiceLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + SqlBackupsServiceLimitedTimeRetryPolicy( + SqlBackupsServiceLimitedTimeRetryPolicy const& rhs) noexcept + : SqlBackupsServiceLimitedTimeRetryPolicy(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 = SqlBackupsServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + sql_v1_internal::SqlBackupsServiceRetryTraits> + impl_; +}; + +/** + * The `SqlBackupsServiceConnection` object for `SqlBackupsServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `SqlBackupsServiceClient`. This allows users to inject custom + * behavior (e.g., with a Google Mock object) when writing tests that use + * objects of type `SqlBackupsServiceClient`. + * + * To create a concrete instance, see `MakeSqlBackupsServiceConnection()`. + * + * For mocking, see `sql_v1_mocks::MockSqlBackupsServiceConnection`. + */ +class SqlBackupsServiceConnection { + public: + virtual ~SqlBackupsServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StatusOr CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const& request); + + virtual StatusOr GetBackup( + google::cloud::sql::v1::GetBackupRequest const& request); + + virtual StreamRange ListBackups( + google::cloud::sql::v1::ListBackupsRequest request); + + virtual StatusOr UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const& request); + + virtual StatusOr DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const& request); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CONNECTION_H diff --git a/google/cloud/sql/v1/sql_backups_connection_idempotency_policy.cc b/google/cloud/sql/v1/sql_backups_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..dc7c88b73f41f --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_connection_idempotency_policy.cc @@ -0,0 +1,70 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/sql_backups_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +SqlBackupsServiceConnectionIdempotencyPolicy:: + ~SqlBackupsServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +SqlBackupsServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency SqlBackupsServiceConnectionIdempotencyPolicy::CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SqlBackupsServiceConnectionIdempotencyPolicy::GetBackup( + google::cloud::sql::v1::GetBackupRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SqlBackupsServiceConnectionIdempotencyPolicy::ListBackups( + google::cloud::sql::v1::ListBackupsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SqlBackupsServiceConnectionIdempotencyPolicy::UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency SqlBackupsServiceConnectionIdempotencyPolicy::DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultSqlBackupsServiceConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/sql_backups_connection_idempotency_policy.h b/google/cloud/sql/v1/sql_backups_connection_idempotency_policy.h new file mode 100644 index 0000000000000..6e37887a3e2f2 --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_connection_idempotency_policy.h @@ -0,0 +1,64 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/sql/v1/cloud_sql_backups.pb.h" +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlBackupsServiceConnectionIdempotencyPolicy { + public: + virtual ~SqlBackupsServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() + const; + + virtual google::cloud::Idempotency CreateBackup( + google::cloud::sql::v1::CreateBackupRequest const& request); + + virtual google::cloud::Idempotency GetBackup( + google::cloud::sql::v1::GetBackupRequest const& request); + + virtual google::cloud::Idempotency ListBackups( + google::cloud::sql::v1::ListBackupsRequest request); + + virtual google::cloud::Idempotency UpdateBackup( + google::cloud::sql::v1::UpdateBackupRequest const& request); + + virtual google::cloud::Idempotency DeleteBackup( + google::cloud::sql::v1::DeleteBackupRequest const& request); +}; + +std::unique_ptr +MakeDefaultSqlBackupsServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/sql/v1/sql_backups_options.h b/google/cloud/sql/v1/sql_backups_options.h new file mode 100644 index 0000000000000..ef1d1e09e9ce2 --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_options.h @@ -0,0 +1,76 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_OPTIONS_H + +#include "google/cloud/sql/v1/sql_backups_connection.h" +#include "google/cloud/sql/v1/sql_backups_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 sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-sql-options + */ +struct SqlBackupsServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-sql-options + */ +struct SqlBackupsServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-sql-options + */ +struct SqlBackupsServiceConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to SqlBackupsService. + * + * @ingroup google-cloud-sql-options + */ +using SqlBackupsServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_OPTIONS_H diff --git a/google/cloud/sql/v1/sql_backups_rest_connection.cc b/google/cloud/sql/v1/sql_backups_rest_connection.cc new file mode 100644 index 0000000000000..6010531028615 --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_rest_connection.cc @@ -0,0 +1,56 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#include "google/cloud/sql/v1/sql_backups_rest_connection.h" +#include "google/cloud/sql/v1/internal/sql_backups_option_defaults.h" +#include "google/cloud/sql/v1/internal/sql_backups_rest_connection_impl.h" +#include "google/cloud/sql/v1/internal/sql_backups_rest_stub_factory.h" +#include "google/cloud/sql/v1/internal/sql_backups_tracing_connection.h" +#include "google/cloud/sql/v1/sql_backups_options.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/rest_background_threads_impl.h" +#include "google/cloud/internal/rest_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +MakeSqlBackupsServiceConnectionRest(Options options) { + internal::CheckExpectedOptions< + CommonOptionList, RestOptionList, UnifiedCredentialsOptionList, + rest_internal::TargetApiVersionOption, SqlBackupsServicePolicyOptionList>( + options, __func__); + options = + sql_v1_internal::SqlBackupsServiceDefaultOptions(std::move(options)); + auto background = std::make_unique< + rest_internal::AutomaticallyCreatedRestBackgroundThreads>(); + auto stub = sql_v1_internal::CreateDefaultSqlBackupsServiceRestStub(options); + return sql_v1_internal::MakeSqlBackupsServiceTracingConnection( + std::make_shared( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/sql_backups_rest_connection.h b/google/cloud/sql/v1/sql_backups_rest_connection.h new file mode 100644 index 0000000000000..ee8c4100f26f0 --- /dev/null +++ b/google/cloud/sql/v1/sql_backups_rest_connection.h @@ -0,0 +1,65 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_backups.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_REST_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_REST_CONNECTION_H + +#include "google/cloud/sql/v1/sql_backups_connection.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A factory function to construct an object of type + * `SqlBackupsServiceConnection` that uses REST over HTTP as transport in lieu + * of gRPC. REST transport should only be used for services that do not support + * gRPC or if the existing network configuration precludes using gRPC. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of + * SqlBackupsServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `SqlBackupsServiceConnection`. Expected options are any of the types + * in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::RestOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::sql_v1::SqlBackupsServicePolicyOptionList` + * + * @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 `SqlBackupsServiceConnection` created + * by this function. + */ +std::shared_ptr +MakeSqlBackupsServiceConnectionRest(Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_BACKUPS_REST_CONNECTION_H diff --git a/google/cloud/sql/v1/sql_feature_eligibility_client.cc b/google/cloud/sql/v1/sql_feature_eligibility_client.cc new file mode 100644 index 0000000000000..4ab7a8c3914bf --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_client.cc @@ -0,0 +1,40 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/sql_feature_eligibility_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlFeatureEligibilityServiceClient::SqlFeatureEligibilityServiceClient( + std::shared_ptr connection, + Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +SqlFeatureEligibilityServiceClient::~SqlFeatureEligibilityServiceClient() = + default; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/sql_feature_eligibility_client.h b/google/cloud/sql/v1/sql_feature_eligibility_client.h new file mode 100644 index 0000000000000..2dc158845be28 --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_client.h @@ -0,0 +1,103 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CLIENT_H + +#include "google/cloud/sql/v1/sql_feature_eligibility_rest_connection.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Service to verify the eligibility of an instance for a given operation. +/// +/// @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 SqlFeatureEligibilityServiceClient { + public: + explicit SqlFeatureEligibilityServiceClient( + std::shared_ptr connection, + Options opts = {}); + ~SqlFeatureEligibilityServiceClient(); + + ///@{ + /// @name Copy and move support + SqlFeatureEligibilityServiceClient( + SqlFeatureEligibilityServiceClient const&) = default; + SqlFeatureEligibilityServiceClient& operator=( + SqlFeatureEligibilityServiceClient const&) = default; + SqlFeatureEligibilityServiceClient(SqlFeatureEligibilityServiceClient&&) = + default; + SqlFeatureEligibilityServiceClient& operator=( + SqlFeatureEligibilityServiceClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(SqlFeatureEligibilityServiceClient const& a, + SqlFeatureEligibilityServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(SqlFeatureEligibilityServiceClient const& a, + SqlFeatureEligibilityServiceClient const& b) { + return !(a == b); + } + ///@} + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CLIENT_H diff --git a/google/cloud/sql/v1/sql_feature_eligibility_connection.cc b/google/cloud/sql/v1/sql_feature_eligibility_connection.cc new file mode 100644 index 0000000000000..ec0d3c448fc0a --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_connection.cc @@ -0,0 +1,42 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/sql_feature_eligibility_connection.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_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/unified_grpc_credentials.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +SqlFeatureEligibilityServiceConnection:: + ~SqlFeatureEligibilityServiceConnection() = default; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/sql_feature_eligibility_connection.h b/google/cloud/sql/v1/sql_feature_eligibility_connection.h new file mode 100644 index 0000000000000..58fe9d1149929 --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_connection.h @@ -0,0 +1,206 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CONNECTION_H + +#include "google/cloud/sql/v1/cloud_sql_feature_eligibility.pb.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_retry_traits.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/internal/retry_policy_impl.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `SqlFeatureEligibilityServiceConnection`. +class SqlFeatureEligibilityServiceRetryPolicy + : 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 `SqlFeatureEligibilityServiceConnection` 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 SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy + : public SqlFeatureEligibilityServiceRetryPolicy { + 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 SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy( + int maximum_failures) + : impl_(maximum_failures) {} + + SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy( + SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy&& rhs) noexcept + : SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy( + rhs.maximum_failures()) {} + SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy( + SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy const& + rhs) noexcept + : SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy( + 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< + SqlFeatureEligibilityServiceLimitedErrorCountRetryPolicy>( + maximum_failures()); + } + + // This is provided only for backwards compatibility. + using BaseType = SqlFeatureEligibilityServiceRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + sql_v1_internal::SqlFeatureEligibilityServiceRetryTraits> + impl_; +}; + +/** + * A retry policy for `SqlFeatureEligibilityServiceConnection` 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 SqlFeatureEligibilityServiceLimitedTimeRetryPolicy + : public SqlFeatureEligibilityServiceRetryPolicy { + 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 SqlFeatureEligibilityServiceLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + SqlFeatureEligibilityServiceLimitedTimeRetryPolicy( + SqlFeatureEligibilityServiceLimitedTimeRetryPolicy&& rhs) noexcept + : SqlFeatureEligibilityServiceLimitedTimeRetryPolicy( + rhs.maximum_duration()) {} + SqlFeatureEligibilityServiceLimitedTimeRetryPolicy( + SqlFeatureEligibilityServiceLimitedTimeRetryPolicy const& rhs) noexcept + : SqlFeatureEligibilityServiceLimitedTimeRetryPolicy( + 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 = SqlFeatureEligibilityServiceRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + sql_v1_internal::SqlFeatureEligibilityServiceRetryTraits> + impl_; +}; + +/** + * The `SqlFeatureEligibilityServiceConnection` object for + * `SqlFeatureEligibilityServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `SqlFeatureEligibilityServiceClient`. This allows users to inject + * custom behavior (e.g., with a Google Mock object) when writing tests that use + * objects of type `SqlFeatureEligibilityServiceClient`. + * + * To create a concrete instance, see + * `MakeSqlFeatureEligibilityServiceConnection()`. + * + * For mocking, see `sql_v1_mocks::MockSqlFeatureEligibilityServiceConnection`. + */ +class SqlFeatureEligibilityServiceConnection { + public: + virtual ~SqlFeatureEligibilityServiceConnection() = 0; + + virtual Options options() { return Options{}; } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CONNECTION_H diff --git a/google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.cc b/google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..28da1a710f8a8 --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.cc @@ -0,0 +1,47 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +SqlFeatureEligibilityServiceConnectionIdempotencyPolicy:: + ~SqlFeatureEligibilityServiceConnectionIdempotencyPolicy() = default; + +std::unique_ptr +SqlFeatureEligibilityServiceConnectionIdempotencyPolicy::clone() const { + return std::make_unique< + SqlFeatureEligibilityServiceConnectionIdempotencyPolicy>(*this); +} + +std::unique_ptr +MakeDefaultSqlFeatureEligibilityServiceConnectionIdempotencyPolicy() { + return std::make_unique< + SqlFeatureEligibilityServiceConnectionIdempotencyPolicy>(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.h b/google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.h new file mode 100644 index 0000000000000..75fcb6cb20c61 --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_connection_idempotency_policy.h @@ -0,0 +1,50 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/sql/v1/cloud_sql_feature_eligibility.pb.h" +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class SqlFeatureEligibilityServiceConnectionIdempotencyPolicy { + public: + virtual ~SqlFeatureEligibilityServiceConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr< + SqlFeatureEligibilityServiceConnectionIdempotencyPolicy> + clone() const; +}; + +std::unique_ptr +MakeDefaultSqlFeatureEligibilityServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/sql/v1/sql_feature_eligibility_options.h b/google/cloud/sql/v1/sql_feature_eligibility_options.h new file mode 100644 index 0000000000000..1a542e4439451 --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_options.h @@ -0,0 +1,77 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_OPTIONS_H + +#include "google/cloud/sql/v1/sql_feature_eligibility_connection.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_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 sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-sql-options + */ +struct SqlFeatureEligibilityServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-sql-options + */ +struct SqlFeatureEligibilityServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-sql-options + */ +struct SqlFeatureEligibilityServiceConnectionIdempotencyPolicyOption { + using Type = + std::shared_ptr; +}; + +/** + * The options applicable to SqlFeatureEligibilityService. + * + * @ingroup google-cloud-sql-options + */ +using SqlFeatureEligibilityServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_OPTIONS_H diff --git a/google/cloud/sql/v1/sql_feature_eligibility_rest_connection.cc b/google/cloud/sql/v1/sql_feature_eligibility_rest_connection.cc new file mode 100644 index 0000000000000..fa84b881a28da --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_rest_connection.cc @@ -0,0 +1,60 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#include "google/cloud/sql/v1/sql_feature_eligibility_rest_connection.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_option_defaults.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_connection_impl.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_rest_stub_factory.h" +#include "google/cloud/sql/v1/internal/sql_feature_eligibility_tracing_connection.h" +#include "google/cloud/sql/v1/sql_feature_eligibility_options.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/rest_background_threads_impl.h" +#include "google/cloud/internal/rest_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr +MakeSqlFeatureEligibilityServiceConnectionRest(Options options) { + internal::CheckExpectedOptions( + options, __func__); + options = sql_v1_internal::SqlFeatureEligibilityServiceDefaultOptions( + std::move(options)); + auto background = std::make_unique< + rest_internal::AutomaticallyCreatedRestBackgroundThreads>(); + auto stub = + sql_v1_internal::CreateDefaultSqlFeatureEligibilityServiceRestStub( + options); + return sql_v1_internal::MakeSqlFeatureEligibilityServiceTracingConnection( + std::make_shared< + sql_v1_internal::SqlFeatureEligibilityServiceRestConnectionImpl>( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/sql/v1/sql_feature_eligibility_rest_connection.h b/google/cloud/sql/v1/sql_feature_eligibility_rest_connection.h new file mode 100644 index 0000000000000..7e66ef278e052 --- /dev/null +++ b/google/cloud/sql/v1/sql_feature_eligibility_rest_connection.h @@ -0,0 +1,66 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/sql/v1/cloud_sql_feature_eligibility.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_REST_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_REST_CONNECTION_H + +#include "google/cloud/sql/v1/sql_feature_eligibility_connection.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace sql_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A factory function to construct an object of type + * `SqlFeatureEligibilityServiceConnection` that uses REST over HTTP as + * transport in lieu of gRPC. REST transport should only be used for services + * that do not support gRPC or if the existing network configuration precludes + * using gRPC. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of + * SqlFeatureEligibilityServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `SqlFeatureEligibilityServiceConnection`. Expected options are any + * of the types in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::RestOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::sql_v1::SqlFeatureEligibilityServicePolicyOptionList` + * + * @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 + * `SqlFeatureEligibilityServiceConnection` created by this function. + */ +std::shared_ptr +MakeSqlFeatureEligibilityServiceConnectionRest(Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace sql_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SQL_V1_SQL_FEATURE_ELIGIBILITY_REST_CONNECTION_H