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(generator): add options support to generated clients #7683

Merged
merged 4 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions ci/cloudbuild/builds/cmake-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ mapfile -t actual_dirs < <(env -C "${INSTALL_PREFIX}" find -type d)
mapfile -t expected_dirs < <(cat ci/etc/expected_install_directories)
expected_dirs+=(
./include/google/api
./include/google/bigtable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this change seems unrelated, but I guess you had to do it as part of regenerating all the libraries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. That is, apart from the generator changes themselves, everything else here was either generated or required by a test because of the regeneration.

./include/google/bigtable/admin
./include/google/bigtable/admin/v2
./include/google/bigtable/v2
./include/google/cloud/bigquery/connection
./include/google/cloud/bigquery/connection/v1
Expand All @@ -62,6 +65,7 @@ expected_dirs+=(
./include/google/cloud/bigquery/reservation
./include/google/cloud/bigquery/reservation/v1
./include/google/cloud/bigquery/v2
./include/google/cloud/bigtable
./include/google/cloud/bigtable/internal
./include/google/cloud/dialogflow
./include/google/cloud/dialogflow/v2
Expand Down
4 changes: 0 additions & 4 deletions ci/etc/expected_install_directories
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
.
./include
./include/google
./include/google/bigtable
./include/google/bigtable/admin
./include/google/bigtable/admin/v2
./include/google/cloud
./include/google/cloud/bigquery
./include/google/cloud/bigquery/internal
./include/google/cloud/bigquery/mocks
./include/google/cloud/bigquery/storage
./include/google/cloud/bigquery/storage/v1
./include/google/cloud/bigtable
./include/google/cloud/iam
./include/google/cloud/iam/internal
./include/google/cloud/iam/mocks
Expand Down
39 changes: 26 additions & 13 deletions generator/integration_tests/golden/golden_kitchen_sink_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
// source: generator/integration_tests/test.proto

#include "generator/integration_tests/golden/golden_kitchen_sink_client.h"
#include "generator/integration_tests/golden/internal/golden_kitchen_sink_option_defaults.h"
#include <memory>

namespace google {
namespace cloud {
namespace golden {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

GoldenKitchenSinkClient::GoldenKitchenSinkClient(std::shared_ptr<GoldenKitchenSinkConnection> connection) : connection_(std::move(connection)) {}
GoldenKitchenSinkClient::GoldenKitchenSinkClient(std::shared_ptr<GoldenKitchenSinkConnection> connection, Options options) : connection_(std::move(connection)), options_(golden_internal::GoldenKitchenSinkDefaultOptions(std::move(options))) {}
GoldenKitchenSinkClient::~GoldenKitchenSinkClient() = default;

StatusOr<google::test::admin::database::v1::GenerateAccessTokenResponse>
GoldenKitchenSinkClient::GenerateAccessToken(std::string const& name, std::vector<std::string> const& delegates, std::vector<std::string> const& scope, google::protobuf::Duration const& lifetime) {
GoldenKitchenSinkClient::GenerateAccessToken(std::string const& name, std::vector<std::string> const& delegates, std::vector<std::string> const& scope, google::protobuf::Duration const& lifetime, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
google::test::admin::database::v1::GenerateAccessTokenRequest request;
request.set_name(name);
*request.mutable_delegates() = {delegates.begin(), delegates.end()};
Expand All @@ -38,7 +40,8 @@ GoldenKitchenSinkClient::GenerateAccessToken(std::string const& name, std::vecto
}

StatusOr<google::test::admin::database::v1::GenerateIdTokenResponse>
GoldenKitchenSinkClient::GenerateIdToken(std::string const& name, std::vector<std::string> const& delegates, std::string const& audience, bool include_email) {
GoldenKitchenSinkClient::GenerateIdToken(std::string const& name, std::vector<std::string> const& delegates, std::string const& audience, bool include_email, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
google::test::admin::database::v1::GenerateIdTokenRequest request;
request.set_name(name);
*request.mutable_delegates() = {delegates.begin(), delegates.end()};
Expand All @@ -48,62 +51,72 @@ GoldenKitchenSinkClient::GenerateIdToken(std::string const& name, std::vector<st
}

StatusOr<google::test::admin::database::v1::WriteLogEntriesResponse>
GoldenKitchenSinkClient::WriteLogEntries(std::string const& log_name, std::map<std::string, std::string> const& labels) {
GoldenKitchenSinkClient::WriteLogEntries(std::string const& log_name, std::map<std::string, std::string> const& labels, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
google::test::admin::database::v1::WriteLogEntriesRequest request;
request.set_log_name(log_name);
*request.mutable_labels() = {labels.begin(), labels.end()};
return connection_->WriteLogEntries(request);
}

StreamRange<std::string>
GoldenKitchenSinkClient::ListLogs(std::string const& parent) {
GoldenKitchenSinkClient::ListLogs(std::string const& parent, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
google::test::admin::database::v1::ListLogsRequest request;
request.set_parent(parent);
return connection_->ListLogs(request);
}

StreamRange<google::test::admin::database::v1::TailLogEntriesResponse>
GoldenKitchenSinkClient::TailLogEntries(std::vector<std::string> const& resource_names) {
GoldenKitchenSinkClient::TailLogEntries(std::vector<std::string> const& resource_names, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
google::test::admin::database::v1::TailLogEntriesRequest request;
*request.mutable_resource_names() = {resource_names.begin(), resource_names.end()};
return connection_->TailLogEntries(request);
}

StatusOr<google::test::admin::database::v1::ListServiceAccountKeysResponse>
GoldenKitchenSinkClient::ListServiceAccountKeys(std::string const& name, std::vector<google::test::admin::database::v1::ListServiceAccountKeysRequest::KeyType> const& key_types) {
GoldenKitchenSinkClient::ListServiceAccountKeys(std::string const& name, std::vector<google::test::admin::database::v1::ListServiceAccountKeysRequest::KeyType> const& key_types, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
google::test::admin::database::v1::ListServiceAccountKeysRequest request;
request.set_name(name);
*request.mutable_key_types() = {key_types.begin(), key_types.end()};
return connection_->ListServiceAccountKeys(request);
}

StatusOr<google::test::admin::database::v1::GenerateAccessTokenResponse>
GoldenKitchenSinkClient::GenerateAccessToken(google::test::admin::database::v1::GenerateAccessTokenRequest const& request) {
GoldenKitchenSinkClient::GenerateAccessToken(google::test::admin::database::v1::GenerateAccessTokenRequest const& request, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
return connection_->GenerateAccessToken(request);
}

StatusOr<google::test::admin::database::v1::GenerateIdTokenResponse>
GoldenKitchenSinkClient::GenerateIdToken(google::test::admin::database::v1::GenerateIdTokenRequest const& request) {
GoldenKitchenSinkClient::GenerateIdToken(google::test::admin::database::v1::GenerateIdTokenRequest const& request, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
return connection_->GenerateIdToken(request);
}

StatusOr<google::test::admin::database::v1::WriteLogEntriesResponse>
GoldenKitchenSinkClient::WriteLogEntries(google::test::admin::database::v1::WriteLogEntriesRequest const& request) {
GoldenKitchenSinkClient::WriteLogEntries(google::test::admin::database::v1::WriteLogEntriesRequest const& request, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
return connection_->WriteLogEntries(request);
}

StreamRange<std::string>
GoldenKitchenSinkClient::ListLogs(google::test::admin::database::v1::ListLogsRequest request) {
GoldenKitchenSinkClient::ListLogs(google::test::admin::database::v1::ListLogsRequest request, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
return connection_->ListLogs(std::move(request));
}

StreamRange<google::test::admin::database::v1::TailLogEntriesResponse>
GoldenKitchenSinkClient::TailLogEntries(google::test::admin::database::v1::TailLogEntriesRequest const& request) {
GoldenKitchenSinkClient::TailLogEntries(google::test::admin::database::v1::TailLogEntriesRequest const& request, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
return connection_->TailLogEntries(request);
}

StatusOr<google::test::admin::database::v1::ListServiceAccountKeysResponse>
GoldenKitchenSinkClient::ListServiceAccountKeys(google::test::admin::database::v1::ListServiceAccountKeysRequest const& request) {
GoldenKitchenSinkClient::ListServiceAccountKeys(google::test::admin::database::v1::ListServiceAccountKeysRequest const& request, Options options) {
internal::OptionsSpan span(internal::MergeOptions(std::move(options), options_));
return connection_->ListServiceAccountKeys(request);
}

Expand Down
Loading