Skip to content

Commit 2c6dd06

Browse files
authored
feat(bigquerystorage): generate library (#8472)
1 parent b034484 commit 2c6dd06

29 files changed

+2385
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ The library has been expanded to include the following services:
105105
* [BigQuery Connection API](https://cloud.google.com/bigquery/docs/connections-api-intro)
106106
* [BigQuery Data Transfer Service](https://cloud.google.com/bigquery-transfer)
107107
* [BigQuery Reservations](https://cloud.google.com/bigquery/docs/reservations-intro)
108+
* [BigQuery Storage Write API](https://cloud.google.com/bigquery/docs/write-api)
108109

109110
### [Bigtable](https://github.com/googleapis/google-cloud-cpp/blob/main/google/cloud/bigtable/README.md)
110111

generator/generator_config.textproto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ service {
107107
retryable_status_codes: ["kDeadlineExceeded", "kUnavailable"]
108108
}
109109

110+
service {
111+
service_proto_path: "google/cloud/bigquery/storage/v1/storage.proto"
112+
product_path: "google/cloud/bigquery"
113+
initial_copyright_year: "2022"
114+
omitted_services: ["BigQueryRead"]
115+
retryable_status_codes: ["kUnavailable"]
116+
}
117+
110118
service {
111119
service_proto_path: "google/cloud/bigquery/connection/v1/connection.proto"
112120
product_path: "google/cloud/bigquery"

google/cloud/bigquery/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ add_library(
3838
bigquery_read_connection_idempotency_policy.cc
3939
bigquery_read_connection_idempotency_policy.h
4040
bigquery_read_options.h
41+
bigquery_write_client.cc
42+
bigquery_write_client.h
43+
bigquery_write_connection.cc
44+
bigquery_write_connection.h
45+
bigquery_write_connection_idempotency_policy.cc
46+
bigquery_write_connection_idempotency_policy.h
47+
bigquery_write_options.h
4148
connection_client.cc
4249
connection_client.h
4350
connection_connection.cc
@@ -67,6 +74,21 @@ add_library(
6774
internal/bigquery_read_stub.h
6875
internal/bigquery_read_stub_factory.cc
6976
internal/bigquery_read_stub_factory.h
77+
internal/bigquery_write_auth_decorator.cc
78+
internal/bigquery_write_auth_decorator.h
79+
internal/bigquery_write_connection_impl.cc
80+
internal/bigquery_write_connection_impl.h
81+
internal/bigquery_write_logging_decorator.cc
82+
internal/bigquery_write_logging_decorator.h
83+
internal/bigquery_write_metadata_decorator.cc
84+
internal/bigquery_write_metadata_decorator.h
85+
internal/bigquery_write_option_defaults.cc
86+
internal/bigquery_write_option_defaults.h
87+
internal/bigquery_write_retry_traits.h
88+
internal/bigquery_write_stub.cc
89+
internal/bigquery_write_stub.h
90+
internal/bigquery_write_stub_factory.cc
91+
internal/bigquery_write_stub_factory.h
7092
internal/connection_auth_decorator.cc
7193
internal/connection_auth_decorator.h
7294
internal/connection_connection_impl.cc
@@ -178,6 +200,7 @@ target_sources(
178200
google_cloud_cpp_bigquery_mocks
179201
INTERFACE # cmake-format: sort
180202
${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_bigquery_read_connection.h
203+
${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_bigquery_write_connection.h
181204
${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_connection_connection.h
182205
${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_data_transfer_connection.h
183206
${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_model_connection.h
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Generated by the Codegen C++ plugin.
16+
// If you make any local changes, they will be lost.
17+
// source: google/cloud/bigquery/storage/v1/storage.proto
18+
19+
#include "google/cloud/bigquery/bigquery_write_client.h"
20+
#include "google/cloud/bigquery/internal/bigquery_write_option_defaults.h"
21+
#include <memory>
22+
23+
namespace google {
24+
namespace cloud {
25+
namespace bigquery {
26+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
27+
28+
BigQueryWriteClient::BigQueryWriteClient(
29+
std::shared_ptr<BigQueryWriteConnection> connection, Options opts)
30+
: connection_(std::move(connection)),
31+
options_(internal::MergeOptions(
32+
std::move(opts), bigquery_internal::BigQueryWriteDefaultOptions(
33+
connection_->options()))) {}
34+
BigQueryWriteClient::~BigQueryWriteClient() = default;
35+
36+
StatusOr<google::cloud::bigquery::storage::v1::WriteStream>
37+
BigQueryWriteClient::CreateWriteStream(
38+
std::string const& parent,
39+
google::cloud::bigquery::storage::v1::WriteStream const& write_stream,
40+
Options opts) {
41+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
42+
google::cloud::bigquery::storage::v1::CreateWriteStreamRequest request;
43+
request.set_parent(parent);
44+
*request.mutable_write_stream() = write_stream;
45+
return connection_->CreateWriteStream(request);
46+
}
47+
48+
StatusOr<google::cloud::bigquery::storage::v1::WriteStream>
49+
BigQueryWriteClient::CreateWriteStream(
50+
google::cloud::bigquery::storage::v1::CreateWriteStreamRequest const&
51+
request,
52+
Options opts) {
53+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
54+
return connection_->CreateWriteStream(request);
55+
}
56+
57+
std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
58+
google::cloud::bigquery::storage::v1::AppendRowsRequest,
59+
google::cloud::bigquery::storage::v1::AppendRowsResponse>>
60+
BigQueryWriteClient::AsyncAppendRows(ExperimentalTag tag, Options opts) {
61+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
62+
return connection_->AsyncAppendRows(std::move(tag));
63+
}
64+
65+
StatusOr<google::cloud::bigquery::storage::v1::WriteStream>
66+
BigQueryWriteClient::GetWriteStream(std::string const& name, Options opts) {
67+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
68+
google::cloud::bigquery::storage::v1::GetWriteStreamRequest request;
69+
request.set_name(name);
70+
return connection_->GetWriteStream(request);
71+
}
72+
73+
StatusOr<google::cloud::bigquery::storage::v1::WriteStream>
74+
BigQueryWriteClient::GetWriteStream(
75+
google::cloud::bigquery::storage::v1::GetWriteStreamRequest const& request,
76+
Options opts) {
77+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
78+
return connection_->GetWriteStream(request);
79+
}
80+
81+
StatusOr<google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse>
82+
BigQueryWriteClient::FinalizeWriteStream(std::string const& name,
83+
Options opts) {
84+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
85+
google::cloud::bigquery::storage::v1::FinalizeWriteStreamRequest request;
86+
request.set_name(name);
87+
return connection_->FinalizeWriteStream(request);
88+
}
89+
90+
StatusOr<google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse>
91+
BigQueryWriteClient::FinalizeWriteStream(
92+
google::cloud::bigquery::storage::v1::FinalizeWriteStreamRequest const&
93+
request,
94+
Options opts) {
95+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
96+
return connection_->FinalizeWriteStream(request);
97+
}
98+
99+
StatusOr<google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse>
100+
BigQueryWriteClient::BatchCommitWriteStreams(std::string const& parent,
101+
Options opts) {
102+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
103+
google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsRequest request;
104+
request.set_parent(parent);
105+
return connection_->BatchCommitWriteStreams(request);
106+
}
107+
108+
StatusOr<google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse>
109+
BigQueryWriteClient::BatchCommitWriteStreams(
110+
google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsRequest const&
111+
request,
112+
Options opts) {
113+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
114+
return connection_->BatchCommitWriteStreams(request);
115+
}
116+
117+
StatusOr<google::cloud::bigquery::storage::v1::FlushRowsResponse>
118+
BigQueryWriteClient::FlushRows(std::string const& write_stream, Options opts) {
119+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
120+
google::cloud::bigquery::storage::v1::FlushRowsRequest request;
121+
request.set_write_stream(write_stream);
122+
return connection_->FlushRows(request);
123+
}
124+
125+
StatusOr<google::cloud::bigquery::storage::v1::FlushRowsResponse>
126+
BigQueryWriteClient::FlushRows(
127+
google::cloud::bigquery::storage::v1::FlushRowsRequest const& request,
128+
Options opts) {
129+
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
130+
return connection_->FlushRows(request);
131+
}
132+
133+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
134+
} // namespace bigquery
135+
} // namespace cloud
136+
} // namespace google

0 commit comments

Comments
 (0)