Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bigquery): add migration service #10034

Merged
merged 3 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/etc/expected_install_directories
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
./include/google/cloud/bigquery/datatransfer
./include/google/cloud/bigquery/datatransfer/v1
./include/google/cloud/bigquery/internal
./include/google/cloud/bigquery/migration
./include/google/cloud/bigquery/migration/v2
./include/google/cloud/bigquery/mocks
./include/google/cloud/bigquery/reservation
./include/google/cloud/bigquery/reservation/v1
Expand Down
5 changes: 5 additions & 0 deletions external/googleapis/protodeps/bigquery.deps
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
@com_google_googleapis//google/api:annotations_proto
@com_google_googleapis//google/api:client_proto
@com_google_googleapis//google/api:distribution_proto
@com_google_googleapis//google/api:field_behavior_proto
@com_google_googleapis//google/api:http_proto
@com_google_googleapis//google/api:label_proto
@com_google_googleapis//google/api:launch_stage_proto
@com_google_googleapis//google/api:metric_proto
@com_google_googleapis//google/api:resource_proto
@com_google_googleapis//google/iam/v1:iam_policy_proto
@com_google_googleapis//google/iam/v1:options_proto
@com_google_googleapis//google/iam/v1:policy_proto
@com_google_googleapis//google/rpc:error_details_proto
@com_google_googleapis//google/rpc:status_proto
@com_google_googleapis//google/type:expr_proto
5 changes: 5 additions & 0 deletions external/googleapis/protolists/bigquery.list
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
@com_google_googleapis//google/cloud/bigquery/datatransfer/v1:datatransfer.proto
@com_google_googleapis//google/cloud/bigquery/datatransfer/v1:transfer.proto
@com_google_googleapis//google/cloud/bigquery/logging/v1:audit_data.proto
@com_google_googleapis//google/cloud/bigquery/migration/v2:migration_entities.proto
@com_google_googleapis//google/cloud/bigquery/migration/v2:migration_error_details.proto
@com_google_googleapis//google/cloud/bigquery/migration/v2:migration_metrics.proto
@com_google_googleapis//google/cloud/bigquery/migration/v2:migration_service.proto
@com_google_googleapis//google/cloud/bigquery/migration/v2:translation_config.proto
@com_google_googleapis//google/cloud/bigquery/reservation/v1:reservation.proto
@com_google_googleapis//google/cloud/bigquery/storage/v1:annotations.proto
@com_google_googleapis//google/cloud/bigquery/storage/v1:arrow.proto
Expand Down
14 changes: 8 additions & 6 deletions external/googleapis/update_libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ declare -A -r LIBRARIES=(
"@com_google_googleapis//google/cloud/beyondcorp/clientgateways/v1:clientgateways_cc_grpc"
)"
["bigquery"]="$(
# This is long enough that it needs to be kept in alphabetical order
printf ",%s" \
"@com_google_googleapis//google/cloud/bigquery/v2:bigquery_cc_grpc" \
"@com_google_googleapis//google/cloud/bigquery/storage/v1:storage_cc_grpc" \
"@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/analyticshub/v1:analyticshub_cc_grpc" \
"@com_google_googleapis//google/cloud/bigquery/connection/v1:connection_cc_grpc" \
"@com_google_googleapis//google/cloud/bigquery/analyticshub/v1:analyticshub_cc_grpc"
"@com_google_googleapis//google/cloud/bigquery/datatransfer/v1:datatransfer_cc_grpc" \
"@com_google_googleapis//google/cloud/bigquery/logging/v1:logging_cc_grpc" \
"@com_google_googleapis//google/cloud/bigquery/migration/v2:migration_cc_grpc" \
"@com_google_googleapis//google/cloud/bigquery/reservation/v1:reservation_cc_grpc" \
"@com_google_googleapis//google/cloud/bigquery/storage/v1:storage_cc_grpc" \
"@com_google_googleapis//google/cloud/bigquery/v2:bigquery_cc_grpc"
)"
["bigtable"]="$(
printf ",%s" \
Expand Down
31 changes: 19 additions & 12 deletions generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -159,53 +159,60 @@ service {

# BigQuery
service {
service_proto_path: "google/cloud/bigquery/storage/v1/storage.proto"
service_proto_path: "google/cloud/bigquery/analyticshub/v1/analyticshub.proto"
product_path: "google/cloud/bigquery"
initial_copyright_year: "2021"
omitted_services: ["BigQueryWrite"]
backwards_compatibility_namespace_alias: true
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/bigquery/storage/v1/storage.proto"
service_proto_path: "google/cloud/bigquery/connection/v1/connection.proto"
product_path: "google/cloud/bigquery"
initial_copyright_year: "2022"
omitted_services: ["BigQueryRead"]
service_endpoint_env_var: "GOOGLE_CLOUD_CPP_BIGQUERY_CONNECTION_SERVICE_ENDPOINT"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/bigquery/connection/v1/connection.proto"
service_proto_path: "google/cloud/bigquery/datatransfer/v1/datatransfer.proto"
product_path: "google/cloud/bigquery"
initial_copyright_year: "2022"
service_endpoint_env_var: "GOOGLE_CLOUD_CPP_BIGQUERY_CONNECTION_SERVICE_ENDPOINT"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/bigquery/reservation/v1/reservation.proto"
service_proto_path: "google/cloud/bigquery/migration/v2/migration_service.proto"
product_path: "google/cloud/bigquery"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/bigquery/datatransfer/v1/datatransfer.proto"
service_proto_path: "google/cloud/bigquery/reservation/v1/reservation.proto"
product_path: "google/cloud/bigquery"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/bigquery/v2/model.proto"
service_proto_path: "google/cloud/bigquery/storage/v1/storage.proto"
product_path: "google/cloud/bigquery"
initial_copyright_year: "2021"
omitted_services: ["BigQueryWrite"]
backwards_compatibility_namespace_alias: true
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/bigquery/storage/v1/storage.proto"
product_path: "google/cloud/bigquery"
initial_copyright_year: "2022"
omitted_services: ["BigQueryRead"]
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/bigquery/analyticshub/v1/analyticshub.proto"
service_proto_path: "google/cloud/bigquery/v2/model.proto"
product_path: "google/cloud/bigquery"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
Expand Down
104 changes: 104 additions & 0 deletions google/cloud/bigquery/internal/migration_auth_decorator.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// 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/migration/v2/migration_service.proto

#include "google/cloud/bigquery/internal/migration_auth_decorator.h"
#include <google/cloud/bigquery/migration/v2/migration_service.grpc.pb.h>
#include <memory>

namespace google {
namespace cloud {
namespace bigquery_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

MigrationServiceAuth::MigrationServiceAuth(
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth,
std::shared_ptr<MigrationServiceStub> child)
: auth_(std::move(auth)), child_(std::move(child)) {}

StatusOr<google::cloud::bigquery::migration::v2::MigrationWorkflow>
MigrationServiceAuth::CreateMigrationWorkflow(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::
CreateMigrationWorkflowRequest const& request) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->CreateMigrationWorkflow(context, request);
}

StatusOr<google::cloud::bigquery::migration::v2::MigrationWorkflow>
MigrationServiceAuth::GetMigrationWorkflow(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::GetMigrationWorkflowRequest const&
request) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->GetMigrationWorkflow(context, request);
}

StatusOr<google::cloud::bigquery::migration::v2::ListMigrationWorkflowsResponse>
MigrationServiceAuth::ListMigrationWorkflows(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::ListMigrationWorkflowsRequest const&
request) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->ListMigrationWorkflows(context, request);
}

Status MigrationServiceAuth::DeleteMigrationWorkflow(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::
DeleteMigrationWorkflowRequest const& request) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->DeleteMigrationWorkflow(context, request);
}

Status MigrationServiceAuth::StartMigrationWorkflow(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::StartMigrationWorkflowRequest const&
request) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->StartMigrationWorkflow(context, request);
}

StatusOr<google::cloud::bigquery::migration::v2::MigrationSubtask>
MigrationServiceAuth::GetMigrationSubtask(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::GetMigrationSubtaskRequest const&
request) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->GetMigrationSubtask(context, request);
}

StatusOr<google::cloud::bigquery::migration::v2::ListMigrationSubtasksResponse>
MigrationServiceAuth::ListMigrationSubtasks(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::ListMigrationSubtasksRequest const&
request) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->ListMigrationSubtasks(context, request);
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace bigquery_internal
} // namespace cloud
} // namespace google
93 changes: 93 additions & 0 deletions google/cloud/bigquery/internal/migration_auth_decorator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// 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/migration/v2/migration_service.proto

#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_MIGRATION_AUTH_DECORATOR_H
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_MIGRATION_AUTH_DECORATOR_H

#include "google/cloud/bigquery/internal/migration_stub.h"
#include "google/cloud/internal/unified_grpc_credentials.h"
#include "google/cloud/version.h"
#include <memory>
#include <set>
#include <string>

namespace google {
namespace cloud {
namespace bigquery_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

class MigrationServiceAuth : public MigrationServiceStub {
public:
~MigrationServiceAuth() override = default;
MigrationServiceAuth(
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth,
std::shared_ptr<MigrationServiceStub> child);

StatusOr<google::cloud::bigquery::migration::v2::MigrationWorkflow>
CreateMigrationWorkflow(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::
CreateMigrationWorkflowRequest const& request) override;

StatusOr<google::cloud::bigquery::migration::v2::MigrationWorkflow>
GetMigrationWorkflow(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::GetMigrationWorkflowRequest const&
request) override;

StatusOr<
google::cloud::bigquery::migration::v2::ListMigrationWorkflowsResponse>
ListMigrationWorkflows(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::
ListMigrationWorkflowsRequest const& request) override;

Status DeleteMigrationWorkflow(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::
DeleteMigrationWorkflowRequest const& request) override;

Status StartMigrationWorkflow(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::
StartMigrationWorkflowRequest const& request) override;

StatusOr<google::cloud::bigquery::migration::v2::MigrationSubtask>
GetMigrationSubtask(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::GetMigrationSubtaskRequest const&
request) override;

StatusOr<
google::cloud::bigquery::migration::v2::ListMigrationSubtasksResponse>
ListMigrationSubtasks(
grpc::ClientContext& context,
google::cloud::bigquery::migration::v2::
ListMigrationSubtasksRequest const& request) override;

private:
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth_;
std::shared_ptr<MigrationServiceStub> child_;
};

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace bigquery_internal
} // namespace cloud
} // namespace google

#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_INTERNAL_MIGRATION_AUTH_DECORATOR_H
Loading