diff --git a/ci/etc/expected_install_directories b/ci/etc/expected_install_directories index d7b3b9beda1ce..0b0c89ae1b880 100644 --- a/ci/etc/expected_install_directories +++ b/ci/etc/expected_install_directories @@ -75,6 +75,8 @@ ./include/google/cloud/beyondcorp/internal ./include/google/cloud/beyondcorp/mocks ./include/google/cloud/bigquery +./include/google/cloud/bigquery/analyticshub +./include/google/cloud/bigquery/analyticshub/v1 ./include/google/cloud/bigquery/connection ./include/google/cloud/bigquery/connection/v1 ./include/google/cloud/bigquery/datatransfer diff --git a/external/googleapis/protolists/bigquery.list b/external/googleapis/protolists/bigquery.list index f07ee318301d7..b185e09cadaf0 100644 --- a/external/googleapis/protolists/bigquery.list +++ b/external/googleapis/protolists/bigquery.list @@ -1,3 +1,4 @@ +@com_google_googleapis//google/cloud/bigquery/analyticshub/v1:analyticshub.proto @com_google_googleapis//google/cloud/bigquery/connection/v1:connection.proto @com_google_googleapis//google/cloud/bigquery/datatransfer/v1:datatransfer.proto @com_google_googleapis//google/cloud/bigquery/datatransfer/v1:transfer.proto diff --git a/external/googleapis/update_libraries.sh b/external/googleapis/update_libraries.sh index 5051d6f0118c2..bebb3826ebfe7 100755 --- a/external/googleapis/update_libraries.sh +++ b/external/googleapis/update_libraries.sh @@ -52,7 +52,8 @@ declare -A -r LIBRARIES=( "@com_google_googleapis//google/cloud/bigquery/reservation/v1:reservation_cc_grpc" \ "@com_google_googleapis//google/cloud/bigquery/logging/v1:logging_cc_grpc" \ "@com_google_googleapis//google/cloud/bigquery/datatransfer/v1:datatransfer_cc_grpc" \ - "@com_google_googleapis//google/cloud/bigquery/connection/v1:connection_cc_grpc" + "@com_google_googleapis//google/cloud/bigquery/connection/v1:connection_cc_grpc" \ + "@com_google_googleapis//google/cloud/bigquery/analyticshub/v1:analyticshub_cc_grpc" )" ["bigtable"]="$( printf ",%s" \ diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index bd6c950901f4b..6aa549937b1cd 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -204,6 +204,13 @@ service { retryable_status_codes: ["kUnavailable"] } +service { + service_proto_path: "google/cloud/bigquery/analyticshub/v1/analyticshub.proto" + product_path: "google/cloud/bigquery" + initial_copyright_year: "2022" + retryable_status_codes: ["kUnavailable"] +} + # Bigtable service { service_proto_path: "google/bigtable/v2/bigtable.proto" diff --git a/google/cloud/bigquery/BUILD.bazel b/google/cloud/bigquery/BUILD.bazel index 9076b4a51d16c..cea55af3cd716 100644 --- a/google/cloud/bigquery/BUILD.bazel +++ b/google/cloud/bigquery/BUILD.bazel @@ -26,6 +26,7 @@ cc_library( deps = [ "//:common", "//:grpc_utils", + "@com_google_googleapis//google/cloud/bigquery/analyticshub/v1:analyticshub_cc_grpc", "@com_google_googleapis//google/cloud/bigquery/connection/v1:connection_cc_grpc", "@com_google_googleapis//google/cloud/bigquery/datatransfer/v1:datatransfer_cc_grpc", "@com_google_googleapis//google/cloud/bigquery/logging/v1:logging_cc_grpc", diff --git a/google/cloud/bigquery/CMakeLists.txt b/google/cloud/bigquery/CMakeLists.txt index a3a77f3e89bc2..8c797a06926c2 100644 --- a/google/cloud/bigquery/CMakeLists.txt +++ b/google/cloud/bigquery/CMakeLists.txt @@ -31,6 +31,13 @@ include(GoogleCloudCppCommon) # configure_file(version_info.h.in ${CMAKE_CURRENT_SOURCE_DIR}/version_info.h) add_library( google_cloud_cpp_bigquery # cmake-format: sort + analytics_hub_client.cc + analytics_hub_client.h + analytics_hub_connection.cc + analytics_hub_connection.h + analytics_hub_connection_idempotency_policy.cc + analytics_hub_connection_idempotency_policy.h + analytics_hub_options.h bigquery_read_client.cc bigquery_read_client.h bigquery_read_connection.cc @@ -59,6 +66,21 @@ add_library( data_transfer_connection_idempotency_policy.cc data_transfer_connection_idempotency_policy.h data_transfer_options.h + internal/analytics_hub_auth_decorator.cc + internal/analytics_hub_auth_decorator.h + internal/analytics_hub_connection_impl.cc + internal/analytics_hub_connection_impl.h + internal/analytics_hub_logging_decorator.cc + internal/analytics_hub_logging_decorator.h + internal/analytics_hub_metadata_decorator.cc + internal/analytics_hub_metadata_decorator.h + internal/analytics_hub_option_defaults.cc + internal/analytics_hub_option_defaults.h + internal/analytics_hub_retry_traits.h + internal/analytics_hub_stub.cc + internal/analytics_hub_stub.h + internal/analytics_hub_stub_factory.cc + internal/analytics_hub_stub_factory.h internal/bigquery_read_auth_decorator.cc internal/bigquery_read_auth_decorator.h internal/bigquery_read_connection_impl.cc @@ -199,6 +221,7 @@ add_library(google_cloud_cpp_bigquery_mocks INTERFACE) target_sources( google_cloud_cpp_bigquery_mocks INTERFACE # cmake-format: sort + ${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_analytics_hub_connection.h ${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_bigquery_read_connection.h ${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_bigquery_write_connection.h ${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_connection_connection.h diff --git a/google/cloud/bigquery/analytics_hub_client.cc b/google/cloud/bigquery/analytics_hub_client.cc new file mode 100644 index 0000000000000..f51208391fd9b --- /dev/null +++ b/google/cloud/bigquery/analytics_hub_client.cc @@ -0,0 +1,277 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/analytics_hub_client.h" +#include + +namespace google { +namespace cloud { +namespace bigquery { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AnalyticsHubServiceClient::AnalyticsHubServiceClient( + std::shared_ptr connection, Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +AnalyticsHubServiceClient::~AnalyticsHubServiceClient() = default; + +StreamRange +AnalyticsHubServiceClient::ListDataExchanges(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest request; + request.set_parent(parent); + return connection_->ListDataExchanges(request); +} + +StreamRange +AnalyticsHubServiceClient::ListDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListDataExchanges(std::move(request)); +} + +StreamRange +AnalyticsHubServiceClient::ListOrgDataExchanges(std::string const& organization, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest + request; + request.set_organization(organization); + return connection_->ListOrgDataExchanges(request); +} + +StreamRange +AnalyticsHubServiceClient::ListOrgDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOrgDataExchanges(std::move(request)); +} + +StatusOr +AnalyticsHubServiceClient::GetDataExchange(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest request; + request.set_name(name); + return connection_->GetDataExchange(request); +} + +StatusOr +AnalyticsHubServiceClient::GetDataExchange( + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetDataExchange(request); +} + +StatusOr +AnalyticsHubServiceClient::CreateDataExchange( + std::string const& parent, + google::cloud::bigquery::analyticshub::v1::DataExchange const& + data_exchange, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::CreateDataExchangeRequest request; + request.set_parent(parent); + *request.mutable_data_exchange() = data_exchange; + return connection_->CreateDataExchange(request); +} + +StatusOr +AnalyticsHubServiceClient::CreateDataExchange( + google::cloud::bigquery::analyticshub::v1::CreateDataExchangeRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateDataExchange(request); +} + +StatusOr +AnalyticsHubServiceClient::UpdateDataExchange( + google::cloud::bigquery::analyticshub::v1::DataExchange const& + data_exchange, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::UpdateDataExchangeRequest request; + *request.mutable_data_exchange() = data_exchange; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateDataExchange(request); +} + +StatusOr +AnalyticsHubServiceClient::UpdateDataExchange( + google::cloud::bigquery::analyticshub::v1::UpdateDataExchangeRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateDataExchange(request); +} + +Status AnalyticsHubServiceClient::DeleteDataExchange(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::DeleteDataExchangeRequest request; + request.set_name(name); + return connection_->DeleteDataExchange(request); +} + +Status AnalyticsHubServiceClient::DeleteDataExchange( + google::cloud::bigquery::analyticshub::v1::DeleteDataExchangeRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteDataExchange(request); +} + +StreamRange +AnalyticsHubServiceClient::ListListings(std::string const& parent, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::ListListingsRequest request; + request.set_parent(parent); + return connection_->ListListings(request); +} + +StreamRange +AnalyticsHubServiceClient::ListListings( + google::cloud::bigquery::analyticshub::v1::ListListingsRequest request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListListings(std::move(request)); +} + +StatusOr +AnalyticsHubServiceClient::GetListing(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::GetListingRequest request; + request.set_name(name); + return connection_->GetListing(request); +} + +StatusOr +AnalyticsHubServiceClient::GetListing( + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetListing(request); +} + +StatusOr +AnalyticsHubServiceClient::CreateListing( + std::string const& parent, + google::cloud::bigquery::analyticshub::v1::Listing const& listing, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::CreateListingRequest request; + request.set_parent(parent); + *request.mutable_listing() = listing; + return connection_->CreateListing(request); +} + +StatusOr +AnalyticsHubServiceClient::CreateListing( + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateListing(request); +} + +StatusOr +AnalyticsHubServiceClient::UpdateListing( + google::cloud::bigquery::analyticshub::v1::Listing const& listing, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest request; + *request.mutable_listing() = listing; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateListing(request); +} + +StatusOr +AnalyticsHubServiceClient::UpdateListing( + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateListing(request); +} + +Status AnalyticsHubServiceClient::DeleteListing(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest request; + request.set_name(name); + return connection_->DeleteListing(request); +} + +Status AnalyticsHubServiceClient::DeleteListing( + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteListing(request); +} + +StatusOr +AnalyticsHubServiceClient::SubscribeListing(std::string const& name, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest request; + request.set_name(name); + return connection_->SubscribeListing(request); +} + +StatusOr +AnalyticsHubServiceClient::SubscribeListing( + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SubscribeListing(request); +} + +StatusOr AnalyticsHubServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr AnalyticsHubServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr +AnalyticsHubServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/analytics_hub_client.h b/google/cloud/bigquery/analytics_hub_client.h new file mode 100644 index 0000000000000..412b9c9d79f59 --- /dev/null +++ b/google/cloud/bigquery/analytics_hub_client.h @@ -0,0 +1,632 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CLIENT_H + +#include "google/cloud/bigquery/analytics_hub_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 + +namespace google { +namespace cloud { +namespace bigquery { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// The `AnalyticsHubService` API facilitates data sharing within and across +/// organizations. It allows data providers to publish listings that reference +/// shared datasets. With Analytics Hub, users can discover and search for +/// listings that they have access to. Subscribers can view and subscribe to +/// listings. When you subscribe to a listing, Analytics Hub creates a linked +/// dataset in your project. +/// +/// @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 AnalyticsHubServiceClient { + public: + explicit AnalyticsHubServiceClient( + std::shared_ptr connection, + Options opts = {}); + ~AnalyticsHubServiceClient(); + + //@{ + // @name Copy and move support + AnalyticsHubServiceClient(AnalyticsHubServiceClient const&) = default; + AnalyticsHubServiceClient& operator=(AnalyticsHubServiceClient const&) = + default; + AnalyticsHubServiceClient(AnalyticsHubServiceClient&&) = default; + AnalyticsHubServiceClient& operator=(AnalyticsHubServiceClient&&) = default; + //@} + + //@{ + // @name Equality + friend bool operator==(AnalyticsHubServiceClient const& a, + AnalyticsHubServiceClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(AnalyticsHubServiceClient const& a, + AnalyticsHubServiceClient const& b) { + return !(a == b); + } + //@} + + /// + /// Lists all data exchanges in a given project and location. + /// + /// @param parent Required. The parent resource path of the data exchanges. + /// e.g. `projects/myproject/locations/US`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.ListDataExchangesRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L433} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StreamRange + ListDataExchanges(std::string const& parent, Options opts = {}); + + /// + /// Lists all data exchanges in a given project and location. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L433} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.ListDataExchangesRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L433} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StreamRange + ListDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest + request, + Options opts = {}); + + /// + /// Lists all data exchanges from projects in a given organization and + /// location. + /// + /// @param organization Required. The organization resource path of the + /// projects containing DataExchanges. + /// e.g. `organizations/myorg/locations/US`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.ListOrgDataExchangesRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L463} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StreamRange + ListOrgDataExchanges(std::string const& organization, Options opts = {}); + + /// + /// Lists all data exchanges from projects in a given organization and + /// location. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L463} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.ListOrgDataExchangesRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L463} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StreamRange + ListOrgDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest + request, + Options opts = {}); + + /// + /// Gets the details of a data exchange. + /// + /// @param name Required. The resource name of the data exchange. + /// e.g. `projects/myproject/locations/US/dataExchanges/123`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.GetDataExchangeRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L488} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StatusOr + GetDataExchange(std::string const& name, Options opts = {}); + + /// + /// Gets the details of a data exchange. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L488} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.GetDataExchangeRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L488} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StatusOr + GetDataExchange( + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request, + Options opts = {}); + + /// + /// Creates a new data exchange. + /// + /// @param parent Required. The parent resource path of the data exchange. + /// e.g. `projects/myproject/locations/US`. + /// @param data_exchange Required. The data exchange to create. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.CreateDataExchangeRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L500} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StatusOr + CreateDataExchange( + std::string const& parent, + google::cloud::bigquery::analyticshub::v1::DataExchange const& + data_exchange, + Options opts = {}); + + /// + /// Creates a new data exchange. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::CreateDataExchangeRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L500} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.CreateDataExchangeRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L500} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StatusOr + CreateDataExchange(google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request, + Options opts = {}); + + /// + /// Updates an existing data exchange. + /// + /// @param data_exchange Required. The data exchange to update. + /// @param update_mask Required. Field mask specifies the fields to update in + /// the data exchange + /// resource. The fields specified in the + /// `updateMask` are relative to the resource and are not a full request. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.UpdateDataExchangeRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L522} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StatusOr + UpdateDataExchange( + google::cloud::bigquery::analyticshub::v1::DataExchange const& + data_exchange, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + /// + /// Updates an existing data exchange. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::UpdateDataExchangeRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L522} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DataExchange,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + /// [google.cloud.bigquery.analyticshub.v1.UpdateDataExchangeRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L522} + /// [google.cloud.bigquery.analyticshub.v1.DataExchange]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L200} + /// + StatusOr + UpdateDataExchange(google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request, + Options opts = {}); + + /// + /// Deletes an existing data exchange. + /// + /// @param name Required. The full name of the data exchange resource that + /// you want to delete. + /// For example, `projects/myproject/locations/US/dataExchanges/123`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// + /// [google.cloud.bigquery.analyticshub.v1.DeleteDataExchangeRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L533} + /// + Status DeleteDataExchange(std::string const& name, Options opts = {}); + + /// + /// Deletes an existing data exchange. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DeleteDataExchangeRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L533} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// + /// [google.cloud.bigquery.analyticshub.v1.DeleteDataExchangeRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L533} + /// + Status DeleteDataExchange(google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request, + Options opts = {}); + + /// + /// Lists all listings in a given project and location. + /// + /// @param parent Required. The parent resource path of the listing. + /// e.g. `projects/myproject/locations/US/dataExchanges/123`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::Listing,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + /// [google.cloud.bigquery.analyticshub.v1.ListListingsRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L545} + /// [google.cloud.bigquery.analyticshub.v1.Listing]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + StreamRange ListListings( + std::string const& parent, Options opts = {}); + + /// + /// Lists all listings in a given project and location. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::ListListingsRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L545} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::Listing,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + /// [google.cloud.bigquery.analyticshub.v1.ListListingsRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L545} + /// [google.cloud.bigquery.analyticshub.v1.Listing]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + StreamRange ListListings( + google::cloud::bigquery::analyticshub::v1::ListListingsRequest request, + Options opts = {}); + + /// + /// Gets the details of a listing. + /// + /// @param name Required. The resource name of the listing. + /// e.g. `projects/myproject/locations/US/dataExchanges/123/listings/456`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::Listing,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + /// [google.cloud.bigquery.analyticshub.v1.GetListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L574} + /// [google.cloud.bigquery.analyticshub.v1.Listing]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + StatusOr GetListing( + std::string const& name, Options opts = {}); + + /// + /// Gets the details of a listing. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::GetListingRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L574} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::Listing,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + /// [google.cloud.bigquery.analyticshub.v1.GetListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L574} + /// [google.cloud.bigquery.analyticshub.v1.Listing]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + StatusOr GetListing( + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request, + Options opts = {}); + + /// + /// Creates a new listing. + /// + /// @param parent Required. The parent resource path of the listing. + /// e.g. `projects/myproject/locations/US/dataExchanges/123`. + /// @param listing Required. The listing to create. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::Listing,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + /// [google.cloud.bigquery.analyticshub.v1.CreateListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L586} + /// [google.cloud.bigquery.analyticshub.v1.Listing]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + StatusOr CreateListing( + std::string const& parent, + google::cloud::bigquery::analyticshub::v1::Listing const& listing, + Options opts = {}); + + /// + /// Creates a new listing. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::CreateListingRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L586} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::Listing,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + /// [google.cloud.bigquery.analyticshub.v1.CreateListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L586} + /// [google.cloud.bigquery.analyticshub.v1.Listing]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + StatusOr CreateListing( + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request, + Options opts = {}); + + /// + /// Updates an existing listing. + /// + /// @param listing Required. The listing to update. + /// @param update_mask Required. Field mask specifies the fields to update in + /// the listing resource. The + /// fields specified in the `updateMask` are relative to the resource and are + /// not a full request. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::Listing,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + /// [google.cloud.bigquery.analyticshub.v1.UpdateListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L608} + /// [google.cloud.bigquery.analyticshub.v1.Listing]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + StatusOr UpdateListing( + google::cloud::bigquery::analyticshub::v1::Listing const& listing, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + /// + /// Updates an existing listing. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::UpdateListingRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L608} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::Listing,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + /// [google.cloud.bigquery.analyticshub.v1.UpdateListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L608} + /// [google.cloud.bigquery.analyticshub.v1.Listing]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L301} + /// + StatusOr UpdateListing( + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request, + Options opts = {}); + + /// + /// Deletes a listing. + /// + /// @param name Required. Resource name of the listing to delete. + /// e.g. `projects/myproject/locations/US/dataExchanges/123/listings/456`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// + /// [google.cloud.bigquery.analyticshub.v1.DeleteListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L619} + /// + Status DeleteListing(std::string const& name, Options opts = {}); + + /// + /// Deletes a listing. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::DeleteListingRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L619} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// + /// [google.cloud.bigquery.analyticshub.v1.DeleteListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L619} + /// + Status DeleteListing( + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request, + Options opts = {}); + + /// + /// Subscribes to a listing. + /// + /// Currently, with Analytics Hub, you can create listings that + /// reference only BigQuery datasets. + /// Upon subscription to a listing for a BigQuery dataset, Analytics Hub + /// creates a linked dataset in the subscriber's project. + /// + /// @param name Required. Resource name of the listing that you want to + /// subscribe to. + /// e.g. `projects/myproject/locations/US/dataExchanges/123/listings/456`. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::SubscribeListingResponse,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L649} + /// + /// [google.cloud.bigquery.analyticshub.v1.SubscribeListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L631} + /// [google.cloud.bigquery.analyticshub.v1.SubscribeListingResponse]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L649} + /// + StatusOr + SubscribeListing(std::string const& name, Options opts = {}); + + /// + /// Subscribes to a listing. + /// + /// Currently, with Analytics Hub, you can create listings that + /// reference only BigQuery datasets. + /// Upon subscription to a listing for a BigQuery dataset, Analytics Hub + /// creates a linked dataset in the subscriber's project. + /// + /// @param request + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L631} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::cloud::bigquery::analyticshub::v1::SubscribeListingResponse,google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L649} + /// + /// [google.cloud.bigquery.analyticshub.v1.SubscribeListingRequest]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L631} + /// [google.cloud.bigquery.analyticshub.v1.SubscribeListingResponse]: + /// @googleapis_reference_link{google/cloud/bigquery/analyticshub/v1/analyticshub.proto#L649} + /// + StatusOr + SubscribeListing( + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request, + Options opts = {}); + + /// + /// Gets the IAM policy. + /// + /// @param request + /// @googleapis_link{google::iam::v1::GetIamPolicyRequest,google/iam/v1/iam_policy.proto#L123} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::iam::v1::Policy,google/iam/v1/policy.proto#L96} + /// + /// [google.iam.v1.GetIamPolicyRequest]: + /// @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: + /// @googleapis_reference_link{google/iam/v1/policy.proto#L96} + /// + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + /// + /// Sets the IAM policy. + /// + /// @param request + /// @googleapis_link{google::iam::v1::SetIamPolicyRequest,google/iam/v1/iam_policy.proto#L101} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::iam::v1::Policy,google/iam/v1/policy.proto#L96} + /// + /// [google.iam.v1.SetIamPolicyRequest]: + /// @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// [google.iam.v1.Policy]: + /// @googleapis_reference_link{google/iam/v1/policy.proto#L96} + /// + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + /// + /// Returns the permissions that a caller has. + /// + /// @param request + /// @googleapis_link{google::iam::v1::TestIamPermissionsRequest,google/iam/v1/iam_policy.proto#L136} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::iam::v1::TestIamPermissionsResponse,google/iam/v1/iam_policy.proto#L151} + /// + /// [google.iam.v1.TestIamPermissionsRequest]: + /// @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: + /// @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CLIENT_H diff --git a/google/cloud/bigquery/analytics_hub_connection.cc b/google/cloud/bigquery/analytics_hub_connection.cc new file mode 100644 index 0000000000000..7ac8c1f81fdbe --- /dev/null +++ b/google/cloud/bigquery/analytics_hub_connection.cc @@ -0,0 +1,151 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/analytics_hub_connection.h" +#include "google/cloud/bigquery/analytics_hub_options.h" +#include "google/cloud/bigquery/internal/analytics_hub_connection_impl.h" +#include "google/cloud/bigquery/internal/analytics_hub_option_defaults.h" +#include "google/cloud/bigquery/internal/analytics_hub_stub_factory.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 + +namespace google { +namespace cloud { +namespace bigquery { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AnalyticsHubServiceConnection::~AnalyticsHubServiceConnection() = default; + +StreamRange +AnalyticsHubServiceConnection::ListDataExchanges( + google::cloud::bigquery::analyticshub::v1:: + ListDataExchangesRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StreamRange +AnalyticsHubServiceConnection::ListOrgDataExchanges( + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AnalyticsHubServiceConnection::GetDataExchange( + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AnalyticsHubServiceConnection::CreateDataExchange( + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AnalyticsHubServiceConnection::UpdateDataExchange( + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AnalyticsHubServiceConnection::DeleteDataExchange( + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange +AnalyticsHubServiceConnection::ListListings( + google::cloud::bigquery::analyticshub::v1:: + ListListingsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AnalyticsHubServiceConnection::GetListing( + google::cloud::bigquery::analyticshub::v1::GetListingRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AnalyticsHubServiceConnection::CreateListing( + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AnalyticsHubServiceConnection::UpdateListing( + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status AnalyticsHubServiceConnection::DeleteListing( + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AnalyticsHubServiceConnection::SubscribeListing( + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AnalyticsHubServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AnalyticsHubServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AnalyticsHubServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +std::shared_ptr +MakeAnalyticsHubServiceConnection(Options options) { + internal::CheckExpectedOptions(options, + __func__); + options = + bigquery_internal::AnalyticsHubServiceDefaultOptions(std::move(options)); + auto background = internal::MakeBackgroundThreadsFactory(options)(); + auto stub = bigquery_internal::CreateDefaultAnalyticsHubServiceStub( + background->cq(), options); + return std::make_shared( + std::move(background), std::move(stub), std::move(options)); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/analytics_hub_connection.h b/google/cloud/bigquery/analytics_hub_connection.h new file mode 100644 index 0000000000000..f3e9cfeab6645 --- /dev/null +++ b/google/cloud/bigquery/analytics_hub_connection.h @@ -0,0 +1,163 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CONNECTION_H + +#include "google/cloud/bigquery/analytics_hub_connection_idempotency_policy.h" +#include "google/cloud/bigquery/internal/analytics_hub_retry_traits.h" +#include "google/cloud/bigquery/internal/analytics_hub_stub.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 bigquery { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using AnalyticsHubServiceRetryPolicy = + ::google::cloud::internal::TraitBasedRetryPolicy< + bigquery_internal::AnalyticsHubServiceRetryTraits>; + +using AnalyticsHubServiceLimitedTimeRetryPolicy = + ::google::cloud::internal::LimitedTimeRetryPolicy< + bigquery_internal::AnalyticsHubServiceRetryTraits>; + +using AnalyticsHubServiceLimitedErrorCountRetryPolicy = + ::google::cloud::internal::LimitedErrorCountRetryPolicy< + bigquery_internal::AnalyticsHubServiceRetryTraits>; + +/** + * The `AnalyticsHubServiceConnection` object for `AnalyticsHubServiceClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `AnalyticsHubServiceClient`. This allows users to inject custom + * behavior (e.g., with a Google Mock object) when writing tests that use + * objects of type `AnalyticsHubServiceClient`. + * + * To create a concrete instance, see `MakeAnalyticsHubServiceConnection()`. + * + * For mocking, see `bigquery_mocks::MockAnalyticsHubServiceConnection`. + */ +class AnalyticsHubServiceConnection { + public: + virtual ~AnalyticsHubServiceConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StreamRange + ListDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest + request); + + virtual StreamRange + ListOrgDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest + request); + + virtual StatusOr + GetDataExchange( + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request); + + virtual StatusOr + CreateDataExchange(google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request); + + virtual StatusOr + UpdateDataExchange(google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request); + + virtual Status DeleteDataExchange( + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request); + + virtual StreamRange + ListListings( + google::cloud::bigquery::analyticshub::v1::ListListingsRequest request); + + virtual StatusOr + GetListing(google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request); + + virtual StatusOr + CreateListing( + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request); + + virtual StatusOr + UpdateListing( + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request); + + virtual Status DeleteListing( + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request); + + virtual StatusOr< + google::cloud::bigquery::analyticshub::v1::SubscribeListingResponse> + SubscribeListing( + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); +}; + +/** + * A factory function to construct an object of type + * `AnalyticsHubServiceConnection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of + * AnalyticsHubServiceClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `AnalyticsHubServiceConnection`. Expected options are any of the + * types in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::bigquery::AnalyticsHubServicePolicyOptionList` + * + * @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 `AnalyticsHubServiceConnection` + * created by this function. + */ +std::shared_ptr +MakeAnalyticsHubServiceConnection(Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CONNECTION_H diff --git a/google/cloud/bigquery/analytics_hub_connection_idempotency_policy.cc b/google/cloud/bigquery/analytics_hub_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..257dccfac40e9 --- /dev/null +++ b/google/cloud/bigquery/analytics_hub_connection_idempotency_policy.cc @@ -0,0 +1,144 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/analytics_hub_connection_idempotency_policy.h" +#include "absl/memory/memory.h" +#include + +namespace google { +namespace cloud { +namespace bigquery { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +AnalyticsHubServiceConnectionIdempotencyPolicy:: + ~AnalyticsHubServiceConnectionIdempotencyPolicy() = default; + +namespace { +class DefaultAnalyticsHubServiceConnectionIdempotencyPolicy + : public AnalyticsHubServiceConnectionIdempotencyPolicy { + public: + ~DefaultAnalyticsHubServiceConnectionIdempotencyPolicy() override = default; + + /// Create a new copy of this object. + std::unique_ptr clone() + const override { + return absl::make_unique< + DefaultAnalyticsHubServiceConnectionIdempotencyPolicy>(*this); + } + + Idempotency ListDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest) + override { + return Idempotency::kIdempotent; + } + + Idempotency ListOrgDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest) + override { + return Idempotency::kIdempotent; + } + + Idempotency GetDataExchange( + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const&) + override { + return Idempotency::kIdempotent; + } + + Idempotency CreateDataExchange( + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const&) override { + return Idempotency::kNonIdempotent; + } + + Idempotency UpdateDataExchange( + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const&) override { + return Idempotency::kNonIdempotent; + } + + Idempotency DeleteDataExchange( + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const&) override { + return Idempotency::kNonIdempotent; + } + + Idempotency ListListings( + google::cloud::bigquery::analyticshub::v1::ListListingsRequest) override { + return Idempotency::kIdempotent; + } + + Idempotency GetListing( + google::cloud::bigquery::analyticshub::v1::GetListingRequest const&) + override { + return Idempotency::kIdempotent; + } + + Idempotency CreateListing( + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const&) + override { + return Idempotency::kNonIdempotent; + } + + Idempotency UpdateListing( + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const&) + override { + return Idempotency::kNonIdempotent; + } + + Idempotency DeleteListing( + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const&) + override { + return Idempotency::kNonIdempotent; + } + + Idempotency SubscribeListing( + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const&) + override { + return Idempotency::kNonIdempotent; + } + + Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) override { + return Idempotency::kNonIdempotent; + } + + Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; + } + + Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) override { + return Idempotency::kNonIdempotent; + } +}; +} // namespace + +std::unique_ptr +MakeDefaultAnalyticsHubServiceConnectionIdempotencyPolicy() { + return absl::make_unique< + DefaultAnalyticsHubServiceConnectionIdempotencyPolicy>(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/analytics_hub_connection_idempotency_policy.h b/google/cloud/bigquery/analytics_hub_connection_idempotency_policy.h new file mode 100644 index 0000000000000..098e0bd36651e --- /dev/null +++ b/google/cloud/bigquery/analytics_hub_connection_idempotency_policy.h @@ -0,0 +1,107 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/idempotency.h" +#include "google/cloud/internal/retry_policy.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace bigquery { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AnalyticsHubServiceConnectionIdempotencyPolicy { + public: + virtual ~AnalyticsHubServiceConnectionIdempotencyPolicy() = 0; + + /// Create a new copy of this object. + virtual std::unique_ptr + clone() const = 0; + + virtual google::cloud::Idempotency ListDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest + request) = 0; + + virtual google::cloud::Idempotency ListOrgDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest + request) = 0; + + virtual google::cloud::Idempotency GetDataExchange( + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) = 0; + + virtual google::cloud::Idempotency CreateDataExchange( + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) = 0; + + virtual google::cloud::Idempotency UpdateDataExchange( + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) = 0; + + virtual google::cloud::Idempotency DeleteDataExchange( + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) = 0; + + virtual google::cloud::Idempotency ListListings( + google::cloud::bigquery::analyticshub::v1::ListListingsRequest + request) = 0; + + virtual google::cloud::Idempotency GetListing( + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) = 0; + + virtual google::cloud::Idempotency CreateListing( + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) = 0; + + virtual google::cloud::Idempotency UpdateListing( + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) = 0; + + virtual google::cloud::Idempotency DeleteListing( + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) = 0; + + virtual google::cloud::Idempotency SubscribeListing( + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) = 0; + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) = 0; +}; + +std::unique_ptr +MakeDefaultAnalyticsHubServiceConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/bigquery/analytics_hub_options.h b/google/cloud/bigquery/analytics_hub_options.h new file mode 100644 index 0000000000000..2d0b594dbb68a --- /dev/null +++ b/google/cloud/bigquery/analytics_hub_options.h @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_OPTIONS_H + +#include "google/cloud/bigquery/analytics_hub_connection.h" +#include "google/cloud/bigquery/analytics_hub_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 bigquery { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Option to use with `google::cloud::Options`. +struct AnalyticsHubServiceRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/// Option to use with `google::cloud::Options`. +struct AnalyticsHubServiceBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/// Option to use with `google::cloud::Options`. +struct AnalyticsHubServiceConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +using AnalyticsHubServicePolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_ANALYTICS_HUB_OPTIONS_H diff --git a/google/cloud/bigquery/doc/bigquery-main.dox b/google/cloud/bigquery/doc/bigquery-main.dox index 7464986d8126b..f377117d29a99 100644 --- a/google/cloud/bigquery/doc/bigquery-main.dox +++ b/google/cloud/bigquery/doc/bigquery-main.dox @@ -77,6 +77,9 @@ behaviors in the library. - `GOOGLE_CLOUD_CPP_RESERVATION_SERVICE_ENDPOINT=...` changes the default endpoint (bigqueryreservation.googleapis.com) used by `ReservationServiceConnection`. +- `GOOGLE_CLOUD_CPP_ANALYTICS_HUB_SERVICE_ENDPOINT=...` changes the default endpoint + (analyticshub.googleapis.com) used by `AnalyticsHubServiceConnection`. + - `GOOGLE_CLOUD_CPP_ENABLE_TRACING=rpc` turns on tracing for most gRPC calls. The library injects an additional Stub decorator that prints each gRPC request and response. Unless you have configured you own logging backend, diff --git a/google/cloud/bigquery/google_cloud_cpp_bigquery.bzl b/google/cloud/bigquery/google_cloud_cpp_bigquery.bzl index 79a17618ff97a..a1cc5e075d658 100644 --- a/google/cloud/bigquery/google_cloud_cpp_bigquery.bzl +++ b/google/cloud/bigquery/google_cloud_cpp_bigquery.bzl @@ -17,6 +17,10 @@ """Automatically generated source lists for google_cloud_cpp_bigquery - DO NOT EDIT.""" google_cloud_cpp_bigquery_hdrs = [ + "analytics_hub_client.h", + "analytics_hub_connection.h", + "analytics_hub_connection_idempotency_policy.h", + "analytics_hub_options.h", "bigquery_read_client.h", "bigquery_read_connection.h", "bigquery_read_connection_idempotency_policy.h", @@ -33,6 +37,14 @@ google_cloud_cpp_bigquery_hdrs = [ "data_transfer_connection.h", "data_transfer_connection_idempotency_policy.h", "data_transfer_options.h", + "internal/analytics_hub_auth_decorator.h", + "internal/analytics_hub_connection_impl.h", + "internal/analytics_hub_logging_decorator.h", + "internal/analytics_hub_metadata_decorator.h", + "internal/analytics_hub_option_defaults.h", + "internal/analytics_hub_retry_traits.h", + "internal/analytics_hub_stub.h", + "internal/analytics_hub_stub_factory.h", "internal/bigquery_read_auth_decorator.h", "internal/bigquery_read_connection_impl.h", "internal/bigquery_read_logging_decorator.h", @@ -93,6 +105,9 @@ google_cloud_cpp_bigquery_hdrs = [ ] google_cloud_cpp_bigquery_srcs = [ + "analytics_hub_client.cc", + "analytics_hub_connection.cc", + "analytics_hub_connection_idempotency_policy.cc", "bigquery_read_client.cc", "bigquery_read_connection.cc", "bigquery_read_connection_idempotency_policy.cc", @@ -105,6 +120,13 @@ google_cloud_cpp_bigquery_srcs = [ "data_transfer_client.cc", "data_transfer_connection.cc", "data_transfer_connection_idempotency_policy.cc", + "internal/analytics_hub_auth_decorator.cc", + "internal/analytics_hub_connection_impl.cc", + "internal/analytics_hub_logging_decorator.cc", + "internal/analytics_hub_metadata_decorator.cc", + "internal/analytics_hub_option_defaults.cc", + "internal/analytics_hub_stub.cc", + "internal/analytics_hub_stub_factory.cc", "internal/bigquery_read_auth_decorator.cc", "internal/bigquery_read_connection_impl.cc", "internal/bigquery_read_logging_decorator.cc", diff --git a/google/cloud/bigquery/google_cloud_cpp_bigquery_mocks.bzl b/google/cloud/bigquery/google_cloud_cpp_bigquery_mocks.bzl index 151a306c6fb4c..956fdfb50e708 100644 --- a/google/cloud/bigquery/google_cloud_cpp_bigquery_mocks.bzl +++ b/google/cloud/bigquery/google_cloud_cpp_bigquery_mocks.bzl @@ -17,6 +17,7 @@ """Automatically generated source lists for google_cloud_cpp_bigquery_mocks - DO NOT EDIT.""" google_cloud_cpp_bigquery_mocks_hdrs = [ + "mocks/mock_analytics_hub_connection.h", "mocks/mock_bigquery_read_connection.h", "mocks/mock_bigquery_write_connection.h", "mocks/mock_connection_connection.h", diff --git a/google/cloud/bigquery/internal/analytics_hub_auth_decorator.cc b/google/cloud/bigquery/internal/analytics_hub_auth_decorator.cc new file mode 100644 index 0000000000000..b7e1d2c01888c --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_auth_decorator.cc @@ -0,0 +1,180 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/internal/analytics_hub_auth_decorator.h" +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AnalyticsHubServiceAuth::AnalyticsHubServiceAuth( + std::shared_ptr auth, + std::shared_ptr child) + : auth_(std::move(auth)), child_(std::move(child)) {} + +StatusOr +AnalyticsHubServiceAuth::ListDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListDataExchanges(context, request); +} + +StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> +AnalyticsHubServiceAuth::ListOrgDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListOrgDataExchanges(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::GetDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetDataExchange(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::CreateDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateDataExchangeRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateDataExchange(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::UpdateDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateDataExchangeRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateDataExchange(context, request); +} + +Status AnalyticsHubServiceAuth::DeleteDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteDataExchangeRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteDataExchange(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::ListListings( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListListings(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::GetListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetListing(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::CreateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->CreateListing(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::UpdateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->UpdateListing(context, request); +} + +Status AnalyticsHubServiceAuth::DeleteListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->DeleteListing(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::SubscribeListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SubscribeListing(context, request); +} + +StatusOr AnalyticsHubServiceAuth::GetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, request); +} + +StatusOr AnalyticsHubServiceAuth::SetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, request); +} + +StatusOr +AnalyticsHubServiceAuth::TestIamPermissions( + grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/internal/analytics_hub_auth_decorator.h b/google/cloud/bigquery/internal/analytics_hub_auth_decorator.h new file mode 100644 index 0000000000000..d9548ddef4c07 --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_auth_decorator.h @@ -0,0 +1,128 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_AUTH_DECORATOR_H + +#include "google/cloud/bigquery/internal/analytics_hub_stub.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/version.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AnalyticsHubServiceAuth : public AnalyticsHubServiceStub { + public: + ~AnalyticsHubServiceAuth() override = default; + AnalyticsHubServiceAuth( + std::shared_ptr auth, + std::shared_ptr child); + + StatusOr + ListDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) override; + + StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> + ListOrgDataExchanges(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) override; + + StatusOr + GetDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) override; + + StatusOr + CreateDataExchange(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) override; + + StatusOr + UpdateDataExchange(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) override; + + Status DeleteDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) override; + + StatusOr + ListListings( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) override; + + StatusOr GetListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) override; + + StatusOr CreateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) override; + + StatusOr UpdateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) override; + + Status DeleteListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) override; + + StatusOr + SubscribeListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + private: + std::shared_ptr auth_; + std::shared_ptr child_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_AUTH_DECORATOR_H diff --git a/google/cloud/bigquery/internal/analytics_hub_connection_impl.cc b/google/cloud/bigquery/internal/analytics_hub_connection_impl.cc new file mode 100644 index 0000000000000..86a0123a2101a --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_connection_impl.cc @@ -0,0 +1,318 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/internal/analytics_hub_connection_impl.h" +#include "google/cloud/bigquery/internal/analytics_hub_option_defaults.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/retry_loop.h" +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AnalyticsHubServiceConnectionImpl::AnalyticsHubServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions( + std::move(options), AnalyticsHubServiceConnection::options())) {} + +StreamRange +AnalyticsHubServiceConnectionImpl::ListDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest + request) { + request.clear_page_token(); + auto& stub = stub_; + auto retry = std::shared_ptr( + retry_policy()); + auto backoff = std::shared_ptr(backoff_policy()); + auto idempotency = idempotency_policy()->ListDataExchanges(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + std::move(request), + [stub, retry, backoff, idempotency, + function_name](google::cloud::bigquery::analyticshub::v1:: + ListDataExchangesRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListDataExchangesRequest const& request) { + return stub->ListDataExchanges(context, request); + }, + r, function_name); + }, + [](google::cloud::bigquery::analyticshub::v1::ListDataExchangesResponse + r) { + std::vector + result(r.data_exchanges().size()); + auto& messages = *r.mutable_data_exchanges(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StreamRange +AnalyticsHubServiceConnectionImpl::ListOrgDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest + request) { + request.clear_page_token(); + auto& stub = stub_; + auto retry = std::shared_ptr( + retry_policy()); + auto backoff = std::shared_ptr(backoff_policy()); + auto idempotency = idempotency_policy()->ListOrgDataExchanges(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + std::move(request), + [stub, retry, backoff, idempotency, + function_name](google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) { + return stub->ListOrgDataExchanges(context, request); + }, + r, function_name); + }, + [](google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse + r) { + std::vector + result(r.data_exchanges().size()); + auto& messages = *r.mutable_data_exchanges(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::GetDataExchange( + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->GetDataExchange(request), + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + GetDataExchangeRequest const& request) { + return stub_->GetDataExchange(context, request); + }, + request, __func__); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::CreateDataExchange( + google::cloud::bigquery::analyticshub::v1::CreateDataExchangeRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->CreateDataExchange(request), + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) { + return stub_->CreateDataExchange(context, request); + }, + request, __func__); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::UpdateDataExchange( + google::cloud::bigquery::analyticshub::v1::UpdateDataExchangeRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->UpdateDataExchange(request), + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) { + return stub_->UpdateDataExchange(context, request); + }, + request, __func__); +} + +Status AnalyticsHubServiceConnectionImpl::DeleteDataExchange( + google::cloud::bigquery::analyticshub::v1::DeleteDataExchangeRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->DeleteDataExchange(request), + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) { + return stub_->DeleteDataExchange(context, request); + }, + request, __func__); +} + +StreamRange +AnalyticsHubServiceConnectionImpl::ListListings( + google::cloud::bigquery::analyticshub::v1::ListListingsRequest request) { + request.clear_page_token(); + auto& stub = stub_; + auto retry = std::shared_ptr( + retry_policy()); + auto backoff = std::shared_ptr(backoff_policy()); + auto idempotency = idempotency_policy()->ListListings(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + std::move(request), + [stub, retry, backoff, idempotency, function_name]( + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListListingsRequest const& request) { + return stub->ListListings(context, request); + }, + r, function_name); + }, + [](google::cloud::bigquery::analyticshub::v1::ListListingsResponse r) { + std::vector result( + r.listings().size()); + auto& messages = *r.mutable_listings(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::GetListing( + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->GetListing(request), + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) { return stub_->GetListing(context, request); }, + request, __func__); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::CreateListing( + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->CreateListing(request), + [this]( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) { return stub_->CreateListing(context, request); }, + request, __func__); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::UpdateListing( + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->UpdateListing(request), + [this]( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) { return stub_->UpdateListing(context, request); }, + request, __func__); +} + +Status AnalyticsHubServiceConnectionImpl::DeleteListing( + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->DeleteListing(request), + [this]( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) { return stub_->DeleteListing(context, request); }, + request, __func__); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::SubscribeListing( + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->SubscribeListing(request), + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + SubscribeListingRequest const& request) { + return stub_->SubscribeListing(context, request); + }, + request, __func__); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->GetIamPolicy(request), + [this](grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, request); + }, + request, __func__); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->SetIamPolicy(request), + [this](grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, request); + }, + request, __func__); +} + +StatusOr +AnalyticsHubServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::RetryLoop( + retry_policy(), backoff_policy(), + idempotency_policy()->TestIamPermissions(request), + [this](grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, request); + }, + request, __func__); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/internal/analytics_hub_connection_impl.h b/google/cloud/bigquery/internal/analytics_hub_connection_impl.h new file mode 100644 index 0000000000000..33f16de591aea --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_connection_impl.h @@ -0,0 +1,158 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_CONNECTION_IMPL_H + +#include "google/cloud/bigquery/analytics_hub_connection.h" +#include "google/cloud/bigquery/analytics_hub_connection_idempotency_policy.h" +#include "google/cloud/bigquery/analytics_hub_options.h" +#include "google/cloud/bigquery/internal/analytics_hub_retry_traits.h" +#include "google/cloud/bigquery/internal/analytics_hub_stub.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AnalyticsHubServiceConnectionImpl + : public bigquery::AnalyticsHubServiceConnection { + public: + ~AnalyticsHubServiceConnectionImpl() override = default; + + AnalyticsHubServiceConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, + Options options); + + Options options() override { return options_; } + + StreamRange + ListDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest + request) override; + + StreamRange + ListOrgDataExchanges( + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest + request) override; + + StatusOr + GetDataExchange( + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) override; + + StatusOr + CreateDataExchange(google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) override; + + StatusOr + UpdateDataExchange(google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) override; + + Status DeleteDataExchange( + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) override; + + StreamRange ListListings( + google::cloud::bigquery::analyticshub::v1::ListListingsRequest request) + override; + + StatusOr GetListing( + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) override; + + StatusOr CreateListing( + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) override; + + StatusOr UpdateListing( + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) override; + + Status DeleteListing( + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) override; + + StatusOr + SubscribeListing( + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + + private: + std::unique_ptr retry_policy() { + auto const& options = internal::CurrentOptions(); + if (options.has()) { + return options.get() + ->clone(); + } + return options_.get() + ->clone(); + } + + std::unique_ptr backoff_policy() { + auto const& options = internal::CurrentOptions(); + if (options.has()) { + return options.get() + ->clone(); + } + return options_.get() + ->clone(); + } + + std::unique_ptr + idempotency_policy() { + auto const& options = internal::CurrentOptions(); + if (options.has< + bigquery::AnalyticsHubServiceConnectionIdempotencyPolicyOption>()) { + return options + .get() + ->clone(); + } + return options_ + .get() + ->clone(); + } + + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_CONNECTION_IMPL_H diff --git a/google/cloud/bigquery/internal/analytics_hub_logging_decorator.cc b/google/cloud/bigquery/internal/analytics_hub_logging_decorator.cc new file mode 100644 index 0000000000000..2f5a7f3852be0 --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_logging_decorator.cc @@ -0,0 +1,235 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/internal/analytics_hub_logging_decorator.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AnalyticsHubServiceLogging::AnalyticsHubServiceLogging( + 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 +AnalyticsHubServiceLogging::ListDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListDataExchangesRequest const& request) { + return child_->ListDataExchanges(context, request); + }, + context, request, __func__, tracing_options_); +} + +StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> +AnalyticsHubServiceLogging::ListOrgDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) { + return child_->ListOrgDataExchanges(context, request); + }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::GetDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + GetDataExchangeRequest const& request) { + return child_->GetDataExchange(context, request); + }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::CreateDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateDataExchangeRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) { + return child_->CreateDataExchange(context, request); + }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::UpdateDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateDataExchangeRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) { + return child_->UpdateDataExchange(context, request); + }, + context, request, __func__, tracing_options_); +} + +Status AnalyticsHubServiceLogging::DeleteDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteDataExchangeRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) { + return child_->DeleteDataExchange(context, request); + }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::ListListings( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) { return child_->ListListings(context, request); }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::GetListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) { return child_->GetListing(context, request); }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::CreateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) { return child_->CreateListing(context, request); }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::UpdateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) { return child_->UpdateListing(context, request); }, + context, request, __func__, tracing_options_); +} + +Status AnalyticsHubServiceLogging::DeleteListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this]( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) { return child_->DeleteListing(context, request); }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::SubscribeListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + SubscribeListingRequest const& request) { + return child_->SubscribeListing(context, request); + }, + context, request, __func__, tracing_options_); +} + +StatusOr AnalyticsHubServiceLogging::GetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, request); + }, + context, request, __func__, tracing_options_); +} + +StatusOr AnalyticsHubServiceLogging::SetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, request); + }, + context, request, __func__, tracing_options_); +} + +StatusOr +AnalyticsHubServiceLogging::TestIamPermissions( + grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, request); + }, + context, request, __func__, tracing_options_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/internal/analytics_hub_logging_decorator.h b/google/cloud/bigquery/internal/analytics_hub_logging_decorator.h new file mode 100644 index 0000000000000..657205fb674b0 --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_logging_decorator.h @@ -0,0 +1,129 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_LOGGING_DECORATOR_H + +#include "google/cloud/bigquery/internal/analytics_hub_stub.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AnalyticsHubServiceLogging : public AnalyticsHubServiceStub { + public: + ~AnalyticsHubServiceLogging() override = default; + AnalyticsHubServiceLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set components); + + StatusOr + ListDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) override; + + StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> + ListOrgDataExchanges(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) override; + + StatusOr + GetDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) override; + + StatusOr + CreateDataExchange(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) override; + + StatusOr + UpdateDataExchange(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) override; + + Status DeleteDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) override; + + StatusOr + ListListings( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) override; + + StatusOr GetListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) override; + + StatusOr CreateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) override; + + StatusOr UpdateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) override; + + Status DeleteListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) override; + + StatusOr + SubscribeListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + private: + std::shared_ptr child_; + TracingOptions tracing_options_; + std::set components_; +}; // AnalyticsHubServiceLogging + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_LOGGING_DECORATOR_H diff --git a/google/cloud/bigquery/internal/analytics_hub_metadata_decorator.cc b/google/cloud/bigquery/internal/analytics_hub_metadata_decorator.cc new file mode 100644 index 0000000000000..3029be46c3431 --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_metadata_decorator.cc @@ -0,0 +1,186 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/internal/analytics_hub_metadata_decorator.h" +#include "google/cloud/common_options.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/status_or.h" +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AnalyticsHubServiceMetadata::AnalyticsHubServiceMetadata( + std::shared_ptr child) + : child_(std::move(child)), + api_client_header_( + google::cloud::internal::ApiClientHeader("generator")) {} + +StatusOr +AnalyticsHubServiceMetadata::ListDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) { + SetMetadata(context, "parent=" + request.parent()); + return child_->ListDataExchanges(context, request); +} + +StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> +AnalyticsHubServiceMetadata::ListOrgDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) { + SetMetadata(context, "organization=" + request.organization()); + return child_->ListOrgDataExchanges(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::GetDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) { + SetMetadata(context, "name=" + request.name()); + return child_->GetDataExchange(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::CreateDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateDataExchangeRequest const& + request) { + SetMetadata(context, "parent=" + request.parent()); + return child_->CreateDataExchange(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::UpdateDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateDataExchangeRequest const& + request) { + SetMetadata(context, "data_exchange.name=" + request.data_exchange().name()); + return child_->UpdateDataExchange(context, request); +} + +Status AnalyticsHubServiceMetadata::DeleteDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteDataExchangeRequest const& + request) { + SetMetadata(context, "name=" + request.name()); + return child_->DeleteDataExchange(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::ListListings( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) { + SetMetadata(context, "parent=" + request.parent()); + return child_->ListListings(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::GetListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) { + SetMetadata(context, "name=" + request.name()); + return child_->GetListing(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::CreateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) { + SetMetadata(context, "parent=" + request.parent()); + return child_->CreateListing(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::UpdateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) { + SetMetadata(context, "listing.name=" + request.listing().name()); + return child_->UpdateListing(context, request); +} + +Status AnalyticsHubServiceMetadata::DeleteListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) { + SetMetadata(context, "name=" + request.name()); + return child_->DeleteListing(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::SubscribeListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) { + SetMetadata(context, "name=" + request.name()); + return child_->SubscribeListing(context, request); +} + +StatusOr AnalyticsHubServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata(context, "resource=" + request.resource()); + return child_->GetIamPolicy(context, request); +} + +StatusOr AnalyticsHubServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata(context, "resource=" + request.resource()); + return child_->SetIamPolicy(context, request); +} + +StatusOr +AnalyticsHubServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata(context, "resource=" + request.resource()); + return child_->TestIamPermissions(context, request); +} + +void AnalyticsHubServiceMetadata::SetMetadata( + grpc::ClientContext& context, std::string const& request_params) { + context.AddMetadata("x-goog-request-params", request_params); + SetMetadata(context); +} + +void AnalyticsHubServiceMetadata::SetMetadata(grpc::ClientContext& context) { + context.AddMetadata("x-goog-api-client", api_client_header_); + auto const& options = internal::CurrentOptions(); + if (options.has()) { + context.AddMetadata("x-goog-user-project", + options.get()); + } + auto const& authority = options.get(); + if (!authority.empty()) context.set_authority(authority); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/internal/analytics_hub_metadata_decorator.h b/google/cloud/bigquery/internal/analytics_hub_metadata_decorator.h new file mode 100644 index 0000000000000..7bc5ff99c83ca --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_metadata_decorator.h @@ -0,0 +1,129 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_METADATA_DECORATOR_H + +#include "google/cloud/bigquery/internal/analytics_hub_stub.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AnalyticsHubServiceMetadata : public AnalyticsHubServiceStub { + public: + ~AnalyticsHubServiceMetadata() override = default; + explicit AnalyticsHubServiceMetadata( + std::shared_ptr child); + + StatusOr + ListDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) override; + + StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> + ListOrgDataExchanges(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) override; + + StatusOr + GetDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) override; + + StatusOr + CreateDataExchange(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) override; + + StatusOr + UpdateDataExchange(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) override; + + Status DeleteDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) override; + + StatusOr + ListListings( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) override; + + StatusOr GetListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) override; + + StatusOr CreateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) override; + + StatusOr UpdateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) override; + + Status DeleteListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) override; + + StatusOr + SubscribeListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + private: + void SetMetadata(grpc::ClientContext& context, + std::string const& request_params); + void SetMetadata(grpc::ClientContext& context); + + std::shared_ptr child_; + std::string api_client_header_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_METADATA_DECORATOR_H diff --git a/google/cloud/bigquery/internal/analytics_hub_option_defaults.cc b/google/cloud/bigquery/internal/analytics_hub_option_defaults.cc new file mode 100644 index 0000000000000..f993baa3d770a --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_option_defaults.cc @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/internal/analytics_hub_option_defaults.h" +#include "google/cloud/bigquery/analytics_hub_connection.h" +#include "google/cloud/bigquery/analytics_hub_options.h" +#include "google/cloud/internal/populate_common_options.h" +#include "google/cloud/internal/populate_grpc_options.h" +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options AnalyticsHubServiceDefaultOptions(Options options) { + options = google::cloud::internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_ANALYTICS_HUB_SERVICE_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_ANALYTICS_HUB_SERVICE_AUTHORITY", + "analyticshub.googleapis.com"); + options = + google::cloud::internal::PopulateGrpcOptions(std::move(options), ""); + if (!options.has()) { + options.set( + bigquery::AnalyticsHubServiceLimitedTimeRetryPolicy( + std::chrono::minutes(30)) + .clone()); + } + if (!options.has()) { + options.set( + ExponentialBackoffPolicy(std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling) + .clone()); + } + if (!options.has< + bigquery::AnalyticsHubServiceConnectionIdempotencyPolicyOption>()) { + options.set( + bigquery::MakeDefaultAnalyticsHubServiceConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/internal/analytics_hub_option_defaults.h b/google/cloud/bigquery/internal/analytics_hub_option_defaults.h new file mode 100644 index 0000000000000..80ffdc9fd2370 --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options AnalyticsHubServiceDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_OPTION_DEFAULTS_H diff --git a/google/cloud/bigquery/internal/analytics_hub_retry_traits.h b/google/cloud/bigquery/internal/analytics_hub_retry_traits.h new file mode 100644 index 0000000000000..2a38701794515 --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct AnalyticsHubServiceRetryTraits { + static inline bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_RETRY_TRAITS_H diff --git a/google/cloud/bigquery/internal/analytics_hub_stub.cc b/google/cloud/bigquery/internal/analytics_hub_stub.cc new file mode 100644 index 0000000000000..690edf7b55a38 --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_stub.cc @@ -0,0 +1,233 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/internal/analytics_hub_stub.h" +#include "google/cloud/grpc_error_delegate.h" +#include "google/cloud/status_or.h" +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +AnalyticsHubServiceStub::~AnalyticsHubServiceStub() = default; + +StatusOr +DefaultAnalyticsHubServiceStub::ListDataExchanges( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::ListDataExchangesResponse response; + auto status = + grpc_stub_->ListDataExchanges(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> +DefaultAnalyticsHubServiceStub::ListOrgDataExchanges( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) { + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse + response; + auto status = + grpc_stub_->ListOrgDataExchanges(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnalyticsHubServiceStub::GetDataExchange( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::DataExchange response; + auto status = + grpc_stub_->GetDataExchange(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnalyticsHubServiceStub::CreateDataExchange( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::CreateDataExchangeRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::DataExchange response; + auto status = + grpc_stub_->CreateDataExchange(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnalyticsHubServiceStub::UpdateDataExchange( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::UpdateDataExchangeRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::DataExchange response; + auto status = + grpc_stub_->UpdateDataExchange(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAnalyticsHubServiceStub::DeleteDataExchange( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::DeleteDataExchangeRequest const& + request) { + google::protobuf::Empty response; + auto status = + grpc_stub_->DeleteDataExchange(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultAnalyticsHubServiceStub::ListListings( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::ListListingsResponse response; + auto status = grpc_stub_->ListListings(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnalyticsHubServiceStub::GetListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::Listing response; + auto status = grpc_stub_->GetListing(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnalyticsHubServiceStub::CreateListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::Listing response; + auto status = grpc_stub_->CreateListing(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnalyticsHubServiceStub::UpdateListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::Listing response; + auto status = grpc_stub_->UpdateListing(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +Status DefaultAnalyticsHubServiceStub::DeleteListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) { + google::protobuf::Empty response; + auto status = grpc_stub_->DeleteListing(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return google::cloud::Status(); +} + +StatusOr +DefaultAnalyticsHubServiceStub::SubscribeListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) { + google::cloud::bigquery::analyticshub::v1::SubscribeListingResponse response; + auto status = + grpc_stub_->SubscribeListing(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAnalyticsHubServiceStub::GetIamPolicy( + grpc::ClientContext& client_context, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = grpc_stub_->GetIamPolicy(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAnalyticsHubServiceStub::SetIamPolicy( + grpc::ClientContext& client_context, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = grpc_stub_->SetIamPolicy(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnalyticsHubServiceStub::TestIamPermissions( + grpc::ClientContext& client_context, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + grpc_stub_->TestIamPermissions(&client_context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/internal/analytics_hub_stub.h b/google/cloud/bigquery/internal/analytics_hub_stub.h new file mode 100644 index 0000000000000..af06354e881ca --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_stub.h @@ -0,0 +1,216 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_STUB_H + +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class AnalyticsHubServiceStub { + public: + virtual ~AnalyticsHubServiceStub() = 0; + + virtual StatusOr< + google::cloud::bigquery::analyticshub::v1::ListDataExchangesResponse> + ListDataExchanges( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) = 0; + + virtual StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> + ListOrgDataExchanges(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) = 0; + + virtual StatusOr + GetDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) = 0; + + virtual StatusOr + CreateDataExchange(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) = 0; + + virtual StatusOr + UpdateDataExchange(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) = 0; + + virtual Status DeleteDataExchange( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) = 0; + + virtual StatusOr< + google::cloud::bigquery::analyticshub::v1::ListListingsResponse> + ListListings( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) = 0; + + virtual StatusOr + GetListing(grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) = 0; + + virtual StatusOr + CreateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) = 0; + + virtual StatusOr + UpdateListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) = 0; + + virtual Status DeleteListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) = 0; + + virtual StatusOr< + google::cloud::bigquery::analyticshub::v1::SubscribeListingResponse> + SubscribeListing( + grpc::ClientContext& context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; +}; + +class DefaultAnalyticsHubServiceStub : public AnalyticsHubServiceStub { + public: + explicit DefaultAnalyticsHubServiceStub( + std::unique_ptr + grpc_stub) + : grpc_stub_(std::move(grpc_stub)) {} + + StatusOr + ListDataExchanges( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest const& + request) override; + + StatusOr< + google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesResponse> + ListOrgDataExchanges(grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1:: + ListOrgDataExchangesRequest const& request) override; + + StatusOr + GetDataExchange( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request) override; + + StatusOr + CreateDataExchange(grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request) override; + + StatusOr + UpdateDataExchange(grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request) override; + + Status DeleteDataExchange( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request) override; + + StatusOr + ListListings( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::ListListingsRequest const& + request) override; + + StatusOr GetListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request) override; + + StatusOr CreateListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request) override; + + StatusOr UpdateListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request) override; + + Status DeleteListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request) override; + + StatusOr + SubscribeListing( + grpc::ClientContext& client_context, + google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& client_context, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& client_context, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& client_context, + google::iam::v1::TestIamPermissionsRequest const& request) override; + + private: + std::unique_ptr + grpc_stub_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_STUB_H diff --git a/google/cloud/bigquery/internal/analytics_hub_stub_factory.cc b/google/cloud/bigquery/internal/analytics_hub_stub_factory.cc new file mode 100644 index 0000000000000..f95498290b85d --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_stub_factory.cc @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#include "google/cloud/bigquery/internal/analytics_hub_stub_factory.h" +#include "google/cloud/bigquery/internal/analytics_hub_auth_decorator.h" +#include "google/cloud/bigquery/internal/analytics_hub_logging_decorator.h" +#include "google/cloud/bigquery/internal/analytics_hub_metadata_decorator.h" +#include "google/cloud/bigquery/internal/analytics_hub_stub.h" +#include "google/cloud/common_options.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultAnalyticsHubServiceStub( + google::cloud::CompletionQueue cq, Options const& options) { + auto auth = google::cloud::internal::CreateAuthenticationStrategy( + std::move(cq), options); + auto channel = auth->CreateChannel(options.get(), + internal::MakeChannelArguments(options)); + auto service_grpc_stub = + google::cloud::bigquery::analyticshub::v1::AnalyticsHubService::NewStub( + channel); + std::shared_ptr stub = + std::make_shared( + std::move(service_grpc_stub)); + + if (auth->RequiresConfigureContext()) { + stub = std::make_shared(std::move(auth), + std::move(stub)); + } + stub = std::make_shared(std::move(stub)); + if (internal::Contains(options.get(), "rpc")) { + GCP_LOG(INFO) << "Enabled logging for gRPC calls"; + stub = std::make_shared( + std::move(stub), options.get(), + options.get()); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/bigquery/internal/analytics_hub_stub_factory.h b/google/cloud/bigquery/internal/analytics_hub_stub_factory.h new file mode 100644 index 0000000000000..53918d08754be --- /dev/null +++ b/google/cloud/bigquery/internal/analytics_hub_stub_factory.h @@ -0,0 +1,42 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_STUB_FACTORY_H + +#include "google/cloud/bigquery/internal/analytics_hub_stub.h" +#include "google/cloud/completion_queue.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace bigquery_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultAnalyticsHubServiceStub( + google::cloud::CompletionQueue cq, Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_ANALYTICS_HUB_STUB_FACTORY_H diff --git a/google/cloud/bigquery/mocks/mock_analytics_hub_connection.h b/google/cloud/bigquery/mocks/mock_analytics_hub_connection.h new file mode 100644 index 0000000000000..cb1d69e440a86 --- /dev/null +++ b/google/cloud/bigquery/mocks/mock_analytics_hub_connection.h @@ -0,0 +1,147 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/cloud/bigquery/analyticshub/v1/analyticshub.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_MOCKS_MOCK_ANALYTICS_HUB_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_MOCKS_MOCK_ANALYTICS_HUB_CONNECTION_H + +#include "google/cloud/bigquery/analytics_hub_connection.h" +#include + +namespace google { +namespace cloud { +namespace bigquery_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `AnalyticsHubServiceConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `AnalyticsHubServiceClient`. To do + * so, construct an object of type `AnalyticsHubServiceClient` 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]: @googleapis_dev_link{bigquery,bigquery-read-mock.html} + */ +class MockAnalyticsHubServiceConnection + : public bigquery::AnalyticsHubServiceConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD( + StreamRange, + ListDataExchanges, + (google::cloud::bigquery::analyticshub::v1::ListDataExchangesRequest + request), + (override)); + + MOCK_METHOD( + StreamRange, + ListOrgDataExchanges, + (google::cloud::bigquery::analyticshub::v1::ListOrgDataExchangesRequest + request), + (override)); + + MOCK_METHOD( + StatusOr, + GetDataExchange, + (google::cloud::bigquery::analyticshub::v1::GetDataExchangeRequest const& + request), + (override)); + + MOCK_METHOD(StatusOr, + CreateDataExchange, + (google::cloud::bigquery::analyticshub::v1:: + CreateDataExchangeRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + UpdateDataExchange, + (google::cloud::bigquery::analyticshub::v1:: + UpdateDataExchangeRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteDataExchange, + (google::cloud::bigquery::analyticshub::v1:: + DeleteDataExchangeRequest const& request), + (override)); + + MOCK_METHOD( + StreamRange, + ListListings, + (google::cloud::bigquery::analyticshub::v1::ListListingsRequest request), + (override)); + + MOCK_METHOD( + StatusOr, GetListing, + (google::cloud::bigquery::analyticshub::v1::GetListingRequest const& + request), + (override)); + + MOCK_METHOD( + StatusOr, + CreateListing, + (google::cloud::bigquery::analyticshub::v1::CreateListingRequest const& + request), + (override)); + + MOCK_METHOD( + StatusOr, + UpdateListing, + (google::cloud::bigquery::analyticshub::v1::UpdateListingRequest const& + request), + (override)); + + MOCK_METHOD( + Status, DeleteListing, + (google::cloud::bigquery::analyticshub::v1::DeleteListingRequest const& + request), + (override)); + + MOCK_METHOD( + StatusOr< + google::cloud::bigquery::analyticshub::v1::SubscribeListingResponse>, + SubscribeListing, + (google::cloud::bigquery::analyticshub::v1::SubscribeListingRequest const& + request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace bigquery_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_MOCKS_MOCK_ANALYTICS_HUB_CONNECTION_H